LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Having difficulty using a dotnet assembly (won't load)

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);



}

0 Kudos
Message 1 of 5
(4,617 Views)

What version of .NET  did you create the assembly in and what version of LabWindows/CVI are you using? 

0 Kudos
Message 2 of 5
(4,578 Views)

(dll} Assemblly was created in  .net version 2.0, For CVI I have tried both 2010 and 2013.  Note dll comes from a third party however, I have been able to use it in my visual studio (2010) project without any issues.  the reason I need it for CVI is that there is an existing CVI based test equipment that needs upgrade / extention with some of the capabilitoes comming from this assembly

0 Kudos
Message 3 of 5
(4,560 Views)

Does the assembly have any additional .NET dependencies? If so, those will also need a wrapper generated. 

0 Kudos
Message 4 of 5
(4,541 Views)

There are no other dependencies that is the only reference I add to my visual Studio project.

0 Kudos
Message 5 of 5
(4,537 Views)