P/Invoke or C++/CLI for wrapping a C library

In the case where I am working with an existing C library, I prefer PInvoke. PInvoke, while a bit tedious and troublesome at times, is a fairly well understood technology that has an ever growing set of tools and internet documentation available. Generally speaking, whatever problem you run into, there is already a sample available … 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

How to use Nullable types in c++/cli?

OK, found it, after a lot of hassle: to return null, just do return Nullable<double>(); to return non-null: return Nullable<double>(12321); It is important to declare the return value as Nullable<double> and not Nullable<double>^, as if you do it, when using other languages as C# and vb.net, you’ll see the type as ValueType instead of double?.

Using C++ Class DLL in C# Application

Simple way assuming class Foo: Create a C++/CLI project, call this FooWrapper. Make FooWrapper depend on the unmanaged dll (however you normally would). Create a managed class ManagedFoo which contains a single private instance field of type Foo*. provide public wrapping functions in ManagedFoo which forward on to the underlying instance field. Optionally (though recommended): … Read more

What is app.aps file in Visual C++?

It’s a generated file for designer efficiency, you can ignore it in source control: File created by Microsoft Visual C++, a software development application; stores the binary representation of a resource included with the project; enables the application to load resources more quickly. http://fileinfo.com/extension/aps

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);

Documenting C++/CLI library code for use from c# – best tools and practices? [closed]

I have gotten it to work as follows: Use XML style comments for your C++/CLI header entries. This means the full XML comment is required (triple-slash comments, <summary> tag at a minimum) Make sure that the C++ compiler option Generate XML Documentation Files is on. This should generate an XML file with documentation with 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

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)