I upgraded to VS 2010 when it was released, and just got around to upgrading my main website to .Net 4. But the blog engine running under the mainsite now fails with security exceptions.
This one's down to me! Please accept my apologies for this - I'll see to it that the developer responsible for this happening is given 20 lashes (but only after he or she has fixed this problem).
Url : http://localhost:13769/blog/post.aspx?id=b0e88e4b-8549-4ac7-b00d-e84dc8ba1331
Raw Url : /blog/post.aspx?id=b0e88e4b-8549-4ac7-b00d-e84dc8ba1331
Message : Exception of type 'System.Web.HttpUnhandledException' was thrown.
Source : System.Web
StackTrace : at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.post_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\blog\a38b0af3\f6b053f3\App_Web_ed0f0zsp.12.cs:line 0
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
TargetSite : Boolean HandleError(System.Exception)
Message : Attempt by security transparent method 'Controls.RelatedPosts..ctor()' to access security critical method 'Resources.labels.get_relatedPosts()' failed. Assembly 'App_Code.wuwqmmjh, Version=22.214.171.124, Culture=neutral, PublicKeyToken=null'
is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause
of this exception
It looks like .Net 4 doesn't like the way that the labels and resources are loaded for some reason. I already tried to set the security level back to the "legacy" security for 2.0, but that didn't solve the problem.
Anytime you go to pull a resource like this:
private string _Headline = Resources.labels.relatedPosts;
It will blow up with that exception.
I have already rebuilt the main core library under .Net 4. It required changes for the security in .Net 4:
Added to assembly info:
Anyone else have any ideas? Or is it only going to support .Net 2?