第三方 DLL 上的 Asp.net FileIOPermission 异常
我在我的 asp.net 项目(Server 2008,VS2008)中使用 Npgsql.dll。我的开发环境是服务器 2003 和 VS 2008。这个 dll 在我的开发环境中运行良好,但是当我在生产中发布它时,它会抛出以下异常:
System.TypeInitializationException: The type initializer for 'Npgsql.NpgsqlConnectionStringBuilder' threw an exception. ---> 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.VerifyCodeBaseDiscovery(String codeBase)
at System.Reflection.Assembly.GetName(Boolean copiedName)
at Npgsql.NpgsqlConnectionStringBuilder..cctor()
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"
PathDiscovery="C:\inetpub\wwwroot\MENU_MDS\MWareAuthService\bin\Npgsql.DLL"/>
The demand was for:
<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
PathDiscovery="C:\inetpub\wwwroot\MENU_MDS\MWareAuthService\bin\Npgsql.DLL"/>
The granted set of the failing assembly was:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.FileDialogPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Access="Open"/>
<IPermission class="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Allowed="ApplicationIsolationByUser"
UserQuota="512000"/>
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Execution"/>
<IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Window="SafeTopLevelWindows"
Clipboard="OwnClipboard"/>
<IPermission class="System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
PublicKeyBlob="00240000048000009400000006020000002400005253413100040000010001002B3C590B2A4E3D347E6878DC0FF4D21EB056A50420250C6617044330701D35C98078A5DF97A62D83C9A2DB2D072523A8FC491398254C6B89329B8C1DCEF43A1E7AA16153BCEA2AE9A471145624826F60D7C8E71CD025B554A0177BD935A7809629F0A7AFC778EBB4AD033E1BF512C1A9C6CEEA26B077BC46CAC93800435E77EE"
Name="Npgsql"
AssemblyVersion="2.0.5.0"/>
<IPermission class="System.Security.Permissions.UrlIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Url="file:///C:/inetpub/wwwroot/MENU_MDS/MWareAuthService/bin/Npgsql.DLL"/>
<IPermission class="System.Security.Permissions.ZoneIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Zone="Internet"/>
<IPermission class="System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
version="1"
Level="SafePrinting"/>
</PermissionSet>
The assembly or AppDomain that failed was:
Npgsql, Version=2.0.5.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7 The Zone of the assembly that failed was:
Internet
The Url of the assembly that failed was:
file:///C:/inetpub/wwwroot/MENU_MDS/MWareAuthService/bin/Npgsql.DLL
--- End of inner exception stack trace ---
at Npgsql.NpgsqlConnectionStringBuilder..ctor(String connectionString)
at Npgsql.NpgsqlConnection..ctor(String ConnectionString)
at MWareAuthService.MWareAuthService.Login(String username, String password, String ipaddress)
我将非常感谢对此问题的任何帮助。
I am using Npgsql.dll in my asp.net project (Server 2008, VS2008). My dev environment is server 2003 and VS 2008. This dll works fine on my dev environment, but when I publish this on production, it throws following Exception:
System.TypeInitializationException: The type initializer for 'Npgsql.NpgsqlConnectionStringBuilder' threw an exception. ---> 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.VerifyCodeBaseDiscovery(String codeBase)
at System.Reflection.Assembly.GetName(Boolean copiedName)
at Npgsql.NpgsqlConnectionStringBuilder..cctor()
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"
PathDiscovery="C:\inetpub\wwwroot\MENU_MDS\MWareAuthService\bin\Npgsql.DLL"/>
The demand was for:
<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
PathDiscovery="C:\inetpub\wwwroot\MENU_MDS\MWareAuthService\bin\Npgsql.DLL"/>
The granted set of the failing assembly was:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.FileDialogPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Access="Open"/>
<IPermission class="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Allowed="ApplicationIsolationByUser"
UserQuota="512000"/>
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Execution"/>
<IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Window="SafeTopLevelWindows"
Clipboard="OwnClipboard"/>
<IPermission class="System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
PublicKeyBlob="00240000048000009400000006020000002400005253413100040000010001002B3C590B2A4E3D347E6878DC0FF4D21EB056A50420250C6617044330701D35C98078A5DF97A62D83C9A2DB2D072523A8FC491398254C6B89329B8C1DCEF43A1E7AA16153BCEA2AE9A471145624826F60D7C8E71CD025B554A0177BD935A7809629F0A7AFC778EBB4AD033E1BF512C1A9C6CEEA26B077BC46CAC93800435E77EE"
Name="Npgsql"
AssemblyVersion="2.0.5.0"/>
<IPermission class="System.Security.Permissions.UrlIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Url="file:///C:/inetpub/wwwroot/MENU_MDS/MWareAuthService/bin/Npgsql.DLL"/>
<IPermission class="System.Security.Permissions.ZoneIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Zone="Internet"/>
<IPermission class="System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
version="1"
Level="SafePrinting"/>
</PermissionSet>
The assembly or AppDomain that failed was:
Npgsql, Version=2.0.5.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7 The Zone of the assembly that failed was:
Internet
The Url of the assembly that failed was:
file:///C:/inetpub/wwwroot/MENU_MDS/MWareAuthService/bin/Npgsql.DLL
--- End of inner exception stack trace ---
at Npgsql.NpgsqlConnectionStringBuilder..ctor(String connectionString)
at Npgsql.NpgsqlConnection..ctor(String ConnectionString)
at MWareAuthService.MWareAuthService.Login(String username, String password, String ipaddress)
I will really appreciate any help on this matter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已通过将程序集添加到 GAC 来解决此问题。
I have fixed this issue by adding the assembly to GAC.