Service Being Killed By Unhandled SecurityException

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
bradleyward
Sr. Member
Sr. Member
Posts: 11
Joined: 25 Nov 2013, 21:38

Service Being Killed By Unhandled SecurityException

Post by bradleyward »

I am incorporating client OPC UA code based on the SDK into a Windows Service, and when I start the service it is getting killed by an unhancled SecurityException (see stack trace below). The stack trace does not include any of my code, and only one frame in the stack trace is in Unified Automation code: in UnifiedAutomation.UaBase.ApplicationInstance+WindowsService.OnBackgroundStart(System.Object)

From the stack trace it appears that the Unified Automation code expects there to be an already defined Event Source in the Windows Event Log. But I do not know what that Event Source needs to be named.

I am NOT using the "/install" arguments that I see referenced in a few places in the Unified Automation SDK documentation. I don't use it for several reasons, mainly that (a) I don't know what it does and (b) I have other complex installation needs and cannot cede control over this critical part of the application over to a 3rd party SDK.

If the "/install" argument processing does something magic that I need to take care of myself, then I need some documentation on what that might be.

Please help!

Thanks!


Application: TestOPCService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Security.SecurityException
Stack:
at System.Diagnostics.EventLog.FindSourceRegistration(System.String, System.String, Boolean, Boolean)
at System.Diagnostics.EventLog.SourceExists(System.String, System.String, Boolean)
at System.Diagnostics.EventLogInternal.VerifyAndCreateSource(System.String, System.String)
at System.Diagnostics.EventLogInternal.WriteEntry(System.String, System.Diagnostics.EventLogEntryType, Int32, Int16, Byte[])
at System.Diagnostics.EventLog.WriteEntry(System.String, System.Diagnostics.EventLogEntryType)
at UnifiedAutomation.UaBase.ApplicationInstance+WindowsService.OnBackgroundStart(System.Object)
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart(System.Object)

bradleyward
Sr. Member
Sr. Member
Posts: 11
Joined: 25 Nov 2013, 21:38

Re: Service Being Killed By Unhandled SecurityException

Post by bradleyward »

I found this page about doing a service install, but it does not mention anything about any interaction with the Windows Event Log... :(

http://documentation.unified-automation ... ocess.html

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Service Being Killed By Unhandled SecurityException

Post by Support Team »

Hi Bradley,

When you start the Service using the service support built into the ApplicationInstance class you need permission to write to the event log.

If you would rather manage all of the service code yourself you should disable this feature by setting NoAutoStartService=true on the ApplicationInstance.
Since you mentioned that you need to control everything on your own we assume you want to deactivate the option that the SDK handles the service functionality.

The /install option is described here:
http://documentation.unified-automation ... ocess.html
For the client it creates the certificate store and the application instance certificate.

Best Regards,
Unified Automation Support Team

Post Reply