I have created a Windows Service that (along with other database related processes) converts files to XOD format. All of the code run by the service exists in a separate class library which I call my "engine". During development I test the engine by running its code from a WPF application that mimics what happens when my service runs. So I know that all is working fine in regards to converting to XOD. However when I go to start my Windows service (either locally on my development machine or on my server) I get the following error:
Application: BTT.DocsOnTap.UserDbService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
at System.Reflection.RuntimeAssembly._nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
at System.Reflection.RuntimeAssembly.nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(System.String, System.Security.Policy.Evidence, Byte[], System.Configuration.Assemblies.AssemblyHashAlgorithm, Boolean, Boolean, System.Threading.StackCrawlMark ByRef)
at System.Reflection.Assembly.LoadFrom(System.String)
at pdftron.PDFNetLoader.PDFNetResolveEventHandler(System.Object, System.ResolveEventArgs)
at System.AppDomain.OnAssemblyResolveEvent(System.Reflection.RuntimeAssembly, System.String)
Exception Info: System.IO.FileNotFoundException
at BTT.DocsOnTap.UserDbService.UserDbService..ctor()
at BTT.DocsOnTap.UserDbService.Program.Main()
My service constructor looks like this:
public partial class UserDbService : ServiceBase
{
......
private static PDFNetLoader _loader = PDFNetLoader.Instance(); ******
public UserDbService()
{
pdftron.PDFNet.Initialize(); ******
InitializeComponent();
CanStop = true;
_log.Info("Service initialized");
}
......
}
If I remove the 2 lines marked with astrisks then my service starts OK. In my WPF application all works OK with the calls to the Loader and Initialize (I have these 2 lines in my MainWindow.xaml.cs).
Can you suggest what I need to do to get things to work with the Loader and Initialize calls in my Windows Service (I've also included a screen shot of my bin/Debug directory for the service.
Thanks,
David