• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 637
  • Last Modified:

VB.NET app calling C++ dll, DLLNotFoundException

I have here C++ dlls that has been compiled as a 32bit dll.
It is called by .NET windows service, compiled as 32bit as well.
Provided below is a sample code to to use the methods of the C++dll

<DllImport("mytest.dll") , entrypoint:="mytestmethod1")>
public shared function mytestmethod1() as string
end function

This works in 32 bit.

My problem is this  - to make same code run in 64bit.
The C++ dll and the .NET windows service are now compiled as 64bit.
When i start to run the .NET windows service, I get an error as soon as I hit a code calling the C++ method -  a DllNotFoundException exception. so nonetheless, i added try catch statements for DllNotFoundException.

Im still getting this error but Im dead sure i have the c++ dll in the .NET windows service bin directory.

please help.
  • 2
  • 2
1 Solution
AndyAinscowFreelance programmer / ConsultantCommented:
Give the 64 bit version a different name to the 32 bit version - modify your Dllimport code - does it still fail with the dllnotfoundexception?
jermineMAuthor Commented:
Recompiled the C++ to create using a new dll name. Copied the dll into the VB.NET bin folder.
Replaced the DLL name used  in the wrapper.
Still encountering DllNotFoundException.

any other ideas?

AndyAinscowFreelance programmer / ConsultantCommented:
Nope - it was a long shot.
jermineMAuthor Commented:
thanks for the suggestion though :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now