LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why am I getting Error 1172 when trying to invoke .NET assembly?

If the vi and the .NET assembly are on a network drive (mapped to a drive letter), I get Error 1172. If they are on my local hard drive there is no problem. Why? The .NET philosophy is that it shouldn't matter where things reside.

Rich
0 Kudos
Message 1 of 10
(19,574 Views)
There are two things you have to do to when using a mapped drive:

  • Make sure that you saved the VI in the same directory as the .NET assembly and that you have added the .NET assembly as a reference to LabVIEW.

  • Increase Assembly Trust of the assembly DLL and the executable on the network drive.

Best Regards,
Philip C.
Applications Engineer
National Instruments
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
Message 2 of 10
(19,571 Views)
Thank you, Philip. I do have the vi in the same directory as the .NET assembly, and the assembly has been added as a reference to LabVIEW. How do I increase Assembly Trust? I created the assembly using the LabVIEW .NET browser that I downloaded from NI. It has no options, just a button to create the assembly.
0 Kudos
Message 3 of 10
(19,571 Views)
Hi Richard,

Here�s a KnowledgeBase describing the procedure of increasing Assembly Trust.

Good luck!

Best regards,
Philip C.
Applications Engineer
National Instruments
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 4 of 10
(19,572 Views)
I am having this exact problem as well.  The Vi works great on my computer but once I moved it to the network it no longer works.  I have referenced the .dll but when I try to increase assembly trust it says "Unable to load assembly" .... any ideas??
0 Kudos
Message 5 of 10
(18,883 Views)
How exactly are you increasing assembly trust?

What version of LV are you using?

If you have LV 8+, then you can get more detailed information on the error (maybe not in this case...but worth a shot) by getting debugview (http://www.microsoft.com/technet/sysinternals/Miscellaneous/DebugView.mspx) and running that when you try to run your VI. It captures the full .NET Exception and dumps it out.
0 Kudos
Message 6 of 10
(18,859 Views)
And also check out

http://detritus.blogs.com/lycangeek/2005/05/network_paths_a.html

0 Kudos
Message 7 of 10
(18,857 Views)
This Vi is running LV 7.1 and I have attempted to increase trust using the mscorcfg.msc as directed in the NI knowledgebase article for this problem but that throws up an "Unable to load assembly" error.  I also checked out your webpage and used the caspol.exe as shown below
 
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>caspol -q -machine -addgroup 1 -url
 file://E:/* FullTrust -name "Process Flow"
Microsoft (R) .NET Framework CasPol 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
Added union code group with "-url" membership condition to the Machine level.
Success
 
I was hoping the VI would now work correctly but I am still receiving the same error!
Error 1172
Exception has been thrown by the target of an invocation. >> Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. in Process Flow.vi
 
Any ideas?
 
Thanks for the help!
0 Kudos
Message 8 of 10
(18,846 Views)
I'm afraid I'm not sure where to go from this point. I tried doing some web searching on the error message, and it's all about playing around with the various security settings and demands - running code on a network share is apparently one of the more complicated things to do on .NET.

It might be easier to try to create a simple .EXE from C#/VB to load your assembly as a test case and get more detailed exception messages (7.1 doesn't support the debug dumping).
0 Kudos
Message 9 of 10
(18,830 Views)

Matt,

Is the assembly that you created a private or shared assembly?  A private assembly will allow access by a single application, where a shared can be used by multiple applications.  By default, when a .NET program is compiled, the assembly produced will be a private assembly. This assembly needs to be placed in the same folder as the calling application.

Shared assemblies are placed in the Global Assembly Cache. This Global Assembly Cache stores .NET assemblies specifically designated to be shared by several applications on that computer. If you are calling your .NET Assembly Reference from a network drive, I believe you will need to make it a shared assembly.

This Microsoft KB discusses the differences and how to install a shared assembly:

http://support.microsoft.com/default.aspx?scid=kb;en-us;315682

You can also see the following post which discusses this issue as well:

http://forums.ni.com/ni/board/message?board.id=170&message.id=90149&requireLogin=False

I hope this helps.  Have a great day.

Brian Coalson

Software Engineer
National Instruments
0 Kudos
Message 10 of 10
(18,806 Views)