10-26-2015 04:44 AM
Hi everyone,
I am using Labwindows/CVI 2012 and I am try to register a delegate with a parameter using the system.eventhandler'1 (in mscorlib.dll). I get always the same run-time error -6578 "could not load the required type information".
I've noticed that the error happen just, when the generics, that I am passing, belongs to a different assembly. For example, if a take the generic "System.UnhandledExceptionEventArgs", it works fine, but using "System.Xml.Serialization.XmlNodeEventArgs" it would not work.
I am using the wrapper automatically generated from Labwindows and the .NET framework is 4.0 (mscorlib assembly version 4.0.0.0).
The command look like this:
System_EventHandler_T1__Create(&SystemEventHandler1,"System.Xml.Serialization.XmlNodeEventArgs", XmlSerNodeEvent, NULL, &ExceptionHandle);
I am pretty sure that both assemblies were correctly loaded and they are both in the GAC (I am able to use the other functions in the assemblies).
Should I do something special to make the second assembly "visible" to mscorlib assembly?
I thank in advance for the answers.
Best regards,
Andrea
Solved! Go to Solution.
10-27-2015 07:26 AM
Hi Andrea,
I can imagine two causes of this error message.
One is, that CVI can not load the information because it misses some information to link to the assembly. Since you are using a GAC assembly there should be normally all information available, but you can take a look into this, if you want with the following link:
Calling a Visual Basic DLL From LabWindows™/CVI - National Instruments
http://digital.ni.com/public.nsf/allkb/AA35D259FD350D3E8625699F0059C641?OpenDocument
The second cause may be a return value, that can not be handled by CVI itself. I think the handle is the one, that can cause the issue here.
when passing data between C and .NET not all data types and objects can be casted automatically. Under the following link you can find a list:
Converting .NET Data Types to C Data Types - LabWindows™/CVI™ 2013 Help - National Instruments
http://zone.ni.com/reference/en-XX/help/370051Y-01/cvi/libref/cvidotnet_convertingdatatypes/
The handles are mentioned here, too.
Best regards,
Melanie
07-11-2016 10:55 AM
Hello Andrea,
How did you resolve this issue? I'm having a silmilar problem using eventhandler'1.
Best regards,
Darrel
12-06-2016 10:10 AM
I wanted to respond to this page since there's no resolution. Two notes about System_EventHandler_T1__Create:
I'd highly recommend reading through this page if you have questions about this:
MSDN: How the Runtime Locates Assemblies
Hope this helps!
Trent
06-04-2019 03:01 PM
Hi,
I want to check with you if your issue was resolved, I am currently having little trouble with the System_EventHandler_T1_Create(), and I am suggested the same solution, would you be open in sharing your piece of snippet which contains this function, I am unaware about the function specific name for TEventArgs. I am attaching my piece of code with using function. Your help is appreciated. Thanks!
06-05-2019 01:04 AM
Unfortunately, I don't have the test case i used handy.
Like i mentioned above, you should check the control help in the function panel. You can see the help topic for a specific parameter by right clicking on the parameter in the function panel. TEventArgs should include something like this:
"If the type you pass is defined in mscorlib or in the target assembly, then you can just pass the full name of the type. If not, you must pass the assembly-qualified name of the type, that is, the full name of the type followed by the assembly information, separated by a comma."
You should try this and add error handling to catch exceptions - in your case, it should look something like:
int status; CDotNetHandle excptHdl; status = System_EventHandler_T1__Create (&CommStateChangedHandler, "MyCimetrix.ComStateChangedEventArgs, MyCimetrix", CommStateChanged, NULL, &excptHdl);
That's assuming the name of your assembly is "MyCimetrix.dll" and is located in the same directory as the executable. If the function returns an error, try using the CDotNet library to get the exception info.
Trent
06-05-2019 08:56 AM
Hi Trent,
Thanks for your response. I decided to put your code of lines in my callback of Set Value, put a break point to see if there is any value to CommStateChangedHandler, initially I got uninitialized and then I declared it as a zero, I got NULL value later, do you think you could suggest in terms of how to initialize? Attaching a pic here, Again thanks for any help and suggestion.
-Riddhi
06-06-2019 06:43 AM
I finally figure out what was the problem calling the event handler: in order to be recognized the TEventArgs must be provided with the fully string describing the assembly as in the following example.
System_EventHandler_T1__Create(&myRobot.ChangedConnectionStateHandle, "ABB.Robotics.Controllers.ConnectionChangedEventArgs,ABB.Robotics.Controllers.PC, Version=6.2.6753.1029, Culture=neutral, PublicKeyToken=null", ConnectionChanged, NULL, &ExceptionHandle) ;
Thank you everyone for the support.
06-06-2019 08:34 AM
Hi,
Can you please specify, what would is myrobot here, so I can connect the same information in my code? Or if you can share your snippet of code that will be nice.
Thanks,
Riddhi