I am trying to use a dotnet dll and having problems loading it. Used .net controller from tools menu to create a CVI wrapper all that worked out without any issue. However, when I try to use it will get an error CDotNetCouldNotLoadAssemblyError. I read some posts and they recommended to register path and that function works fine . I even added my dotnet dll to the GAC it still gives same errors. Dll itself work fines since I can use it within my visual studio project and control hardware. Here is the piece of code
//==============================================================================
// Global variables
CDotNetAssemblyHandle ecMasterDotNet;
EcMasterDotNet_CEcMasterDotNet thisEcMaster;
//Master parameters
EcMasterDotNet_DN_EC_T_INITMASTERPARMS initMasterParams;
// Master Config
EcMasterDotNet_DN_EC_T_MASTER_CONFIG oMasterConfig;
//
EcMasterDotNet_ECError ecRetVal;
//==============================================================================
// Global functions
/// HIFN The main entry-point function.
int main (int argc, char *argv[])
{
int error = 0;
/* initialize and load resources */
nullChk (InitCVIRTE (0, argv, 0));
errChk (panelHandle = LoadPanel (0, "EthercatTest.uir", PANEL));
/* display the panel and run the user interface */
errChk (DisplayPanel (panelHandle));
errChk (RunUserInterface ());
MessagePopup("Application Exit","Exit");
Error:
/* clean up */
if (panelHandle > 0)
DiscardPanel (panelHandle);
return 0;
}
void InitializeMaster()
{
int retVal = -9999;
char valReturned[40];
retVal = CDotNetRegisterAssemblyPath("EcMasterDotNet, Version=2.5.3.6, Culture=Neutral, PublicKeyToken=13b16034f262d5b2","C:\\temp\\EtherCatDotNet\\EcMasterDotNet.dll");
//retVal = CDotNetRegisterAssemblyPath("EcMasterDotNet","C:\\temp\\EcMasterDotNet.dll");
retVal = Initialize_mscorlib();
/****************** Error on the next line, it won't work returns -6579 CDotNetCouldNotLoadAssemblyError ************************/
retVal = CDotNetLoadAssembly ("EcMasterDotNet.dll", &ecMasterDotNet);
retVal = Initialize_EcMasterDotNet();
//Initialize ECMasterDotNet library
retVal = EcMasterDotNet_CEcMasterDotNet__Create(&thisEcMaster, 0);
sprintf(valReturned,"Init returned: %d", retVal);
MessagePopup("Init EcDotnet", valReturned);
//Init Master Param
retVal = EcMasterDotNet_DN_EC_T_INITMASTERPARMS__Create (&initMasterParams, 0);
retVal = EcMasterDotNet_DN_EC_T_MASTER_CONFIG__Create (&oMasterConfig, 0);
}