HELP: DllNotFoundException in .net application

G

Guest

Hi,

I'm writing a .net windows service that makes use of some C++ Dlls (written
by myself) - actually it calls some functions that are declared as exported
functions in the *.def file.

Now, when I start the service, I receive a DllNotFoundException saying that
my dll was not found - although it's in the same directory! Are there any
pitfalls concerning the use of C++ dlls in windows services?

(by the way: the functions are imported by 'Public Declare Function.... lib
"mydll.dll" etc. in the service).

Any ideas?

Thanks,

Andreas
 
G

Gary Chang[MSFT]

Hi Andreas,
Now, when I start the service, I receive a DllNotFoundException
saying that my dll was not found - although it's in the same directory.

The current directory for a Windows service is the system32 directory by
default. So if you use a relative path to specify your service DLLs, they
should be existed in the system32 directory.

However, if you do not want to install your personal DLLs to the system32
directory, I suggest you use the following .NET method to set your service'
the current directory to the same directory as your windows service:

System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseD
irectory);


Thanks!

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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