简体   繁体   中英

Eventlog creation using wix on 32bit vs 64bit OS

The recommended way to create an Application Event Log using wix seems to be

 <Util:EventSource
          Name="BLAH"
          Log="Application"
          EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR]EventLogMessages.dll"/>

On 64bit OS you replace it NETFRAMEWORK40FULLINSTALLROOTDIR with NETFRAMEWORK40FULLINSTALLROOTDIR64.

I have noticed that when you run a 32bit app on a 64bit OS it creates an event log with NETFRAMEWORK40FULLINSTALLROOTDIR when your use the .NET EventLog.CreateEventSource method from code.

EventMessageFile => C:\Windows\Microsoft.NET\Framework\v4.0.30319\EventLogMessages.dll

If you run a 64bit version of the app with no eventlog it will create it so

EventMessageFile => C:\Windows\Microsoft.NET\Framework64\v4.0.30319\EventLogMessages.dll

Regardless of whether the EventMessageFile has Framework or Framework64 in the path both 32bit and 64bit versions of the app can write to it merrily once it is created.

Is this supported behavior? What is the correct way to create it if one were to allow both 32bit and 64bit versions of the app side by side ?

The Windows event log allows you to create localized event log message files. When Microsoft is writing a service that is part of Windows they probably want to be able to localize what is written to the event log. However, almost everybody else just wants to be able to write a string in their language of choice to the event log and that is exactly what the .NET event log wrapper provides. Thus .NET provides a very generic event log message file that contains no localized messages but just a message with a single argument placeholder where the supplied string argument is inserted giving you total control of what your .NET application writes to the event log.

I would be surprised if the 32 bit and the 64 bit default event log message files in .NET ( EventLogMessages.dll ) contained different messages but even with this knowledge you should point your 32 bit service to the 32 bit DLL and the 64 bit service to the 64 bit DLL. And if I understand your question correctly that is exactly the behavior that your are seeing.

There are no real "side-by-side" issues with regard to the .NET event log message file. However, if you for some reason decide to create you own (perhaps localized) event log message file you could either install two copies of this file with the two services or you could share a copy you then install to %CommonProgramFiles% . However, not doing a side-by-side installation with two copies can cause problems down the road if one version is updated independently of the other.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM