LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"FileIOPermission" Exception in LabVIEW when using .NET

I am trying to implement a NUnit test runner for LabVIEW. When I load an assembly into the test domain, I get the following exception message:

Error 1172 occurred at Error calling method NUnit.Util.TestDomain.Load of ObjectId handle: 0x6971178 for obj 0x2F09900[NUnit.Util.TestDomain] in domain [LabVIEW Domain for Run] and thread 5528 >> Exception has been thrown by the target of an invocation. >> Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. in LoadTest.vi

I probably have to set permission for the calling assembly. I tried the following (but it didn't work):

[assembly: PermissionSetAttribute(SecurityAction.RequestMinimum, Name = "FullTrust")]

If somebody has an idea how to handle a FileIOPermission exception, please let me know.

Thanks
Frank


0 Kudos
Message 1 of 3
(5,025 Views)
Well, I'm not sure the root cause or exactly what the context is. One thing you can do is go to www.sysinternals.com and download the Debug Viewer (dbgview.exe). When we get a .NET exception like that, we output to the debug stream the entire exception, including the stack trace.
 
Are any of the assemblies on a network drive? That affects what permissions they are allowed.
 
Also, do you know what file you're trying to access (location, permission requirements)?
 
I'm also assuming Windows XP...is that correct?
0 Kudos
Message 2 of 3
(5,012 Views)
Hello Brian,

thanks for the hint with the dbgview.exe. Meanwhile I got a workaround. Instead of instantiating TestDomain, I instantiate SimpleTestRunner. Now I can call my NUnit tests from LabVIEW (Yeah!!). But I would really like to know why I can't load an assembly in the TestDomain Runner. A console Application is running the tests, the same code in LabVIEW is not. To clarify things I added a zip file with a complete Test Project. The bin directory contains two TestRunners. They both run the tests in "NUnitTest.dll" and they both work. In the directory NUnitRunner_LV, there are two VIs ("NUnitSimpleTestRunner.vi" and "NUnitTestDomain.vi"). They do almost exactly the same as the console applications, but the TestDomain runner is not working. It brings up the earlier described exception.

I am using Windows XP, and tried it with LabVIEW 8.0.1 and 8.20

I found an article about .NET CAS on the code project: "http://www.codeproject.com/dotnet/UB_CAS_NET.asp" maybe I can find a solution there. If you are interested and find something out, please let me know. But it is not really important to me anymore since I have a workaround.

Thanks for your help

Frank

Here is the complete exception message:

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib,

Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
   at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
   at System.Security.CodeAccessPermission.Demand()
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark,

Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue,

AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence securityEvidence)
   at System.Activator.CreateInstanceFrom(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder

binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
   at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)
   at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, String typeName)
   at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, String typeName)
   at NUnit.Util.TestDomain.MakeRemoteTestRunner(AppDomain runnerDomain)
   at NUnit.Util.TestDomain.Load(String assemblyFileName, String testFixture)
   at NUnit.Util.TestDomain.Load(String assemblyFileName)
   at Input3Module.Main(String[] argv) in C:\Dokumente und Einstellungen\Frank\Desktop\input3:line 8
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.FileIOPermission
The first permission that failed was:
<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral,

PublicKeyToken=b77a5c561934e089"
version="1"
Read="C:\Programme\NUnit 2.4 (Beta 1) for .Net 2.0\bin\nunit.core.dll"
PathDiscovery="C:\Programme\NUnit 2.4 (Beta 1) for .Net 2.0\bin\nunit.core.dll"/>

The demand was for:
<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral,

PublicKeyToken=b77a5c561934e089"
version="1"
Read="C:\Programme\NUnit 2.4 (Beta 1) for .Net 2.0\bin\nunit.core.dll"
PathDiscovery="C:\Programme\NUnit 2.4 (Beta 1) for .Net 2.0\bin\nunit.core.dll"/>

The granted set of the failing assembly was:
<PermissionSet class="System.Security.PermissionSet"
version="1"/>

The assembly or AppDomain that failed was:
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

0 Kudos
Message 3 of 3
(5,004 Views)