C++ CLI error C3767: candidate function(s) not accessible

The problem is that std::string will compile as a internal (non public) type. This is actually a change in VS 2005+: http://msdn.microsoft.com/en-us/library/ms177253(VS.80).aspx: Native types are private by default outside the assembly Native types now will not be visible outside the assembly by default. For more information on type visibility outside the assembly, see Type Visibility. … Read more

Strong Name Validation Failed

Open the command prompt as administrator and enter following commands: reg DELETE “HKLM\Software\Microsoft\StrongName\Verification” /f reg ADD “HKLM\Software\Microsoft\StrongName\Verification\*,*” /f reg DELETE “HKLM\Software\Wow6432Node\Microsoft\StrongName\Verification” /f reg ADD “HKLM\Software\Wow6432Node\Microsoft\StrongName\Verification\*,*” /f

In C++/CLI, how do I declare and call a function with an ‘out’ parameter?

C++/CLI itself doesn’t support a real ‘out’ argument, but you can mark a reference as an out argument to make other languages see it as a real out argument. You can do this for reference types as: void ReturnString([Out] String^% value) { value = “Returned via out parameter”; } // Called as String^ result; ReturnString(result); … Read more

What is the best way to convert between char* and System::String in C++/CLI

System::String has a constructor that takes a char*: using namespace system; const char* charstr = “Hello, world!”; String^ clistr = gcnew String(charstr); Console::WriteLine(clistr); Getting a char* back is a bit harder, but not too bad: IntPtr p = Marshal::StringToHGlobalAnsi(clistr); char *pNewCharStr = static_cast<char*>(p.ToPointer()); cout << pNewCharStr << endl; Marshal::FreeHGlobal(p);

How to use LINQ in C++/CLI – in VS 2010/.Net 4.0

You can use the Linq methods that are defined in the System::Linq namespace, but you’ll have to jump through a couple extra hoops. First, C++/CLI doesn’t support extension methods. However, the extension methods are regular methods defined on various classes in System::Linq, so you can call them directly. List<int>^ list = gcnew List<int>(); int i … Read more

C++/CLI wrapper for native C++ to use as reference in C#

Ok, tutorial. You have a C++ class NativeClass that you want to expose to C#. class NativeClass { public: void Method(); }; 1) Create a C++/CLI project. Link to your C++ library and headers. 2) Create a wrapper class that exposes the methods you want. Example: #include “NativeClass.h” public ref class NativeClassWrapper { NativeClass* m_nativeClass; … Read more

What does System.Double[*] mean

This is a typical interop problem, the array was created in a COM Automation server. Which exposes the array as a SafeArray, the CLR automatically marshals them to a .NET array object and maintains its structure as specified in the safe array descriptor. A System.Double[] array is a very specific kind of array in the … Read more

Change C++/CLI project to another framework than 4.0 with vs2010

This shows up when you press F1 in the Framework and References dialog: By default for new projects, the targeted framework is set to .NET Framework 4. The IDE does not support modifying the targeted framework, but you can change it manually. In the project file (.vcxproj), the default targeted framework is represented by the … Read more

No IntelliSense for C++/CLI in Visual Studio 2010?

You are correct. Unfortunately it has been dropped. You can check this opened issue on Microsoft’s Connect website. I’ll just quote them for the sake of the answer: Unfortunately in this release we had to cut the intellisense support for C++/CLI due to time constraints. If you want to get some intellisense like quick info … Read more