C++/CLI /CLR Managed Support in Native LibraryHi,<br><br>I have a C++ project, a .dll project in Visual Studio 2005, which uses all native C++.  I was able to compile the project with the /clr option  (just /clr for common language runtime support).  I am able to add the a reference to the dll with another C++ project, which is also compiled with the /clr option, and the entire application runs fine.<br><br>The problem comes when I try adding the .dll project reference to a test C# project and add a &quot;using MyCPPNamespace&quot; to my C# class.  I don't see the new C++ project namespace anywhere within my intellisense in the C Sharp project and I can't just add it as a using.<br><br>I thought compiling my native C++ project with the /clr option allowed us to add references to these projects in other managed language projects.  Am I missing something here?  Please help me, this is a very urgent matter.<br><br>Thanks in advance!<br><br>Kind Regards,<br>Thomas Goddard<br>www.thomasgoddard.com<br>© 2009 Microsoft Corporation. All rights reserved.Thu, 19 Jun 2008 00:15:52 Z9c8c4001-f370-4d18-9d90-0e38b00e0663http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#9c8c4001-f370-4d18-9d90-0e38b00e0663http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#9c8c4001-f370-4d18-9d90-0e38b00e0663YourMomhttp://social.msdn.microsoft.com/Profile/en-US/?user=YourMomC++/CLI /CLR Managed Support in Native LibraryHi,<br><br>I have a C++ project, a .dll project in Visual Studio 2005, which uses all native C++.  I was able to compile the project with the /clr option  (just /clr for common language runtime support).  I am able to add the a reference to the dll with another C++ project, which is also compiled with the /clr option, and the entire application runs fine.<br><br>The problem comes when I try adding the .dll project reference to a test C# project and add a &quot;using MyCPPNamespace&quot; to my C# class.  I don't see the new C++ project namespace anywhere within my intellisense in the C Sharp project and I can't just add it as a using.<br><br>I thought compiling my native C++ project with the /clr option allowed us to add references to these projects in other managed language projects.  Am I missing something here?  Please help me, this is a very urgent matter.<br><br>Thanks in advance!<br><br>Kind Regards,<br>Thomas Goddard<br>www.thomasgoddard.com<br>Fri, 28 Jul 2006 08:19:47 Z2006-07-29T04:35:40Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#cabb4ae5-0e06-4d36-bbcf-426eee42fc85http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#cabb4ae5-0e06-4d36-bbcf-426eee42fc85nobugzhttp://social.msdn.microsoft.com/Profile/en-US/?user=nobugzC++/CLI /CLR Managed Support in Native Library<font size=2><span style="font-family:Verdana,Geneva,Arial,Sans-serif">There's nothing special about an assembly created by the C++ compiler and linker vs one made by the C# compiler.  Try using View + Object Browser to verify that you can see the namespace and the classes in the assembly.  Don't rely too much in IntelliSense, its got problems.  Just try to create a class from the assembly in your code...<br></span></font>Fri, 28 Jul 2006 08:39:32 Z2006-07-28T15:57:48Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#d8c7430e-e94c-4ac6-9991-e7f52c6b7b0bhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#d8c7430e-e94c-4ac6-9991-e7f52c6b7b0bJonathan Caves - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Jonathan%20Caves%20-%20MSFTC++/CLI /CLR Managed Support in Native Library<p>Just compiling your code with /clr does not make your classes accessible from C# - they are still native C++ classes which is something that C# knows nothing about. All that compiling with /clr has done is enable your code to run on the CLR it does not make it interoperable with other .NET languages. In order to be able to interoperate you need to create some classes that are accessible from other .NET languages. To do this you need to use C++/CLI - something like:<br><br><font face="Courier New, Courier, Monospace" color="#0000ff">   public ref class MyClass {<br>      // ...<br>   };</font></p> <p>Here is  good initial <a title="http://msdn2.microsoft.com/en-us/library/xey702bw.aspx" href="http://msdn2.microsoft.com/en-us/library/xey702bw.aspx">introduction</a> to the syntax of C++/CLI.</p>Fri, 28 Jul 2006 16:10:00 Z2006-07-28T16:10:00Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#cecc8197-3de2-42d6-9e70-0b4abf08507chttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#cecc8197-3de2-42d6-9e70-0b4abf08507cnobugzhttp://social.msdn.microsoft.com/Profile/en-US/?user=nobugzC++/CLI /CLR Managed Support in Native Library<font size="2"><span style="font-family: verdana,geneva,arial,sans-serif;">My apologies for my poor response; my post was marked as the answer by the MSFT C++ program manager. Please don't hesitate to unmark it. <br> <br> Without having any code to look at, we need to guess what might be the problem. Things to check:<br> - Did you add a reference to the DLL?<br> - Did you use "ref class" to declare the C++ classes?<br> - When you say "shows my dll's structure", do you see the classes?<br> - When you say "native code classes", do you mean C++/CLI classes or C++ classes?<br> <br> <br> <br> <br> </span></font>Fri, 28 Jul 2006 16:13:27 Z2006-07-28T16:13:27Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#186d44c7-e0fa-4c30-bf57-db8c0f0da924http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#186d44c7-e0fa-4c30-bf57-db8c0f0da924nobugzhttp://social.msdn.microsoft.com/Profile/en-US/?user=nobugzC++/CLI /CLR Managed Support in Native Library<font size=2><span style="font-family:verdana,geneva,arial,sans-serif">Make sure you use the Object Browser in C#, not in C++<br> </span></font>Fri, 28 Jul 2006 16:29:05 Z2006-07-28T16:29:05Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#a6c6b668-c455-47f6-b248-ff6bd81fd6b6http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#a6c6b668-c455-47f6-b248-ff6bd81fd6b6YourMomhttp://social.msdn.microsoft.com/Profile/en-US/?user=YourMomC++/CLI /CLR Managed Support in Native LibraryHi Jonathan,<br>Thank you for the detailed response and your quick response at that. You're saying that I can make some new C++/CLI files, alongside my native C++ files which essentially just makes calls to my native C++?<br><br>I tried the above solution by adding the following code.<br><span style="color: rgb(0, 0, 255);">#pragma once</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);">#include "includes/mynativeclass.hpp"</span><br style="color: rgb(0, 0, 255);"><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);">using namespace someNativeSpace;</span><br style="color: rgb(0, 0, 255);"><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);">namespace myFooSpace</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);">{</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> ref class Foo</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> {</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> public:</span><br style="color: rgb(0, 0, 255);"><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> Foo(void)</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> {</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> nativeclass^ test = new nativeclass();</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> test.whatever();</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> }</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> };</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);">}</span><br><br>Then I compiled and added the project reference to my C# project. After adding the reference I tried this:<br><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);">using System;</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);">using myFooSpace;</span><br style="color: rgb(0, 0, 255);"><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);">namespace Test</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);">{</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> class Class1</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> {</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> Foo foo = new Foo();</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);"> }</span><br style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 255);">}</span><br><br>Of course there was still no intellisense and I simply typed out the namespace and the class intantiation.<br><br>When I tried compiling the C# project I received an error that the namespace myFooNamespace did not exist. The C++ project still compiled fine.<br><br>nobugz:<br> These are native C++ classes (not C++/CLI), no ref was added at all. I see the classes in the object browser and there is a reference to the assembly.<br><br>What else should I try? I can send you guys the solution with some instructions on getting it setup in your dev environment (if you need it to compile) but the setup process requires an open source library called boost. Let me know if you want the source to the solution so you can test it out on your own.<br><br>If you have any other suggestions, I am happy to try them.<br><br>Thank you!<br>Fri, 28 Jul 2006 17:06:08 Z2006-07-28T17:06:08Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#385431a7-685a-4576-a6c4-1be6239067c0http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#385431a7-685a-4576-a6c4-1be6239067c0Jonathan Caves - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Jonathan%20Caves%20-%20MSFTC++/CLI /CLR Managed Support in Native Library<p>There are a couple of problems with this. The first I suspect must be a typo otherwise the code wouldn't compile - it should be:<br><br><font face="Courier New, Courier, Monospace" color="#0000ff">   nativeClass* test = new nativeClass();</font><br><br>The second issue is probably the cause of your problem. The definition of the class needs to be visible to the C# code. So you need to define it as:</p> <p><font face="Courier New, Courier, Monospace" color="#0000ff">   namespace myFooNamespace {<br>      <font color="#ff0000"><strong>public</strong></font> ref class Foo {<br>         // ...<br>      };<br>}</font></p> <p> </p>Fri, 28 Jul 2006 17:11:23 Z2006-07-28T17:11:23Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#b8870610-a381-494b-88b4-baf21f7fb4achttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#b8870610-a381-494b-88b4-baf21f7fb4acAyman Shoukry - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Ayman%20Shoukry%20-%20MSFTC++/CLI /CLR Managed Support in Native Library<p>My appology, I marked nobugz's post as an answer by mistake.</p> <p>Thomas, have you tried the last post by Jonathan! I tried it on my machine using a simple example and it worked.</p> <address>Thanks,</address> <address>Ayman Shoukry</address> <address>VC++ Team</address>Fri, 28 Jul 2006 17:24:19 Z2006-07-28T17:24:19Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#600f1f3d-6921-4f25-939d-e3bbb13a76d8http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#600f1f3d-6921-4f25-939d-e3bbb13a76d8YourMomhttp://social.msdn.microsoft.com/Profile/en-US/?user=YourMomC++/CLI /CLR Managed Support in Native LibraryOk here is a <font size="4"><a style="font-weight: bold;" href="http://www.thomasgoddard.com/source.png">screenshot</a><span style="font-weight: bold;"> </span></font>with the project properties of the C++ project as well as the C# project and source.<br><br>I am still receiving the same errors:<br><br>Error 1 The type or namespace name 'myFooSpace' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Thomas Goddard\Desktop\libtorrent\test\Test\Program.cs 2 7 Test<br>Error 2 The type or namespace name 'myFooSpace' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Thomas Goddard\Desktop\libtorrent\test\Test\Class1.cs 2 7 Test<br>Error 3 The type or namespace name 'Foo' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Thomas Goddard\Desktop\libtorrent\test\Test\Class1.cs 8 9 Test<br><br><span id="_ctl0_MainContent_PostFlatView"><span></span></span><font size="4"><a target="_blank" title="http://www.thomasgoddard.com/ObjectBrowser.png" href="http://www.thomasgoddard.com/ObjectBrowser.png"><span style="text-decoration: underline; font-weight: bold;">Here is a view of the Object Browser as well</span></a><br><br></font>Thanks,<br>Tommy<br><br><br><br>Fri, 28 Jul 2006 17:57:45 Z2006-07-28T17:57:45Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#d87bb991-e099-418d-a229-2acc235ffeb9http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#d87bb991-e099-418d-a229-2acc235ffeb9nobugzhttp://social.msdn.microsoft.com/Profile/en-US/?user=nobugzC++/CLI /CLR Managed Support in Native Library<font size=2><span style="font-family:verdana,geneva,arial,sans-serif">Try using LibTorrent.myFooSpace;<br> </span></font>Fri, 28 Jul 2006 18:33:04 Z2006-07-28T18:33:04Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#f0f6dddd-49ff-4976-964a-de7dd3a41a10http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#f0f6dddd-49ff-4976-964a-de7dd3a41a10Jonathan Caves - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Jonathan%20Caves%20-%20MSFTC++/CLI /CLR Managed Support in Native Library<p>I still see his code:<br><br>torrent^ test = new torrent();</p> <p>This should not compile and it may explain why the C# project can't see the C++ assembly - I would check to ensure that your C++ assembly as actually built successfully.</p>Fri, 28 Jul 2006 18:50:48 Z2006-07-28T18:50:48Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#96a5aaba-1ed1-4669-8ae3-b691b1294588http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#96a5aaba-1ed1-4669-8ae3-b691b1294588YourMomhttp://social.msdn.microsoft.com/Profile/en-US/?user=YourMomC++/CLI /CLR Managed Support in Native LibraryEither way it's the same problem * or ^. <br><br>Error 1 The type or namespace name 'myFooSpace' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Thomas Goddard\Desktop\libtorrent\test\Test\Program.cs 2 7 Test<br>Error 2 The type or namespace name 'myFooSpace' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Thomas Goddard\Desktop\libtorrent\test\Test\Class1.cs 2 7 Test<br>Error 3 The type or namespace name 'Foo' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Thomas Goddard\Desktop\libtorrent\test\Test\Class1.cs 8 9 Test<br><br>I tried LibTorrent.myFooSpace as well. What's missing?<br><br>I am using the following preprocessor directives:<br>WIN32<br>WIN32_LEAN_AND_MEAN<br>_WIN32_WINNT=0x0500<br>UNICODE<br>You can see these in the build log below.&nbsp; I get lots of warnings but 0 errors, LibTorrent.vcproj compiles and links fine.<br><br><font size="4"><a style="font-weight: bold;" href="http://www.thomasgoddard.com/BuildLog.htm">build log</a><font size="3"></font><br></font>Fri, 28 Jul 2006 20:19:54 Z2006-07-28T20:19:54Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#ad25c888-6176-444b-8769-2c91960dbdcehttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#ad25c888-6176-444b-8769-2c91960dbdceeinaroshttp://social.msdn.microsoft.com/Profile/en-US/?user=einarosC++/CLI /CLR Managed Support in Native Library<P>In your C# code, try loading the native/cli dll through reflection, e.g.</P> <P>Assembly asm = Assembly.LoadFile("path to dll");<BR>Type sometype = asm.GetType("'myFooSpace.Foo");</P> <P>This may, if nothing else, help debugging the issue.</P> <P>Make sure that you point to the right dll and try building both&nbsp;with release configuration.</P>Fri, 28 Jul 2006 20:51:27 Z2006-07-28T20:51:27Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#0b54133a-a464-4ca5-9e8f-a318104b72b5http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#0b54133a-a464-4ca5-9e8f-a318104b72b5einaroshttp://social.msdn.microsoft.com/Profile/en-US/?user=einarosC++/CLI /CLR Managed Support in Native Library<p>Also, a side note. Wouldn't /clr make all the code compile as managed by default? I thought that was why the managed/unmanaged pragmas were provided.</p> <p>If this was previously a non-clr dll project, you should at least make sure that your DllMain is unmanaged, to avoid further issues (like loader locks).</p>Fri, 28 Jul 2006 21:11:04 Z2006-07-28T21:11:04Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#17660bc8-0743-4f85-87fe-e15865b94e23http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#17660bc8-0743-4f85-87fe-e15865b94e23YourMomhttp://social.msdn.microsoft.com/Profile/en-US/?user=YourMomC++/CLI /CLR Managed Support in Native Library<span id="_ctl0_MainContent_PostFlatView"><span class=inlineLink>einaros,<br>Thank you for taking the time to reply to my issue.  I went ahead and loaded the assembly <font style="font-weight:bold" size=4><a title="http://www.thomasgoddard.com/Reflection.png" href="http://www.thomasgoddard.com/Reflection.png">using reflection and here is the result</a></font><span style="font-weight:bold">.</span><br><br>You'll notice that entry point is null and sometype is null as well.</span><b><span class=inlineLink><br><br></span> </b></span>Fri, 28 Jul 2006 21:35:34 Z2006-07-28T21:35:34Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#bd26ff29-cb92-47e4-8b2f-ecb3fdce1db4http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#bd26ff29-cb92-47e4-8b2f-ecb3fdce1db4Jonathan Caves - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Jonathan%20Caves%20-%20MSFTC++/CLI /CLR Managed Support in Native Library<p>I'm sorry to keep harping on about this but the '^'/'*' issue is important. If you use '^' the code should not compile and the assembly will not be created - but it looks like C# compiler can find the assembly but it can't find any types in the assembly. This tells me that the C# compiler might be loading a stale version of the assembly so that no matter what changes you make to the C++ assembly (even introducing errors that stop it from building) the C# project is still building against the older version. Even if fix the C++ assembly so that it should work the C# compiler is still using the older version.</p> <p>I would check where the final output of C++ build process is being created and/or checked the timestamp on the version of the assembly that the C# compiler is referenceing.</p>Fri, 28 Jul 2006 21:48:06 Z2006-07-28T21:48:06Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#2ec80904-0a3f-406b-a46d-231e472ac352http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#2ec80904-0a3f-406b-a46d-231e472ac352einaroshttp://social.msdn.microsoft.com/Profile/en-US/?user=einarosC++/CLI /CLR Managed Support in Native Library<p>Entry point being null is normal. Sometype, however ..</p> <p><font face=Verdana>You should point the Assembly.LoadFile to the output directory of the dll project (release/debug), and not the file put in your C#-project output folder (which vs copies there, as you've added a reference to it). With reflection, the reference isn't needed.</font></p>Fri, 28 Jul 2006 21:52:34 Z2006-07-28T21:52:34Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#42de0b26-6dbc-4b5d-a5b6-18367e0296a5http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#42de0b26-6dbc-4b5d-a5b6-18367e0296a5YourMomhttp://social.msdn.microsoft.com/Profile/en-US/?user=YourMomC++/CLI /CLR Managed Support in Native LibraryJonathan and einaros,<br>Thanks for sticking with me on this...<br>Still no luck!<br><font size=4><a style="font-weight:bold" href="http://www.thomasgoddard.com/AllUpdated.png">Here is the latest screen shot</a><br><br>If you guys can figure this out, I'll get you both one of these <img src="images/emoticons/smile_teeth.gif"><br></font><div style="text-align:left"><font size=4><img style="width:162px;height:282px" src="http://www.newscientist.com/data/images/ns/cms/dn8069/dn8069-1_350.jpg">  </font><br></div><font size=4><br></font>Fri, 28 Jul 2006 22:08:45 Z2006-07-28T22:08:45Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#7160f27d-121a-4526-8a18-177cdafac745http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#7160f27d-121a-4526-8a18-177cdafac745YourMomhttp://social.msdn.microsoft.com/Profile/en-US/?user=YourMomC++/CLI /CLR Managed Support in Native LibraryHere is the <font size="4"><a style="font-weight: bold;" href="http://www.thomasgoddard.com/test.zip">Test Project</a><span style="font-weight: bold;"> </span></font>with the library and test client<br><br>You can run reflector on it and see that the Foo class is NOT in the libtorrent library.<br>Fri, 28 Jul 2006 22:16:19 Z2006-07-28T22:16:19Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#8c7f6ff9-12a1-4af4-92ec-e4699e64d031http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#8c7f6ff9-12a1-4af4-92ec-e4699e64d031einaroshttp://social.msdn.microsoft.com/Profile/en-US/?user=einarosC++/CLI /CLR Managed Support in Native LibraryNeither reflector nor the object browser finds the myFooSpace.Foo class in that .dll. Did you include the right one?Fri, 28 Jul 2006 22:36:03 Z2006-07-28T22:36:03Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#a51f7e94-fad3-49d7-b3d5-2131da2f3727http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#a51f7e94-fad3-49d7-b3d5-2131da2f3727YourMomhttp://social.msdn.microsoft.com/Profile/en-US/?user=YourMomC++/CLI /CLR Managed Support in Native LibraryYes that's the latest one.  I take back my last post about the class showing up in reflector.  That's the most recent DLL with a date and time of the last build.  If I change a character in the source on the vcproj, the build fails.  With the code exactly like the screenshots, I tried a build clean which whiped the directory, and built again, the build completed fine and the dll is back.<br>Fri, 28 Jul 2006 22:50:14 Z2006-07-28T22:50:14Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#f30c69ca-11b6-45a3-b48e-33922d75ff12http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#f30c69ca-11b6-45a3-b48e-33922d75ff12einaroshttp://social.msdn.microsoft.com/Profile/en-US/?user=einarosC++/CLI /CLR Managed Support in Native Library<P>In any case, with the amount of noise in your build log (__fastcall being incompatible with /clr and so forth), I suggest you make a simple clr&nbsp;proxy dll instead. Keep libtorrent as a pure native dll and export the proper c++ classes. Add a second dll with a managed interface to these classes. </P> <P>This could help remove the issues at hand, as well as any unwanted effects of compiling a ton of libraries (like Boost) with /clr.</P> <P>Keep in mind though, all third party libraries should remain hidden for the managed proxy code using the native interface -- or else you'd have to include boost and other headers again, and you'd be back in the tar pit.</P>Fri, 28 Jul 2006 22:53:09 Z2006-07-29T04:35:40Zhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#ee985008-688e-46ba-ab59-43fd5d53266bhttp://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9c8c4001-f370-4d18-9d90-0e38b00e0663#ee985008-688e-46ba-ab59-43fd5d53266bYourMomhttp://social.msdn.microsoft.com/Profile/en-US/?user=YourMomC++/CLI /CLR Managed Support in Native LibraryI did exactly as you said in your previous post.&nbsp; I created a new separate project, managed C++/CLI project which contains a reference to the unmanaged(native) C++ .lib file.&nbsp; I added the required header files to include, in the managed project, and compiled it with a simple call to the native code within the managed dll.<br><br>I then reference the managed C++/CLI project from inside the C# project and the classes and namespaces are visible from the C# class.&nbsp; Problem solved!<br><br>Thank you to everyone for your strong support on this issue.<br><br>Not sure what the main issue was with the original LibTorrent project but I am totally happy with this separate managed dll.<br><br>Cheers and Beers!<br>T<br><br><br>Fri, 28 Jul 2006 23:11:18 Z2006-07-28T23:11:18Z