Thank you very much.
Ricardo Vazquez.
If all you have is the .NET .dll (and not access to the project source
code), then you're out of luck.
-Scott
"Ricardo V�zquez" <rvaz...@dummy.es> wrote in message
news:%23F8IKrs...@TK2MSFTNGP04.phx.gbl...
> I need to use a .NET DLL I've written in C#, within a VC++ 6.0/MFC
> project.
> Googling I find plenty of topics related with using a VC++ DLL in a .NET
> project...
Ok,...
> But I need exactly the other way round: a .NET DLL in a VC++ project.
> Is this possible?
Yes it is and there is very good support on that! You have to expose the
managed .net library via COM to your operating system and other applications
that want to use your managed library. Here are several good examples and
explantations/backgrounders on that topic:
[NET Framework Developer's Guide
Exposing .NET Framework Components to COM]
http://msdn.microsoft.com/en-us/library/zsfww439(VS.71).aspx
[How to call a managed DLL from native Visual
C++ code in Visual Studio.NET or in Visual Studio
2005]
http://support.microsoft.com/kb/828736/en-us
[Understanding Classic COM Interoperability
With .NET Applications]
http://www.codeproject.com/KB/COM/cominterop.aspx
[Building COM Servers in .NET]
http://www.codeproject.com/KB/COM/BuildCOMServersInDotNet.aspx
[Calling Managed .NET C# COM Objects
from Unmanaged C++ Code]
http://www.codeproject.com/KB/cs/ManagedCOM.aspx
Hope this helps,..
Regards
Kerem
--
-----------------------
Beste Gr�sse / Best regards / Votre bien devoue
Kerem G�mr�kc�
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
> If all you have is the .NET .dll (and not access to the project source
> code), then you're out of luck.
thats partially true and partially false. You still could write
a wrapper (proxy/assembly dll) and make it COM visible, this
even has some advantages, e.g encapsulating difficult calls
and stuff, possibly extending the functionality of the old net dll
with new things and many more,...this is just a example,...
The short answer is set up a COM callable wrapper. This can be as simple
as using tlbexp.exe (type library export) and creating the wrapper. I
believe you have to register the wrapper in the registry, but this is
fairly easy to do. You can google tblexp.exe for more info on the
command line tool.
Regasm.exe shortens the steps a bit, as it handles a couple of tasks,
but, if I remember correctly, you can regsrv32.exe the wrapper if you
need basic COM support. I would double check this.
As for "both in same project and need a project reference", it is not
going to happen with interop, so you have to separate the two out a bit.
Logical separation (in your head) may be enough, but putting in two
projects may be easier to ensure you keep the wrapper updated with the
assembly. It really depends on how you work.
Peace and Grace,
Greg
--
Vote for Miranda's Christmas Story
http://tinyurl.com/mirandabelieve
Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com
*******************************************
| Think outside the box! |
*******************************************
A non-com alternative is to use C++/CLI:
--
Tom Shelton
Thank you so much!
Kindest regards,
Ricardo.
"Kerem G�mr�kc�" <kare...@hotmail.com> escribi� en el mensaje
news:Oom$70sYKH...@TK2MSFTNGP04.phx.gbl...
> Beste Gr�sse / Best regards / Votre bien devoue
> Kerem G�mr�kc�
Thank a lot.
Best regards,
Ricardo.