Wisej.HostService.exe crashes when run as command inside Windows Service

Answered
0
0

Hi – We’re new to Wisej and really enjoying it – thanks!

We know that Wisej.HostService.exe can be configured to run as a Windows Service, but we’d rather take a different approach:

Our software already includes a Windows Service that manages various “tasks”. When the Service is started or stopped, it in turn starts or stops the various tasks. We added a task that on start simply runs [MyPath\Wisej.HostService.exe -start -d:* -p:8080], and that on stop simply runs [MyPath\Wisej.HostService.exe -stop].

If we start the Service as an app (which is an option), all runs fine – the app can successfully start and stop the Wisej task and Wisej.HostService.exe.

But if we start the Service as a Windows Service (using the same credentials as the app), Wisej.HostService.exe crashes. The stack trace indicates that Wisej.Framework.dll can’t be found, but it is located in the \bin folder.

Event Viewer shows the following stack trace:

The description for Event ID 1325 from source ASP.NET 4.0.30319.0 cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event:

An unhandled exception occurred and the process was terminated.

Application ID: Wisej.HostService.exe

Process ID: 8256

Exception: System.Reflection.TargetInvocationException

Message: Exception has been thrown by the target of an invocation.

StackTrace:
Server stack trace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at Microsoft.Owin.Builder.AppBuilder.BuildInternal(Type signature)
at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder)
at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
at Wisej.HostService.Owin.WisejHost.Start(String domain, Int32 port)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Wisej.HostService.Owin.WisejHost.Start(String domain, Int32 port)
at Wisej.HostService.Service.Service.Start()
at Wisej.HostService.Program.StartProcess(String[] args)
at Wisej.HostService.Program.Main(String[] args)

InnerException: System.IO.FileNotFoundException

Message: Could not load file or assembly ‘Wisej.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=17bef35e11b84171’ or one of its dependencies. The system cannot find the file specified.

StackTrace: at Wisej.HostService.Owin.WisejMiddleware..ctor(OwinMiddleware next)
at lambda_method(Closure , OwinMiddleware )

  • You must to post comments
Good Answer
0
0

Paul – thanks for the prompt response.

We tried configuring our program to run a command file, MyApp.Start.cmd, which in turn ran Wisej.HostService.exe:

C:
cd “C:\MyAppRoot”
.\Wisej.HostService.exe -start -p:8080 -d:*

…when the program was run as an app, everything worked as expected. But when the program was run as a service, Wisej.HostService.exe terminated unexpectedly with the error cited in my original post.

We also tried setting the current directory programmatically:

System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);

…but that resulted in the same error.

Ultimately we stumbled upon what may be a solution. Placing copies of Wisej.Framework.dll in both (not one or the other) the application root and \bin folders appears to make everything work as expected. This solution is not perfect (nor is it fully explainable to us) but we’re hoping it will suffice.

Best,

Mike

  • You must to post comments
0
0

Hi Michael

Reviewing your log, this indicate that cannot find the assembly. That’s not a crash. It’s probably because the process starts in the wrong directory when started by a service. It’s not a wisej issue.

Regards

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.