Using C# DLL in C++ App - nearly there...
-
I realise there is a lot of stuff out there relating to this need, but I'm still struggling...so any pointers to where I'm going wrong are appreciated. I'm attempting to use the ModbusTCP DLL (available elsewhere on these forums) in my C++ console test app (with CLR support enabled) and it compiles ok. However, it crashes even before execution even gets to the first printf(...). Code is as follows, error details are after the code;
#include "stdafx.h"
#include "conio.h"#using "ModbusTCP.dll" // TCP Master implementation
using namespace ModbusTCP;int _tmain(int argc, _TCHAR* argv[])
{
printf( "About to create MBmaster..." );
try
{
// Create new modbus master and add event functions
Master^ MBmaster = gcnew Master( "192.168.100.1", 23 );
printf( "MBmaster created ok" );
}
catch ( ... )//SystemException error )
{
//MessageBox.Show( error.Message );
printf( "Error caught" );
}while ( !\_getch() ) ; return 0;
}
Error dialog contains the following text: "An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. Could not load file or assembly 'ModbusTCP, etc, or one of its dependencies".