473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

EventLog Message Text Files

I am trying to create a message text file for the Catagory field in order to
map the catagory input number to a string text. I have found some MSDN
information on this, but it appears to only be for C/C++.
What I have found in MSDN so far can be found here:
http://msdn.microsoft.com/library/de...sage_files.asp
and
http://msdn.microsoft.com/library/de...er_section.asp
Is it possible to do this in C#? I can't seem to find any howto's or
examples for c#.
My biggest hurdle doing this in C# is the " #define name ((type)0xnnnnnnnn)
" part. I know that c# can do "#defines name" but it can't take in a "type"
to my knowledge. Plus, I don't know what replaces the C++ headers in C#
(and I dont' know C++ in order to compare them).

So, if anyone knows how to create a message text file for the EventLog
Catagory field in C#, please let me know what I am missing or
misunderstanding, or maybe point to some c# howto's or examples. I can't
seem to find any.

TIA,
-John
Nov 15 '05 #1
1 7265
john s wrote:
I am trying to create a message text file for the Catagory field in
order to
map the catagory input number to a string text. I have found some
MSDN
information on this, but it appears to only be for C/C++.
Note that these .mc files are compiled by a special tool (message compiler,
mc.exe) that creates an unmanaged resource (.bin) that is added to the file
as a RT_MESSAGETABLE resource.

As the link mentions, when you install your application you register the
category and message resource files for your event log source by adding an
entry in the registry.
Is it possible to do this in C#? I can't seem to find any howto's or
examples for c#.
Sadly, no, not in v1.1 or v1.0. The EventLog class uses just one message
resource file which (put very politely, and not the language I would
normally use when talking about this class) is very lame.
My biggest hurdle doing this in C# is the " #define name
((type)0xnnnnnnnn) " part. I know that c# can do "#defines name" but
it can't take in a "type"
to my knowledge. Plus, I don't know what replaces the C++ headers in
C# (and I dont' know C++ in order to compare them).
Unfortunately you've misunderstood the docs. The data in the .mc files are a
special format understood *only* by the mc.exe tool. I wrote an article
about this for Visual C++ Developer that describes this, this article used
to be on MSDN library, but its not there anymore :-(
So, if anyone knows how to create a message text file for the EventLog
Catagory field in C#, please let me know what I am missing or
misunderstanding, or maybe point to some c# howto's or examples. I
can't
seem to find any.


If you want to use them now (and in the future) then create your own event
log category/message resource files and use a .NET Installer class to
register them when the app is installed. Then use the unmanaged functions
(RegisterEventSource, ReportEvent, UnregisterEventSource) to report the
event. On *no account* should you ever use EventLog to *write* event log
messages. This class is $%*#@ (I'm trying hard to be polite) Only use
EventLog to *read* event log messages.

The next version of the framework (Whidbey) is supposed to fix this issue,
for example:
http://longhorn.msdn.microsoft.com/l...ntsource2.aspx

Note that this will not allow you to create the message resource files in
C#.

The source for the mc.exe tool used to be available as part of the Platform
SDK (I've not checked in a while), but I would have thought that because
Microsoft are *so* in love with XML this would be a great use for it -
describe the message/category format strings as XML items and create a class
that reads the XML and compiles them to a RT_MESSAGERESOURCE.

Richard
--
my email ev******@zicf.bet is encrypted with ROT13 (www.rot13.org)
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joe | last post by:
I am trying to read the EventLog of different servers on the network. If I run the script in a command line, it works well. But when I try to put the script into the Web server (IIS in Windows...
1
by: Morris | last post by:
I create a custom log and write new entries to this log fine. However, at random time, I got error message error message like this "The description for Event ID ( 0 ) in Source ( MyCustomLog)...
0
by: Steve DeLong | last post by:
I have a set of C++ applications that all use a common message DLL. I am working on a .NET Service that I would also like to use this same message DLL. From what I have read, this should work...
2
by: Next | last post by:
Hello all, I have a windows service that was suppose to write some events into its own EventLog. I created the EventLog using the component on VS 2003 toolbar Added an installer for it. Set...
3
by: bas jaburg | last post by:
Hi, I am using the Microsoft Application BuildingBolock (Freudian slip, hahaha) Exception Management and am using a CustomPublisher. This goes fine and it write's stuff the Windows EventLog. ...
1
by: martin | last post by:
Hi, I'm having some problems with the System.Diagnostics.EventLog class in .NET 2.0 I need to recreate an event message source inside a new log but the messages keeps ending up in the old...
3
by: Ben | last post by:
I am trying to write an eventlog monitor. I am using the sample code provided by VB2005 SDK as the bases for my application. I need to monitor all three logs (application, system, and security)....
0
by: rene | last post by:
I'm trying to use costome categories in my eventlog for a program I'm writing. But I have some problems with it, I cant get it to work. Checklist for how I did this. 1. Created a...
3
by: psabale | last post by:
Hi All, I have created a tool in c#, which monitors the eventlog ( security log) and fetches the details of every new entry. The tool runs fine on one of the machines, but on another machine it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.