Access violation on static initialization

This is the answer of Microsoft as posted to my bug report at Microsoft Connect: Windows Server 2003 and Windows XP have problems with dynamically loading a DLL (via LoadLibrary) that uses thread-local storage, which is what thread-safe statics use internally to provide efficient execution when the static local has already been initialized. As these … Read more

How to implement a unmanaged thread-safe collection when I get this error: is not supported when compiling with /clr

It is not supported because the std::mutex implementation uses GetCurrentThreadId(). That’s a winapi function that is not supposed to be use in managed code since it might be running on a custom CLR host that doesn’t use threads to implement threading. This is the good kind of problem to have, it shows that you are … Read more

How can I make my managed NuGet package support C++/CLI projects?

As Patrick O’Hara wrote, NuGet will not make changes to a C++/CLI project for you. See GitHub Issue NuGet/Home#1121 – Cannot install managed packages into a CLI project. However, using the NuGet command line utility, NuGet.exe, you can have NuGet download and unpack the desired package(s). For a complete example, here were steps that I … Read more

How to call managed code from unmanaged code?

Look at this solution: https://sites.google.com/site/robertgiesecke/Home/uploads/unmanagedexports The solution allows to call C# function from C by decorating your function with [DllExport] attribute (opposite of P/Invoke DllImport). Exmaple: C# code class Test { [DllExport(“add”, CallingConvention = CallingConvention.StdCall)] public static int Add(int left, int right) { return left + right; } } C code: extern “C” int add(int, … 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