第三方 DLL 上的 Asp.net FileIOPermission 异常

发布于 2024-11-28 13:05:28 字数 4204 浏览 3 评论 0原文

我在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲影 2024-12-05 13:05:28

我已通过将程序集添加到 GAC 来解决此问题。

 > gacutil -i Npgsql.dll

I have fixed this issue by adding the assembly to GAC.

 > gacutil -i Npgsql.dll
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文