我将一个 ASP.NET 应用程序 DLL 复制到 \Inetpub\wwwroot\bin 并复制了 Sharepoint 2007 TEMPLATES\Layouts 文件夹下的应用程序文件夹,这样我就可以从http://sp-portal/sites/sitecoll123/_layouts/aspnetapp/Default.aspx
. 它抱怨说:
Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
然后我将 DLL 安装到 GAC(从 \inetpub\wwwroot\bin 文件夹中删除它之后),它无法加载 DLL。它抱怨说:
Could not load type 'AppNS.Default'. at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError)
然后,我将 DLL 复制回 \Inetpub\wwwroot\bin,同时仍将程序集安装在 GAC 中。只有这样它才起作用!我无法解释这一点......我认为将它放在 GAC 中是让程序集易于访问的快速而肮脏的方式。为什么需要在这两个地方?这是安装在 Sharepoint/MOSS 2007 中的 _layouts 下的 ASP.NET 3.5 应用程序。