|
-
April 10th, 2006, 04:11 PM
#1
Compilation of different source files
Hi There,
I'm not 100% sure if this is in the correct forum... Apologies if it is not.
Basically, I have a class written in C# spread over 3 .cs files.
Is it possible for me to include these in a VC++ project and just create instances of the class as if were written in C++?
If so, please explain how! 
Thanks in advance.
Regards,
Big Winston
-
April 10th, 2006, 04:14 PM
#2
Re: Compilation of different source files
No, you cannot. But you can make a COM from your C# class and use it in the C++ project. See MSDN for details.
Har Har
-
April 10th, 2006, 04:15 PM
#3
Re: Compilation of different source files
No. It's not possible. It would be possible if you were using MC++ or C++/CLI and the C# class the CLS-compliant.
-
April 10th, 2006, 04:30 PM
#4
Re: Compilation of different source files
 Originally Posted by BigWinston
Basically, I have a class written in C# spread over 3 .cs files.
Let these classes be a part of a C# DLL project.
To instantiate and access them in regular and unmanaged C++ code, you need to register the assembly using regasm.
Like this -
Code:
regasm.exe YourCSharpDllName.dll
Now, instantiate the way one would instantiate any COM Class. So, if YourCSharpLibName.ClassName is the Prog Id as seen in the registry post successful assembly registration, then you would create an instance of this class inside an unmanaged C++ Client like this -
Code:
CComQIPtr <IInterfaceRegistered> spInterfacePtr;
if (SUCCEEDED (spInterfacePtr.CoCreateInstance (L"YourCSharpLibName.ClassName")))
spInterfacePtr->SomePublicMethod ();
For more information -
Last edited by Siddhartha; April 10th, 2006 at 04:33 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|