3

I'm trying to create an Event Log and Event Source at install time using Wix. The install doesn't fail or give any error...but I don't see any Event Log called MyApp getting created.

      <PropertyRef Id="NETFRAMEWORK40FULLINSTALLROOTDIR"/>


      <Component Id="EventLog" Guid="AD09F8B9-80A0-46E6-9E36-9618E2023D67">
        <util:EventSource Log="MyApp" Name="MyApp" EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR]EventLogMessages.dll" />
      </Component>

I previously had a .NET Installer class that did this and it worked without a problem.

What am I doing wrong?

1
  • I think you have an issue. This will work for a 32 bit OS - not a 64 bit OS. I think you should use NETFRAMEWORK40FULLINSTALLROOTDIR64 for 64 bit. Don't you think? Commented Mar 1, 2012 at 8:25

2 Answers 2

2

I had problems with this, and it was because I was missing a <CreateFolder /> element; my code ended up looking like this:

<Component Id="CreateEventLog32Bit" Guid="{some-guid}" Permanent="yes">
    <Condition><![CDATA[NETFRAMEWORK40FULLINSTALLROOTDIR AND NOT VersionNT64]]></Condition>
    <CreateFolder />
    <util:EventSource Log="Application" Name="MyApp" EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR]EventLogMessages.dll" />
</Component>
<Component Id="CreateEventLog64Bit" Guid="{some-other-guid}" Permanent="yes">
    <Condition><![CDATA[NETFRAMEWORK40FULLINSTALLROOTDIR64  AND VersionNT64]]></Condition>
    <CreateFolder />
    <util:EventSource Log="Application" Name="MyApp" EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR64]EventLogMessages.dll" />
</Component>

(so it can handle both 32-bit and 64-bit installs of .NET 4)

Sign up to request clarification or add additional context in comments.

Comments

0

Can you post an installer log? The EventSource element is really just some syntatical sugar. WiX translates these into simple registry keys/values and I've never seen it fail in any of the installs I've used it in.

8 Comments

It looks like the log file doesn't show up until the first event is written to it. As in, my code doesn't fail writing to it and the event source exists in the registry...but it doesn't show up in the Event Viewer UI....does that make any sense?
I've never heard of that. I'd make sure your application doesn't have any code in it that's initializing the log. I've seen developers doing this assuming that will run with elevated permissions. The logfile I spoke of was the Windows Installer log of running the install.
WriteRegistryValues: Key: \SYSTEM\CurrentControlSet\Services\EventLog\AppCo\App, Name: EventMessageFile, Value: #%C:\Windows\Microsoft.NET\Framework\v4.0.30319\EventLogMessages.dll
Looking at the code that used to do the job, I don't see anything about that dll in the registry...it has a absolute file path to an evt file listed in the registry...
It's hard to give more advise without seeing the actual dll's and installs. The eventlogs that .NET developers have asked me to create worked fine using the .NET bcl dll's provided for category and eventmessage arguments. You may have done something more advanced in your code that requires more specific arguments.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.