473,786 Members | 2,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export / Import C++ Managed Classes

Hello,

I am writing some C++ classes and want to export them as .dll files so
other users can import them and use the methods I have provided in
those classes. I have two types of classes : unmanaged (or regular
classes) and managed (__gc classes). I already know how to use
"__declspec(dll export)" to export and "__declspec(dll import)" to import
"unmanaged" classes. However I dont know how to export "managed"
classes since this method doesnt work for them.

Can anyone help me with this ?

Regards,
Amir

May 26 '06 #1
3 6146
Hi amirbehzadan!
I am writing some C++ classes and want to export them as .dll files so
other users can import them and use the methods I have provided in
those classes. I have two types of classes : unmanaged (or regular
classes) and managed (__gc classes). I already know how to use
"__declspec(dll export)" to export and "__declspec(dll import)" to import
"unmanaged" classes. However I dont know how to export "managed"
classes since this method doesnt work for them.


Just declare it as "public" and put it into a namespace. That´s it.

Any other managed programming language can simply reference the DLL and
use your class.

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
May 26 '06 #2
Hi Jochen,

Thanks a lot. That solved the problem of creating the DLL file. Now
when I am using the corresponding header and library file in a test
application to use that DLL file, I get a number of "unresolved tokens"
that most of them point to the functions inside the imported managed
class. Examples are :

Test error LNK2020: unresolved token (0600000B) TCM::.ctor
Test error LNK2020: unresolved token (0600000C) TCM::Finalize
Test error LNK2020: unresolved token (0600000E) TCM::Start
Test error LNK2020: unresolved token (0600000F) TCM::Stop
Test error LNK2020: unresolved token (06000010) TCM::BytesInRQ
Test error LNK2020: unresolved token (06000011) TCM::stdString
Test fatal error LNK1120: 6 unresolved externals

the last four functions are functions inside the imported managed class
TCM.

Thanks,
Amir

May 26 '06 #3
Hi amirbehzadan!
Thanks a lot. That solved the problem of creating the DLL file. Now
when I am using the corresponding header and library file in a test
application to use that DLL file, I get a number of "unresolved tokens"


You *must not* use header and lib-files!!!

Just add (VC2003):
#using <MyManagedDll.d ll>
Or in VS2005, add the reference to your project properties
(Common|Referen ces).
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
May 27 '06 #4

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

Similar topics

0
3163
by: Dave Irick | last post by:
We are looking for assistance in setting up export/import jobs that will use DLT tapes managed by Netbackup. The issue seems to be how to specify the "file" parameter of export/import so that it is written by bpbackup or read by bprestore. We are transitioning to Veritas from an older and very different tape management system. If anyone has excerpts of export/import scripts that they may share that show how to do this it would be greatly...
8
20378
by: An Ony | last post by:
Hello, I'm trying to write a program (dll) to use with mIRC. mIRC wants me to use these kind of functions: int __stdcall procname(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause) translated into C# code, I think it's this:
0
1176
by: Rob Burke | last post by:
I'm trying to create a hybrid Managed/unmanaged C++ DLL that uses ATL and wraps some of DirectShow. When I add a reference to that Managed C++ DLL in another managed project, I end up "polluting" my namespaces will all sorts of unmanaged stuff I didn't want the DLL to export. For instance, there is an ATL namespace that contains things like CComPtr<IBaseFilter>. And in the root namespace, I am exporting things like _AMMediaType and...
2
3999
by: Siu | last post by:
Hi, I use the following code to export and import a file Excel from resp. into a Web page with the following code: //EXPORT Response.Clear(); Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; Response.Charset = ""; this.EnableViewState = false;
3
4014
by: Iavor Raytchev | last post by:
Hello, We a situation with a central database that contains the data that needs to be presented at N off-line terminals (N can be 5 000 can be 15 000). Each terminal presents unique data. The central database is used for data preparation. Then the data for each terminal is exported as separate SQL file. The terminals run the same application that is used to prepare the data - only in user mode. So what we do is - we export the full database...
2
2319
by: amirbehzadan | last post by:
Hello, I am writing some C++ classes and want to export them as .dll files so other users can import them and use the methods I have provided in those classes. I have two types of classes : unmanaged (or regular classes) and managed (__gc classes). I already know how to use "__declspec(dllexport)" to export and "__declspec(dllimport" to import "unmanaged" classes>. However I dont know how to export "managed" classes since this method...
17
7257
by: Fabry | last post by:
Hi All, I'm new of this group and I do not know if this is the correct group for my question. I have a DLL with its export library (.lib) wrote in Borland C++ 6. In borland everything is OK and I am able to include the lib and use the class that i have exported creating an instance with new etc... I would like to export this class in microsoft VC++ using the same .lib file. Obviously it doesn' t work.
2
17011
by: mike_dba | last post by:
I am attempting to move data between 2 DB2 Linux databases using a pipe. I can't seem to get it working. Any assistance is appreciated. I first issue: mkfifo -m777 mypipe db2 "connect to src_db" db2 "export to mypipe of DEL MODIFIED BY COLDEL, MESSAGES exp.msg select * from myschema.old_table"
3
7163
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this file but save it as an excel file. The data in this excel file will be imported into an Access database. The
0
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6749
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
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 we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.