Trying to run sample code in a c# visual studio project.  This is what I have done so far

1. Added reference to gnsdk_csharp to project

2. Added gnsdk_csharp_marshal.dll to project with "copy if newer"

3. Added all files from main lib folder for windows to project with "copy if newer"

I've tried using both 32 & 64 bit dll's and both same error.  To make it easy I just put all dll's in root of project. Here is arguments using

"123456" "120398a09asdf19922" "License.txt" "." "online"

clientid fake and quotes are for visual reference

When run get error:

An unhandled exception of type 'System.TypeInitializationException' occurred in gnsdk_csharp.dll

Additional information: The type initializer for 'GracenoteSDK.gnsdk_csharp_marshalPINVOKE' threw an exception.

This fixed it for me from post


  • One must add a Reference to gnsdk\wrappers\gnsdk_csharp\lib\gnsdk_csharp.dll.
  • A Post-build event should be added to copy gnsdk\wrappers\gnsdk_csharp\lib\win_x86-64\gnsdk_csharp_marshal.dll into the Output Directory.
  • The gnsdk\lib\win_x86-64 folder must also be passed in via the command line; so the gnsdk_loader can load modules such as gnsdk_manager.dll.

This is not working I get the same error no matter what I do. The error apears to be in the gnsdk_csharp_marshal.dll

This did not solve it for me, what version of Visual Studio are you using?

Ok got this working first and foremost set your target build to x64 under the build. Other wise it will throw several errors and make sure you pass the path via  a string for initializing 

            gnsdkLibraryPath = "D:\\GraceNote\\gnsdk-\\lib\\win_x86-64";
            GnManager manager = new GnManager(gnsdkLibraryPath, licenseFile, GnLicenseInputMode.kLicenseInputModeFilename);