I have an old C DLL that I want to access via C#.
I'm doing this via an outer DLL that wraps the old C DLL in an unmanaged
C++ class, which is in turn wrapped in a Managed C++ class. Both these
unmanaged C++ and managed C++ classes are compiled into a single assembly
(DLL) that is accessed by C#.
[C DLL] <--> [Unmanaged C++ / Managed C++] <--> [C# app]
old dll new C++ assembly app
I don't want to use standard Interop methods. I'm trying to do all the
direct access to the old C DLL with unmanaged C++. The data types in the
old C DLL are relatively complex, so I'm encapsulating the cluttered
legacy stuff in the new unmanaged C++ class.
IOW, I'll usually only be passing ints and a couple strings between the
unmanaged and managed sides.
In general, this approach works, but I'm getting occasional runtime errors
that I can't explain. Could someone post or refer me to a very simple
example that does this with even a single function? Say, take a function
from a stock Windows DLL and show a correct unmanaged C++ class
and managed C++ class that will wrap it correctly.
Thanks for any insights you can provide. 3 1980
On Sun, 09 Jan 2005 21:52:43 -0500, _BNC <_B**@nospam.com> wrote: I have an old C DLL that I want to access via C#.
I'm doing this via an outer DLL that wraps the old C DLL in an unmanaged C++ class, which is in turn wrapped in a Managed C++ class. Both these unmanaged C++ and managed C++ classes are compiled into a single assembly (DLL) that is accessed by C#.
[C DLL] <--> [Unmanaged C++ / Managed C++] <--> [C# app] old dll new C++ assembly app
I don't want to use standard Interop methods. I'm trying to do all the
^^^^^^^^^^
Oops... I meant I don't want to use PInvoke. I'm using the flat 'IJW'
model.
direct access to the old C DLL with unmanaged C++. The data types in the old C DLL are relatively complex, so I'm encapsulating the cluttered legacy stuff in the new unmanaged C++ class.
IOW, I'll usually only be passing ints and a couple strings between the unmanaged and managed sides.
In general, this approach works, but I'm getting occasional runtime errors that I can't explain. Could someone post or refer me to a very simple example that does this with even a single function? Say, take a function from a stock Windows DLL and show a correct unmanaged C++ class and managed C++ class that will wrap it correctly.
Thanks for any insights you can provide.
_BNC wrote: I have an old C DLL that I want to access via C#.
[C DLL] <--> [Unmanaged C++ / Managed C++] <--> [C# app] old dll new C++ assembly app
In general, this approach works, but I'm getting occasional runtime errors that I can't explain.
You may be running into the dreaded Mixed DLL Loading problem: http://msdn.microsoft.com/library/de...ingProblem.asp
See if this helps. If not, try giving a minimal code example that causes
the error, or explaining some more detail of your setup.
--
Derrick Coetzee, Microsoft Speech Server developer
This posting is provided "AS IS" with no warranties, and confers no
rights. Use of included code samples are subject to the terms
specified at http://www.microsoft.com/info/cpyright.htm
I'm getting some errors in an app that makes use of a mixed-mode DLL
for transitioning between .NET and an old native C DLL:
[C DLL] <--> [Unmanaged C++ / Managed C++] <--> [C# app]
I believe I got my initial info from an older Wrox book, so the problems
may have stemmed from there.
Is there a good source of info or examples of mixed Unmanaged/Managed
DLL's? Books, pointers to MSDN articles? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bob Rock |
last post by:
Hello,
in the last few days I've made my first few attempts at creating mixed C++
managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is
visible in those assemblies from a...
|
by: Chris Kiechel |
last post by:
I am writing a .NET Windows application and it needs to
perform DDE calls to a legacy system. I created a C++
unmanaged class that performs the actual DDE connection
and communication. However,...
|
by: Rachel Suddeth |
last post by:
What is the difference between a managed/unmanaged resource, and how do you
tell which is which? I'm trying to understand how to write some Dispose()
methods, and we are supposed to put code that...
|
by: knormand |
last post by:
I have an older MFC C++ app with some new Managed C++ being thrown in. Recently I turned on the /clr flag for one of my old .cpp files. I then placed '#pragma unmanaged' just below my #include...
|
by: Bob Rock |
last post by:
Hello,
in the last few days I've made my first few attempts at creating mixed
C++ managed-unmanaged assemblies and looking afterwards with ILDASM
at what is visible in those assemblies from a...
|
by: zhphust |
last post by:
I want to convert a object of a managed class to a unmanaged structure
that has the same member with that managed class. Can anybody tell me
how i can do it?
Thanks in advance.
--
zhphust...
|
by: Sparhawk |
last post by:
Hi,
my company is going to migrate a large VC++ application to .NET to
make use of Windows Forms (the old class library is not updated any
more). We are not planning to migrate the rest of the...
|
by: =?Utf-8?B?Y2hyaXNiZW4=?= |
last post by:
Hi,
I have some C++ static library which I would like to wrap and use in C#
applications. It appears that I have two options.
1. Wrap the static library as dynamic library (dll), use unmanaged...
|
by: Jon Slaughter |
last post by:
How difficult is it for one to integrate unmanaged C++ into C#? I know for
functions one can use DLLimport but how does one go about doing it for
classes? Do I have to completely reimplement the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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...
|
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,...
| |