LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 1172 - Error creating instance of class in assembly (ClassNotRegistered )

Hello,

as we might want to switch to LabView NXG for a future project I am currently testing if we can use it or not. Up to now the test was very successful but unfortunately I can't get any further. I just try to integrate a .NET dll into a small test project and then call some methods from it. Unfortunately LabView already throws the following error when creating the instance:

 

Error 1172 occurred at Invoke Node Error creating instance of CCanOpenClass in assembly EcoConnect.CCanOpenClass, Interop.EcoConnect, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f5515d91d2c91ef1, (System.Runtime.InteropServices.COMException: The COM class factory for the component with CLSID {44DC59C3-E0AB-4E51-99AC-A5CBD28861E9} could not be retrieved due to the following error: 80040154 Class not registered (exception of HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).)

 

Possible reason(s):

 

LabVIEW: (Hex 0x494) A .NET exception occurred in an external assembly. For information about correcting this error, copy the following exception (in bold), and search the Microsoft Developer Network (MSDN) Web site or the Web for a possible explanation.
System.Runtime.InteropServices.COMException in Interfaces::DotNetSchnittstelle.dni::EcoConnect::CCanOpenClass::CCanOpenClass->Interfaces::init_can.gvi->Application::Main.gvi

 

The used dll (Interop.EcoConnect.dll) is created by ourselves and we have been using it for years in countless projects (also projects with LabView 2014-2019), which is why the error is certainly not to be found in the dll. In the older LabView versions one could simply select such a dll via the .NEt interface and access it accordingly. Since the mechanism in NXG seems to have changed, it became necessary to add a .net dll or an assembly to the global assembly cache, which I did. Maybe the error is hiding there?

 

I have no idea how to fix this bug and hope that someone can help me.

 

In the attachment is a screenshot of the gvi. The error is displayed directly after the constructor call.

 

Best regards

Jens

0 Kudos
Message 1 of 7
(3,121 Views)

The error does not really originate from your interop assembly, its the COM component your performing interop with. The CLR cannot find that COM component during initialization of the wrapper class. Make sure that the COM component has been registered on the system you are using.

 

I haven't used NXG for .NET assembly integration yet so there may be another gotcha around that.

0 Kudos
Message 2 of 7
(3,058 Views)

First of all, thank you very much for your answer.

 

The purpose of the Interop.EcoConnect.dll is to provide a .NET compatible interface for the EcoConnect.dll which is a COM dll. So if the problem is that the COM component cannot be found, this would suggest that the EcoConnect.dll is not registered or cannot be found. However, the EcoConnect.dll is registered in the system during the installation of one of our programs. Could it be related to the fact that the Interop.EcoConnect.dll is no longer located at the same place as the EcoConnect.dll (it is stored under C:\Windows\assembly\GAC_MSIL\Interop.EcoConnect), because normally both dll's are located under a common program path.

 

0 Kudos
Message 3 of 7
(3,021 Views)

Hi Jens_S,

 

A couple thoughts:

  • One issue might be that the Interop.EcoConnect.dll is a 32-bit assembly, and LabVIEW NXG is a 64-bit application. (LabVIEW is a 32-bit application). Would you be able to rebuild the assembly as 64-bit?
  • What version of .NET is Interop.EcoConnect.dll built against? LabVIEW NXG is .NET Framework 4.6.2. 
  • Have you used the .NET Global Assembly Cache utility (gacutil.exe) to confirm that assembly is correctly installed in the GAC?

A few useful links:

https://stackoverflow.com/questions/17985653/class-not-registered-error

https://support.esri.com/en/technical-article/000009384

https://docs.microsoft.com/en-us/visualstudio/ide/how-to-configure-projects-to-target-platforms?view...

 

Thanks,

Frank

0 Kudos
Message 4 of 7
(2,996 Views)

Hi fblerg,

 

You're right, the Interop.EcoConnect.dll is a 32-bit assembly, but I don't know if I can build it as a 64-bit version. The EcoConnect.dll is used in a larger C# project and Visual Studio/ .NET creates the Interop dll automatically. The C# project itself is also a 32-bit application built with .Net 4.7. So yes, the possibility that the error is caused by this is relatively high.

 

Parallel to the forums here I am also in direct contact with NI but still waiting for an answer. If the platform for which the dll is built is actually the reason for the problems, LabVIEW NXG should at least give a clear error.

 

And yes, the Interop dll was installed with the help of the GAC tool.

0 Kudos
Message 5 of 7
(2,967 Views)

I'm afraid it's out of the hands of LabVIEW NXG to determine the exact reason for this error. After all it's not LabVIEW NXG that tries to instantiate your COM object but your Interop assembly and LabVIEW NXP can not even start to guess what your Interop assembly might be trying to do. So all it can do is passing along Exception information that your Interop assembly throws. Your Interop assembly is the one that has the ability to more clearly determine what is the cause of the problem and throw a more clear Exception.

Rolf Kalbermatter
My Blog
Message 6 of 7
(2,948 Views)

Hi Jen,

 

Alright, thanks for confirming those points. As a test to confirm, I would recommend trying to build the project/assembly as 64-bit assembly if possible. There is also a Visual Studio Build option for Platform Target: Any CPU, which might be helpful.

 

https://stackoverflow.com/questions/5229768/c-sharp-compiling-for-32-64-bit-or-for-any-cpu

https://docs.microsoft.com/en-us/visualstudio/ide/how-to-configure-projects-to-target-platforms?view...

 

Thanks,

Frank

0 Kudos
Message 7 of 7
(2,925 Views)