Calling unmanaged function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I've got a rather old DLL that compiles properly with the 'Multi byte
charset' option under VS2005. Now, I cannot call any functions of this dll
out of a VB .net application (would need 'Use Unicode' option for that..). As
I do not want to rewrite the whole application for unicode usage: Is there
any way to call functions out of this DLL in a .net 2.0 application?

Thanks,

Peter
 
Peter Schmitz said:
Hi,

I've got a rather old DLL that compiles properly with the 'Multi byte
charset' option under VS2005. Now, I cannot call any functions of this dll
out of a VB .net application (would need 'Use Unicode' option for that..).
As
I do not want to rewrite the whole application for unicode usage: Is there
any way to call functions out of this DLL in a .net 2.0 application?

What do you mean by "can't call" it? If you mean you need to marshal strings
into unicode to send them, that can be set with the CharSet field of the
DllImport attribute.
 
Thanks for replying! My declarations are similar to the following:

C++ DLL:
void TestFunc()
{
[...]
}

TestFunc is exported by *.def entry.

Now, I want to import this in my .net application:

Public Declare Sub TestFunc lib "mydll.dll" ()

When I call TestFunc in my .net application I receive a DllNotFound
exception. For testing purposes I created a DLL from scratch using VS2005
(the original DLL was converted from VS2003 -> MultiByte) and Unicode charset
- it works perfectly...

Any ideas?

Thanks,
Peter
 
Peter Schmitz said:
Thanks for replying! My declarations are similar to the following:

C++ DLL:
void TestFunc()
{
[...]
}

TestFunc is exported by *.def entry.

Now, I want to import this in my .net application:

Public Declare Sub TestFunc lib "mydll.dll" ()

When I call TestFunc in my .net application I receive a DllNotFound
exception. For testing purposes I created a DLL from scratch using VS2005
(the original DLL was converted from VS2003 -> MultiByte) and Unicode
charset
- it works perfectly...

Any ideas?

A DllNotFound exception? What was the error message?
 
Hi,

that's the error message (the calling .net application is a .net windows
service):

Service cannot be started. System.DllNotFoundException: Unable to load DLL
'mydll.dll': The specified module could not be found. (Exception from
HRESULT: 0x8007007E)

Again, if I call a DLL that was compiled/linked with the 'Use Unicode'
statement, everything works fine...although the function itselfs doesn't even
use strings...

-Andreas


Daniel O'Connell said:
Peter Schmitz said:
Thanks for replying! My declarations are similar to the following:

C++ DLL:
void TestFunc()
{
[...]
}

TestFunc is exported by *.def entry.

Now, I want to import this in my .net application:

Public Declare Sub TestFunc lib "mydll.dll" ()

When I call TestFunc in my .net application I receive a DllNotFound
exception. For testing purposes I created a DLL from scratch using VS2005
(the original DLL was converted from VS2003 -> MultiByte) and Unicode
charset
- it works perfectly...

Any ideas?

A DllNotFound exception? What was the error message?
 
Back
Top