I have an outlook add-in developed with VSTO 2010 that I want to write some event logging. While debugging I can get this to work by simply doing the following:
if (!EventLog.SourceExists(ADDIN_FRIENDLY_NAME))
{
EventLog.CreateEventSource(ADDIN_FRIENDLY_NAME, null);
}
EventLog.WriteEntry(ADDIN_FRIENDLY_NAME, message, EventLogEntryType.Warning);
The problem is the release version the add-in doesn't have admin rights to read the log. I found some articles that talked about creating the EventLog source during installation, but I'm using ClickOnce and it doesn't seem there is a way to do that. Also, someone talked about creating a separate DLL and then call InstallUtil
on that DLL to create the source. This doesn't work for me either since this still requires admin rights.
Is it possible to have the add-in run using Outlook's security level? I see Outlook's messages in the event log so it must have enough rights to do so.
You can try to run click once as administrator using the solution proposed in this article but I don't think it's a good solution.
Maybe a better solution is to include in your click once package a standard .msi setup that you can execute the first time you install your addin. This msi just create the event source.
About your question:
Is it possible to have the add-in run using Outlook's security level?
I don't think that your add-in run using a different security level but probably you have UAC enabled so you cannot execute admin operations also if you are an administrator.