title: Get name of Event Source set up in WiX installer, in C#
body: <p>I need to do some custom writing to the Event Log from a C# application. Because I won't have administrator permissions at run-time, I'm creating the event source in the WiX installer, as so:</p>
  
  <pre><code>&lt;u:EventSource Name="SourceName" Log="Application" EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR]EventLogMessages.dll" /&gt;
  </code></pre>
  
  <p>and then writing by:</p>
  
  <pre><code> EventLog.WriteEntry("SourceName", message, EventLogEntryType.Error);
  </code></pre>
  
  <p>The issue here, is that <code>SourceName</code> must be kept in sync between my installer, and C# codebase - it previously has got out of sync. </p>
  
  <p>I'm currently using the main file's name to link the two, as below:</p>
  
  <pre><code>&lt;?define MainExe="MyMain.exe" ?&gt;
  &lt;u:EventSource Name="$(var.MainExe)" Log="Application" EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR]EventLogMessages.dll" /&gt;
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>var name = Application.ResourceAssembly.ManifestModule.Name;
  EventLog.WriteEntry(name, message, EventLogEntryType.Error);
  </code></pre>
  
  <p>But this feels very hacky. Is there a proper to dynamically get the name of an event source set up in a WiX installer, or do I just have to bodge the best I can?</p>