08-31-2009 01:00 PM
Got a VI that calls a .net exe, if I have Labview 8.2 adapter in development mode this application gets launched and works fine, if I change the adapter to runtime it fails when trying to load the application, I have tried several things that I found on the message boards but none has fixed this problem.
Please take a look at the attachment, this error happens after the first step in the vi gets executed, frmMain.show() function seems to be the one triggering the error.
Thank's in advance;
Jorge
09-01-2009 02:32 PM
It sounds like you are missing an assembly your assembly depends on. Keep in mind that .NET looks in the directory of the .EXE for the process in which it's running. When using the labview development environment that directory is the LabVIEW.exe's directory, but when you use the runtime it is the directory of the sequence editor or user interface. Do you know what assemblies your assembly depends on? Where are the located? Also what version of LabVIEW are you using?
Hope this helps,
-Doug
09-01-2009 03:14 PM
Thank's for your reply, Doug.
I have actually being doing some more investigation on this and yes, it truns out there are some dll's that got used by this assembly, I was just wondering where should these be located when running in runtime mode, but you just answer this quiestion, so let me try it and post the results later today.
Thank's again,
Jorge
09-01-2009 05:45 PM - edited 09-01-2009 05:55 PM
Here is more information from Microsoft on how the .NET framework locates assemblies:
http://msdn.microsoft.com/en-us/library/yx7xezcf%28VS.80%29.aspx
It's quite a bit more complicated that just looking in the application directory. Also, if your assembly is using LoadFrom to dynamically load other assemblies there are special rules for that as well.
In the simplest case, it checks the GAC first, if it's not in the GAC it looks in the applicationbase directory. But this behavior can be altered by configuration files and various other special cases.
NOTE: The TestStand dotnet adapter uses LoadFrom to load assemblies that are specified that are not in the GAC. When using LoadFrom, the .NET framework will also look for assemblies on which the loaded assembly depends in the loaded assembly's directory.
Hope this helps,
-Doug
09-02-2009 01:56 PM
Yes, I have done some more testing and I think it is more an issue of .Net than runtime, I got a hold of a document that explains what references need to be accessible for the assembly to work propperly but the exeample is for Visual so I'm still trying to figure how to set this references in TestStand.
I have attached a couple of attachments, one is a snapshot of the document, and the other is a .NET action step that does the same calls as the VI and returns the same error.
Thank's for your replies.
Jorge
09-03-2009 08:55 AM
commonLib and TCMD are the ones that matter. The system assemblies are in the GAC and should be found. commonLib and TCMD are probably your own custom assemblies and likely need to be in one of three places. Try the following and see which works and choose the one that's best for you.
1) Try putting them in the same directory as the assembly you are calling directly from TestStand or LabVIEW. If commonLib or TCMD depend on any other assemblies that aren't in the GAC then they will need to be added to this directory as well. This goes for all of the options really.
2) Try putting them in the same directory as the application (the .exe file which loads them).
3) If they are strongnamed (if they have public key) you can try installing them to the GAC.
Hope this helps,
-Doug
09-03-2009 08:58 AM - edited 09-03-2009 09:04 AM
In looking at the error message more carefully. The problem you are seeing might be due to custom loading of assemblies dynamically by your code. The loadplugins method of your assembly's code in the error message is not a standard thing. You might need to look at that code more carefully or ask the person who developed it what the requirements are.
Also, perhaps you should be using a call executable step to launch your exe rather than using the dotnet interop code of either labview or teststand. I strongly suspect the assembly is meant to be launched as an exe and not called directly as a subsidiary assembly as you are doing now.
-Doug
09-09-2009 01:34 PM