473,616 Members | 2,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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)0xnnnnnn nn)
" 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
misunderstandin g, or maybe point to some c# howto's or examples. I can't
seem to find any.

TIA,
-John
Nov 15 '05 #1
1 7282
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)0xnnnnnn nn) " 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
misunderstandin g, 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
(RegisterEventS ource, ReportEvent, UnregisterEvent Source) 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_MESSAGERESOU RCE.

Richard
--
my email ev******@zicf.b et 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
4114
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 2000) and run from a web browser, it works with my local machine only. I have the following error when I try to access any remote server: CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. The...
1
1538
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) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for...
0
1860
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 properly: System.Diagnostics.EventLog.WriteEntry("MySource", "My Message", EventLogEntryType.Information, 100, 9); where I want the severity to be Information, the message Event ID in my
2
3539
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 all the appropriate properties to assign the new Source to a new log. For some reason installutil.exe created the source in the correct log. But
3
1497
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. However, each entry starts with the following: The description for Event ID ( 0 ) in Source ( <<appname>> ) cannot be found. The local computer may not have the necessary registry
1
15975
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 log?! I have simplified my code into this tiny snippet: EventLog.CreateEventSource("mySrc", "myLog1");
3
4827
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). How can I monitor all three logs at once? Thanks,
0
1814
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 resourceful.mc content is like this. MessageId=0x1 Severity=Success SymbolicName=INSTALL_CATEGORY
3
1964
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 runs well for some time and then starts giving the following error: "The description for Event ID '0' in Source '' cannot be found. The local computer may not have the necessary registry information or message DLL files to display the message,...
0
8203
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8146
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8647
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8592
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7121
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4141
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2579
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.