LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET Unable to find assembly error

Solved!
Go to solution

Hi all,

I'm developing some instrument API using .NET assembly wrapper. I use CVI2015sp1. When I'm trying to run a certain function from that assembly I get an exception of "Unable to find assembly 'AssemblyName, Version=val, Culture=val, PublicKeyToken=val" - I get this error after initializing the assembly, and running some functions from it.

I used the CDotNetRegisterAssemblyPath to register my assembly path - it didn't work.

I tried to recompile my wrapper source file since I remembered that I have changed the dll to a higher version. I did the following steps:

RightClick on *.fp -> Edit Instrument -> Detach Program -> Attach And Edit Source ---> It compiles the source file - and reports a succes. 

Then I rebuild my entire project and trying to run the function - but still have the same error. 

In my wrapper *.h  file the assembly info looks like that 

//// ->  CVI wrapper header file for .NET assembly: TlaNetInterfaces, Version=6.1.127.0, Culture=neutral, PublicKeyToken=null <- ////  Same name in *.c file.

But error message says that it can't find  assembly 'tla700, Version=6.1.127.0, Culture=neutral, PublicKeyToken=null' 

 

I tried to change the assembly name in wrapper source code - to tla700 instead of TlaNetInterfaces, recompiled in a same way as described above - but it failed to load the assembly itself at the beging. 

 

What do I miss here? 

0 Kudos
Message 1 of 7
(9,968 Views)

Hey ArtB83,

 

Does this example work for you?? I think it is similar to your setup.

Ren H.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 7
(9,916 Views)

Helllo RenKylo2,

Thank you very much, I appreciate your help. I viewed your code example, and I think it doesn't help to solve my problem.

In my program, the assembly file is located within the same directory with the executable and project sources. 

My project runs fine with many other functionalities of that assembly file, until I invoke 1 specific function, and it returnes with an exception that was described in my original post. 

My assembly file details are as following :

In wrapper header file : CVI wrapper header file for .NET assembly: TlaNetInterfaces, Version=6.1.127.0, Culture=neutral, PublicKeyToken=null

In wrapper source file - assembly name is declared as following : static const char * __assemblyName = "TlaNetInterfaces, Version=6.1.127.0, Culture=neutral, PublicKeyToken=null";

And this is the name that used in CDotNetLoadAssembly() function.

When I run my problematic method - the popup error says: Unable to find assembly 'tla700, Version=6.1.127.0, Culture=neutral, PublicKeyToken=null' 

I tried the following steps to solve the problem:

1. Rename my assembly file to tla700.dll - recompile - run - failed to initialize the assembly at the very begining. 

2. Rename the assembly file to tla700.dll and declare different assembly name in a source file - so I gave it a new name - "tla700, Version=6.1.127.0, Culture=neutral, PublicKeyToken=null"; - recompile - run - it also failed to initialize the assembly. 

3. Turned back to the original names - I am able to initialize the assembly file, run many other different functions from it - until I get to the specific one that fails.

 

How do I invoke the function:

1. The problematic method belongs to PARENT class, that uses its instance in order to run. In my case, I perform upcast to a CHILD instance - and invoke the method. As far as I know, upcasting child to its parent class should not be a problem. 

2. I tried to invoke with an upcasted child handle that was NULL - and I got an error of uninitialized handle - as probably expected - but NOT THE ASSEMBLY ERROR.

 

What do I miss, or how can I fix that problem?

0 Kudos
Message 3 of 7
(9,901 Views)

Hey ArtB83,

 

Thanks for the clarification. That is strange. Can you send me your CVI project and the assembly?

 

If you call this with C in Visual Studio, do you see similar behaviour?

Ren H.
Applications Engineering
National Instruments
0 Kudos
Message 4 of 7
(9,880 Views)

Hey Ren,

I didn't try it in Visual Studio, I didn't think of that idea yet. 🙂 Thanks for mentioning. 

Regarding the project itself, before you can run anything from that project, you have to install Tektronix software. 

from here ->  

http://www.tek.com/tla5201-software-0

And then run it in offline mode. It should look like in the attached pic after you install it. 

I will arrange the project issue soon.

0 Kudos
Message 5 of 7
(9,870 Views)

If we are already talking, could you please take a look into enother thread of mine? 🙂 

 

http://forums.ni.com/t5/LabWindows-CVI/Managing-NET-handles-and-instances/m-p/3574901

0 Kudos
Message 6 of 7
(9,864 Views)
Solution
Accepted by ArtB83

Hi Ren,

I have received an answer from Tektronix regarding the problematic method, they report that it returns NULL ptr, when they try to invoke it in VS environment. So the problem probably came from a bug in .NET source code itself, or most likely, it is impossible to invoke that method as a remote client, as I intend to do it. Anyway, it did not come from my CVI wrapper.

 

Best Regards

0 Kudos
Message 7 of 7
(9,833 Views)