473,486 Members | 2,353 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Calling unmanaged function

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
Mar 31 '06 #1
4 1749

"Peter Schmitz" <Pe**********@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
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

Mar 31 '06 #2
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" <Pe**********@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
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


Apr 1 '06 #3

"Peter Schmitz" <Pe**********@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
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?
Apr 1 '06 #4
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" <Pe**********@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
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?

Apr 1 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2409
by: jarmopy | last post by:
Hi, I have made a service with C# and calling that service class from another C# program with remoting. (Referendes from the calling program) That service class is configured so that garpage...
15
11725
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
1
7141
by: Adam Clauss | last post by:
I have an unmanaged C++ library that I need to use through C#. I created a Managed C++ class library and through it wrote a wrapper class to call what I need. However, one of the methods (an...
1
2880
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
17
2174
by: Bill Grigg | last post by:
I have been successfully calling DLL's using VC++ 6.0 and also using VC++7.1 (.NET). I only mention this because I have never felt comfortable with the process, but nonetheless it did work....
1
1463
by: slugster | last post by:
Hi, i originally posted this via another portal, but after giving it time to propagate it still hasn't shown up. My apologies for the multiposting. This might be a very simple question, but i...
1
2577
by: H.B. | last post by:
Hi, I need to make a function that can display data on my Managed C++ app and be called by an unmanaged C++ DLL. Something like : void Form1::Form1_Load(System::Object * sender,...
1
3031
by: Leftie | last post by:
Folks, I'm trying to call an unmanaged function from VB.NET and keep getting "Object reference not set to an instance of an object" error. The code that i wrote can be found at:...
3
4682
by: Klaus | last post by:
Hi, I have an existing VC 6 MFC application which communicates asynchronly with a VC 2005 managed code dll. I use an unmanaged base class with virtual functions to access methods in the MFC...
0
2509
by: Markus Eßmayr | last post by:
Hello! I'm writing a .NET component that forwards calls to it's functions on to an unmanaged DLL. This DLL is loaded dynamically using LoadLibrary and the function pointers are retrieved using...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.