I have to write log entries through my app (ASP.NET -VB-)

In my understanding that's what I do: created a DLL Message library, then I've created certain registry entries, and insert the log entry using System.Diagnostics.EventLog.WriteEntry method on my app, then, it insert the entry but seems to be wrong somehow, the event shows:

"The description for Event ID ( 0 ) in Source ( -sourcecreated- ) 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 details. The following information is part of the event: <<HERE THE MESSAGE I WANT TO LOG>>"

So, what I need is, a Step by Step procedure to do this (baby steps if possible) to accomplish this successfuly.

Thank you

Omar

Dani AI

Generated

Short answer: Event Viewer shows that generic "description cannot be found" text when it cannot map your EventID to a message string from the message file registered for that source. The mapping is done from the registry key under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\<Log>\<YourSource> (the EventMessageFile / TypesSupported values), so if the message DLL is missing or does not contain the ID, you get the generic header and then the raw text you wrote. (learn.microsoft.com)

Baby steps to fix (safe for ASP.NET deployments)

  • Pick a single unique Source name and target log (Application is easiest).
  • Create that source once with administrative rights (installer, one-time admin script or PowerShell), do not try to create it on every request. In VB.NET:
    
    If Not EventLog.SourceExists("MyAppSource") Then
      EventLog.CreateEventSource("MyAppSource", "Application")
      ' Create the source at install time; restart the process before writing.
    End If

EventLog.WriteEntry("MyAppSource", "Your message here", EventLogEntryType.Information)


EventLog.CreateEventSource writes the registry keys and should be run elevated during deployment. ([learn.microsoft.com](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.eventlog.createeventsource?view=windowsdesktop-10.0&utm_source=openai))

If you need properly formatted messages by EventID (not just the raw string) you must supply a message resource DLL (compiled from .mc) and set EventMessageFile to that DLL path for your source. Verify the source key with regedit under the EventLog path and check EventMessageFile/CategoryMessageFile/TypesSupported. Windows will try to load the registered DLL(s) to format the EventID; if it fails you see the generic description text. ([learn.microsoft.com](https://learn.microsoft.com/en-us/windows/win32/eventlog/message-files?utm_source=openai))

Quick troubleshooting: on dev machines run New-EventLog or create the source via PowerShell as admin to mirror production; confirm the EventMessageFile path is accessible to XP if you still see differences between XP and Server 2003. If creating a message DLL is too heavy, register the source and log plain text messages (or use an existing source) so Event Viewer shows the message reliably. ([devblogs.microsoft.com](https://devblogs.microsoft.com/scripting/how-to-use-powershell-to-write-to-event-logs/?utm_source=openai))

Notes: @rapture was right to point toward examples; @culebrin, the XP vs 2K3 difference is usually a registry/message-file discrepancy — creating the source properly on each machine (or providing a real message DLL) will eliminate the "description cannot be found" header.

Recommended Answers

All 3 Replies

Well just searching on this site gave me some responses to this question, a google search on

vb.net how to write to the event log

brought up a ton of things. And last but not least have you used the help feature in Visual Studio? I looked for

"write to event log"

and got some interesting material. In other words, did you make any attempt to figure it out and you don't understand something or do you just want us to do it for you?

(I'm not trying to be a jerk, I'm actually trying to help.)

*hint, within the items I have stated there is a block of code that would be extremely useful to you. :)

You didn't mark it as solved, are you still stuck?

Did you find this site?

Well,

I did that, the problem was that I have a development machine that runs on XP SP2, and my production server runs on 2K3, works ok on windows server 2K3, but on my XP have that problem... I decided I can live with that...

Thanks to all for your help!!

Culebrin

You didn't mark it as solved, are you still stuck?

Did you find this site?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.