Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

Commented Issue: Access issue creating worksheet [11383]

$
0
0
The following error occurs when we try to create a worksheet. The issue is resolved by setting IIS 7.0 LoadUserProfile to true. We are trying to understand why this is needed and teh secruity implications and if there is a workaround to make this work without having to change the default IIS setting<br><br><br>System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. <br>at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&amp; stackMark, Boolean isPermSet) <br>at System.Security.CodeAccessPermission.Demand() <br>at System.Environment.get_UserName() <br>at NPOI.HSSF.Model.InternalWorkbook.CreateWriteAccess() <br>at NPOI.HSSF.Model.InternalWorkbook.CreateWorkbook() <br>at NPOI.HSSF.UserModel.HSSFWorkbook..ctor() <br>at ....<br><br>The action that failed was: <br>Demand <br>The type of the first permission that failed was: <br>System.Security.Permissions.EnvironmentPermission <br>The first permission that failed was: <br><br>version=&quot;1&quot; <br>Read=&quot;UserName&quot;/&gt; <br><br>The demand was for: <br><br>version=&quot;1&quot; <br>Read=&quot;UserName&quot;/&gt; <br><br>The granted set of the failing assembly was: <br><br>version=&quot;1&quot;&gt; <br><br>version=&quot;1&quot; <br>Access=&quot;Open&quot;/&gt; <br><br>version=&quot;1&quot; <br>Allowed=&quot;ApplicationIsolationByUser&quot; <br>UserQuota=&quot;512000&quot;/&gt; <br><br>version=&quot;1&quot; <br>Flags=&quot;Execution&quot;/&gt; <br><br>version=&quot;1&quot; <br>Window=&quot;SafeTopLevelWindows&quot; <br>Clipboard=&quot;OwnClipboard&quot;/&gt; <br><br>version=&quot;1&quot; <br>PublicKeyBlob=&quot;002400000480000094000000060200000024000052534131000400000100010095CCD95AF3B39D8BC20544D3F47FD24B53EBC5CCB693EAED116290629F8CD882C827EBD511AD59449224F0718D3F9D03B64945A6C8B6644266001B8C8426185330E3D96DA70AE16D4ACC21B8D4D480F1385C7E924273179375AA88F81380A72FB115712A313379D16AED4AA36208EE3B4A5DD785B06A07B2D868E3227F4495B5&quot; <br>Name=&quot;NPOI&quot; <br>AssemblyVersion=&quot;1.2.5.0&quot;/&gt; <br><br>version=&quot;1&quot; <br>Url=&quot;file:///c:/xxx/web/bin/NPOI.DLL&quot;/&gt; <br><br>version=&quot;1&quot; <br>Zone=&quot;Internet&quot;/&gt; <br><br>version=&quot;1&quot; <br>Level=&quot;SafePrinting&quot;/&gt; <br><br><br>The assembly or AppDomain that failed was: <br>NPOI, Version=1.2.5.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1 <br>The method that caused the failure was: <br>NPOI.HSSF.Record.Record CreateWriteAccess() <br>The Zone of the assembly that failed was: <br>Internet <br>The Url of the assembly that failed was: <br>file:///c:/xxx/web/bin/NPOI.DLL <br>--- End of inner exception stack trace --- <br>at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct&amp; sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) <br>at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) <br>at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) <br>at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) <br>at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) <br>at ...
Comments: ** Comment from web user: tonyqus **

This should be a bug in NPOI 1.2.5 because the wrong exception is catched.
private static Record CreateWriteAccess()
{
WriteAccessRecord retval = new WriteAccessRecord();

try
{
retval.Username=(Environment.UserName);
}
catch ( AccessViolationException)
{
// AccessControlException can occur in a restricted context
// (client applet/jws application or restricted security server)
retval.Username=("POI");
}
}
AccessViolationException is not the correct exception to be catched. Instead, SecurityException should be used. This bug will be fixed in NPOI 2.0.


Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>