views:

131

answers:

3

I have created a windows service in C# VS2008 that uses a reference to an external class library to wrote. I have added the reference to it in VS2008. When I run start the service it throws an exception when trying to access the external DLL:

Could not load file or assembly 'vcribAPI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

The DLL is in the same directory as the service.exe file. Is there something special that I need to do for windows services like putting the DLL in another directory?

A: 

Does the assembly have other dlls or assemblies it depends on?

If so, they also need to be in this directory.

To be certain, start up the Assembly Loader Log (fusion log). See this howto (Debugging Assembly Loading Failures).

Oded
nope. It doesn't rely on any other assemblies.
Brian
@Brian - updated answer.
Oded
+1  A: 

It could be that vcribAPI.dll relies on other assemblies as well. I suggest using Reflector and open up the dll to see what other dll's it might reference.

Peter Lillevold
I wrote vcribAPI so i know it doesn't rely on any other assemblies.
Brian
@Brian: ok, then yes, you should go with @nobugz comment: use fuslogvw.exe (http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx) to review the assembly binding log for clues.
Peter Lillevold
A: 

Does you service have rights to read in the folder?

Petoj
It is the .Net runtime that loads the dll. If it can start the service exe, it will also be able to load dlls from that same folder.
Peter Lillevold