PC Review


Reply
Thread Tools Rate Thread

Calling unmanaged function

 
 
=?Utf-8?B?UGV0ZXIgU2NobWl0eg==?=
Guest
Posts: n/a
 
      31st Mar 2006
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
 
Reply With Quote
 
 
 
 
Daniel O'Connell [C# MVP]
Guest
Posts: n/a
 
      1st Apr 2006

"Peter Schmitz" <(E-Mail Removed)> wrote in message
news:5C017269-70FE-4331-A3A4-(E-Mail Removed)...
> 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,
>
> Peter



 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgU2NobWl0eg==?=
Guest
Posts: n/a
 
      1st Apr 2006
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





"Daniel O'Connell [C# MVP]" wrote:

>
> "Peter Schmitz" <(E-Mail Removed)> wrote in message
> news:5C017269-70FE-4331-A3A4-(E-Mail Removed)...
> > 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,
> >
> > Peter

>
>
>

 
Reply With Quote
 
Daniel O'Connell [C# MVP]
Guest
Posts: n/a
 
      1st Apr 2006

"Peter Schmitz" <(E-Mail Removed)> wrote in message
news:08744B19-94D8-404F-9D1F-(E-Mail Removed)...
> 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?


 
Reply With Quote
 
=?Utf-8?B?QW5kcmVhcw==?=
Guest
Posts: n/a
 
      1st Apr 2006
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 [C# MVP]" wrote:

>
> "Peter Schmitz" <(E-Mail Removed)> wrote in message
> news:08744B19-94D8-404F-9D1F-(E-Mail Removed)...
> > 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?
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling unmanaged function pointer Markus Eßmayr Microsoft VC .NET 0 11th Jan 2008 03:14 PM
Calling an unmanaged C dll function -- Urgent =?Utf-8?B?TWVsaWggU0FSSUNB?= Microsoft VB .NET 1 3rd May 2006 11:16 AM
Can function calling conventions be changed in unmanaged C# apm Microsoft C# .NET 4 16th Sep 2005 09:29 PM
Calling managed function from unmanaged function in mixed mode dll slugster@gmail.com Microsoft VC .NET 1 25th Jul 2005 07:30 AM
Problem with calling unmanaged function from VC++ darkhonor Microsoft VC .NET 2 27th Apr 2004 10:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:41 PM.