Re: Message Resource DLL C# integration

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hamish wrote:
I'm looking to set up a .NET service (written in C#) that will write events to the event log and use a message resource dll to provide localized message text for the events.

The framework uses a clever hack to get event log messaging to work without the need for hardcoding strings in some DLL: all .NET event sources use mscoree.dll as the event message file, and this has a resource block with all possible message strings set to "%1" (i.e., just the first argument of a formattable string) so it can pass anything it likes directly to the API.

The thing that surprises me is that I still seem to need to use mc.exe and rc.exe to generate the resource only DLL and then I don't see a straightforward way to integrate the generated header file (with the category and message symbolic names) into the C# code for the service.

No, don't bother with all that nonsense, it's completely superfluous for ..NET applications.

For localization, .NET uses satellite assemblies and the ResourceManager class. Look it up in the docs, it's pretty straightforward. When you want to write to the event log, you can just write whatever string you want, including localized strings you looked up.

--
J.
.



Relevant Pages

  • Re: EventLog Category
    ... > I discovered through enumeration all of the event category strings ... The problem you have is because .NET does not use message/category resource ... Category values are handled by the event log in a similar way. ... RegistryPermission perm = new RegistryPermission( ...
    (microsoft.public.dotnet.framework)
  • Re: Edit Control
    ... I would prefer reading these strings from a string table resource. ... That works better for localization (instead of having string literals inside ...
    (microsoft.public.vc.language)
  • Re: .MC file and Event Viewer: Placeholders for Categories?
    ... strings that are merged into the message before Event Viewer displays the ... These strings must not be in English or any other specific language. ... app supplies the text to the event viewer. ... someone who has a message 602 in the event log needs to be able to decode it ...
    (microsoft.public.vc.mfc)
  • RE: MNS with FSW - Cluster setup error
    ... Set: Resource failed. ... Check Event Log. ... Dependent resources might fail too. ... can be resolved using Cluster Administrator. ...
    (microsoft.public.windows.server.clustering)
  • Re: Notification when an administrator logs in
    ... Note that however UserName is always empty for Security event log entries and only ReplacementStrings are provided. ... You are right that the event log format is documented and is not subject to change but a lot of important information are provided as replacement strings only. ... In order to retrieve the SID, we can first get the SID length from the UserSidLength field. ...
    (microsoft.public.win32.programmer.kernel)