Managed dll import complaining about string marshalling

Hi folks,

I am using a Managed dll to use Measuring Computing’s DAQ, a piece of hardware that lets me do fancy analogue I/O. I’m able to import the dll, instantiate the class, and even access fields, but when I try to call a method, I get:

NotImplementedException: string marshalling conversion 34 not implemented.

I guess my first question is: Is it OK to use a managed dll that calls native dlls? I’ve run into a problem in the past where I couldn’t have one dll access another, but they were both c++.

The second question is: could I get this exception by simply not having the right header or required native dll accessible?

Any guidance would be much appreciated!


Hi Alex,

I just ran into the same issue when trying to use a managegd DAQ library (MccDaq/Meilhaus) inside of Unity. Have you made any progress on this issue?

Kind regards,

I never got the managed dll to work. I don’t remember why, it was either because Unity doesn’t like even managed dlls calling other dlls or something to do with the compiler they used. I ended up using the native 64 bit dll. This is the class I used to wrap it:

using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;

// This class wraps up the MCDAQ dll.  This is the library that lets us set the 
// voltage of our device

//TODO error checking for cb calls

public class MCDAQ

    private const string LOG_TAG = "MCDAQ";
    private const bool VERBOSE = false;

    // Types of configuration
    private static int GLOBALINFO = 1;
	private static int BOARDINFO = 2;

	// Types of board configuration info
	private static int BIRANGE	= 6;	// Switch selectable range
	private static int BICLOCK	= 5;	// Switch selectable range

	// Available ranges
	private static int BIP10VOLTS = 1;		// -10 to +10 Volts
	private static int BIP5VOLTS  = 0;		// -5 to +5 Volts
	private static int UNI10VOLTS = 100;	// 0 to +10 Volts

	// Types of error reporting
	private static int DONTPRINT = 0;
	private static int PRINTALL  = 3;     

	// Types of error handling
	private static int DONTSTOP = 0;
	private static int STOPALL = 2;       

	private static float CURRENT_REVISION_NUMBER = 6.51f;
	private static int BOARD_NUMBER = 0;
	private static int RANGE 		= BIP10VOLTS;
	private static int CHANNEL 		= 0;

//---------------------------------------------------------EXTERNAL METHODS IMPORTS:

	[DllImport( "cbw64" )]
	private static extern int cbDeclareRevision( ref float revisionNumber );

    [DllImport( "cbw64" )]
    private static extern int cbAOut( int boardNumber, 
                                      int channel, 
                                      int gain, 
                                      ushort dataValue );

	[DllImport( "cbw64" )]
	private static extern int cbErrHandling( int reporting, int handling );

	[DllImport( "cbw64" )]
	private static extern int cbFlashLED( int boardNumber );

	[DllImport( "cbw64" )]
	private static extern int cbFromEngUnits( int boardNumber, 
	                                          int range,
	                                          float engineeringUnits,
	                                          out ushort dataValue );

	[DllImport( "cbw64" )]
	private static extern int cbGetConfig( int infoType,
	                                       int boardNumber,
	                                       int deviceNumber,
	                                       int configurationItem,
	                                       out int configurationValue );
	[DllImport( "cbw64" )]
	private static extern int cbSetConfig( int infoType,
	                                       int boardNumber,
	                                       int deviceNumber,
	                                       int configurationItem,
	                                       int configurationValue );
	[DllImport( "cbw64" )]
	private static extern int cbVOut( int boardNumber, 
	                                  int channel, 
	                                  int range, 
	                                  float dataValue,
	                                  int options );
	private static bool isInitialized;


	public static void flashLED()
	public static void init()
        // Declare the current software version
		float revisionNum = CURRENT_REVISION_NUMBER;
		cbDeclareRevision( ref revisionNum );
        // Specify internal error handling
		cbErrHandling( PRINTALL, DONTSTOP );
		isInitialized = true;

	public static void writeVolts( float volts )
		ushort dataValue;
        if( VERBOSE )
            Utility.print(LOG_TAG, "Writing Volts: " + volts);
        // Go from pos/neg volts to unsigned int
		cbFromEngUnits( BOARD_NUMBER, RANGE, volts, out dataValue );
        // Send signal to actuate
		cbAOut( BOARD_NUMBER, CHANNEL, RANGE, dataValue );