470,833 Members | 1,438 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

HELP: DllNotFoundException in .net application

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
Mar 31 '06 #1
1 1206
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.App Domain.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.

Apr 3 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Petr Makagon | last post: by
4 posts views Thread by Aaron Stubbendieck | last post: by
1 post views Thread by Jorge_Beteta | last post: by
9 posts views Thread by Ringo | last post: by
1 post views Thread by diegodsa | last post: by
1 post views Thread by Xycoth | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.