473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Subject: Using a dotNET Class in C++

I have to write a dll that can be used by a legacy app. The legacy app looks
for a set of specific exported functions, with mangled names (in the form
_MyMangledFunction@nn). I really don't want (or need, or am able without
spending a lot of time) to write the whole thing in C.

It is my intention to provide the appropriate exports from a (MFC, or just
win32) C++ wrapper dll and from there pass everything straight through to
equivalent functions in a managed class in a managed DLL (VB or C#) which
will handle the logic.

1. I have written a test host app to emulate the legacy app that can call
_MyMangledGetNumber@0() in TestMFCDLL.dll
2. I have written a TestMFCDLL.dll in C++ (mix managed/unmanaged) that
exports MyMangledGetNumber() and returns a number to the test app.
3. I have written a TestVBDLL.dll class library defining a class called
MyManagedClass with a method GetNumber() that contains the logic I need.

The flow is this:
in host app (somewhere)
myIntegerVar = _MyMangledGetNumber@0() //from TestMFCDLL.dll

in TestMFCDLL.dll:
DWORD WINAPI MyMangledGetNumber()
{ //HOW DO I create an instance of TestVBDLL.MyManagedClass
//call to MyManagedClass.GetNumber() where logic resides
return MyManagedClass.GetNumber();
}

What I don't know how to do is the commented elements above. (The actual
scenario is - obviously - more complex than this, but this example
illustrates the essence of the problem). I am able to mix managed and
unmanaged code in TestMFCDLL.dll (safely), and am aware about ensuring it is
/NOENTRY etc.

Is this even a reasonable approach? Or can I create an appropriate .dll in
any dotnet language and export suitably mangled names some other way? I'm
looking, I suppose for both the quick, syntactic solution and broader views.

Nov 17 '05 #1
0 681

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

Similar topics

5
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access...
2
by: David | last post by:
Is there any known defects with respect to Databinding to a ComboBox that is located on a UserForm? I have a scenario on one of my forms that I have spent HOURS trying to solve that has...
2
by: nate axtell | last post by:
Using VB.NET 2003 in Visual Studio... I have created a base Form class ProjectA.FormA, that I inherit in another class called ProjectB.FormB. FormA is declared as MustInherit. When I try to view...
15
by: Sandy | last post by:
My background is web based. I am attempting to write a Windows application and I am finding some simple things difficult. Currently I am trying to find out how to store information session wide....
2
by: Tugrul HELVACI | last post by:
I'm using Delphi 2006 and I have a class defination like this: TPerson = class fPersonName : String; fPersonSurName : String; fPersonAge : Integer; published property PersonName : String...
17
by: Sven Rutten | last post by:
Hello Actually I want to add some C#-Code to a VB.NET-Project in VS 2005. Normally I creating a DLL and importing that from the VB-Project. But as I am coding something for a Smart Device...
1
by: Filip Fransen | last post by:
Hi, I have a to create a com object from a dotnet class. Now I have the following questions : - with Queryinterface you can get all the interfaces from a com app. How can I expose my dotnet...
3
by: maboo59 | last post by:
Hello, I need to call a function from a java class(Example.java, not Javascript) from within .Net 2.0 and I don't know how to do it. Does anyone hava any suggestions? Thanks
4
by: Mike Peretz | last post by:
I am wondering if anyone out there is trying to use friend with C#, simular to the way C++ handles it. I wrote a blog about it and I wonder if someone can give me some feedback. ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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
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,...

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.