"The specified module could not be found" problem

G

Guest

I have built a .NET based service that uses a number of related 3rd party dlls.

If I compile my code into a dll and use this in a test app all is well -
however if I compile my code as a service and try to run the service I get
the following exception:
System.IO.FileNotFoundException: The specified module could not be found.
at CES.VendClientInt.VendClient.GetCardTypes(...)
at YQ_Epos_server.CodeHandler.start(...)

I have tried copying the appropriate dlls to c:\windows\system32 and to the
application directory but to no avail. How can I go about resolving this
issue - bear in mind I am relatively new to .NET development.
 
S

Sijin Joseph

You will need to install the required DLL's in the Global Assembly
Cache(GAC), use gacutil -i <dllname> to install the assembly in the GAC from
where your service app will be able to access it.
 
G

Guest

The documentation seems to indicate that this should not be used other than
for development purposes, I would like to get this running from the install
scripts.

Also when I do try to run this I get:
"Failure adding assembly to the cache: An attempt was made to load a
program with an incorrect format"
for the ActiveX dll (this has been registered previously using regssrv32.exe)
or
"Failure adding assembly to the cache: Attempt to install an assembly
without a strong name"
for the .NET wrapper dll and the .NET assembly dll.
 
J

José Joye

By the way, you can redefine the working directory for a Service.
Personnaly, in the OnStart method, I redefine it so as to be the directory
where the Main exe file is located:

protected override void OnStart(string[] args)
{
try
{
// Define working directory (For a service, this is set to System)
Process pc = Process.GetCurrentProcess();
Directory.SetCurrentDirectory
(pc.MainModule.FileName.Substring(0,pc.MainModule.FileName.LastIndexOf(@"\")
));
....

José
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top