Note that there are some explanatory texts on larger screens.

plurals
  1. POWill this code create an EventLog at installation time?
    text
    copied!<p>Following the <a href="https://stackoverflow.com/questions/3176337/any-reason-id-get-a-nullreference-exception-on-windows-7-only/3176366#3176366">advice of Henk</a>, I've created a Setup Project in VS10 with the aim of adding a custom action. This custom action will hopefully add an EventLog whilst running as admin (ie during installation) rather than having my app throw an exception on OSes with UAC.</p> <p>Unfortunately, I don't ordinarily have access to an OS that uses UAC. The next time I do, I hope the installation will go smoothly.</p> <p>With that in mind, is there anything in the below code which is obviously wrong?</p> <pre><code>using System; using System.Diagnostics; namespace EventLogCreator { class Program { static void Main(string[] args) { switch (args[0]) { case "-i": if (!EventLog.Exists("SSD Log")) { Console.WriteLine("Log not found, creating."); EventLog.CreateEventSource("setup", "SSD Log"); } break; case "-u": if (EventLog.Exists("SSD Log")) { Console.WriteLine("Log found, removing."); EventLog.Delete("SSD Log"); } break; } } } } </code></pre> <p>The output of this project is sucked into the setup project. I then have two custom actions:</p> <ol> <li>On install with "-i" as an argument</li> <li>On uninstall with "-u" as an argument</li> </ol> <p>I'm not expecting a free code review, but I'm venturing into the unknown here, so I'd appreciate a heads up if I'm humping the wrong bit of trash.</p> <p><em>PS I'm particularly concerned that I'm specifying the actual log name, but not an actual source. Will this matter?</em> </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload