Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebookSDK - AllowPartiallyTrustedCallers Problem
    primarykey
    data
    text
    <p>I'm using the latest version of the FacebookSDK (4.0.2) (facebooksdk.codeplex.com)</p> <p>And I noticed the Src code is made up of several projects namely:</p> <p>1)</p> <p>Samples -> Facebook.Samples.AspWebsite Project<br/> Samples -> Facebook.Samples.MvcFacebookApp Project<br/> Samples -> Facebook.Samples.MvcWebsite Project<br/></p> <p>2)</p> <p>Tests -> Facebook.Tests<br/> Tests -> Facebook.Web.Tests<br/></p> <p>3)</p> <p>Facebook Project<br/> Facebook.Web Project<br/> Facebook.Web.Mvc Project<br/></p> <p>Okay, so I am building a Facebook Canvas .Net 4.0 MVC 2 application and am simply using the Facebook.Samples.MvcFacebookApp Project and replacing and adding classes and files as I see fit for my situation. However I have come to the point where my site will be running on a Microsoft Azure cloud and I want to abstract the data layer (database) into it's Project. So I went ahead and created a new Project in the solution called BusinessData and added an EntityDataModel to it, so now the solution looks like this:</p> <p>1)</p> <p>Samples -> Facebook.Samples ...<br/></p> <p>2)</p> <p>Tests -> Facebook.Tests ...<br/></p> <p>3)</p> <p>Facebook Project<br/> Facebook.Web Project<br/> Facebook.Web.Mvc Project<br/> BusinessData Project<br/> -> Business.edmx<br/><br/></p> <p>Great so now I add a reference to the BusinessData Project to my Facebook.Samples.MvcFacebookApp Project and try and access my database. However I get this error in my TrackUserAttribute.cs class in the Facebook.Samples.MvcFacebookApp Project:</p> <pre> <code> System.MethodAccessException occurred Message=Attempt by security transparent method 'Facebook.Samples.MvcFacebookApp.Models.TrackUserAttribute..ctor()' to access security critical method 'BusinessData.BusinessEntities..ctor()' failed. Assembly 'Facebook.Samples.MvcFacebookApp, Version=4.0.2.0, 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. Source=Facebook.Samples.MvcFacebookApp StackTrace: at Facebook.Samples.MvcFacebookApp.Models.TrackUserAttribute..ctor() in C:\Users\rkara\Desktop\FacebookPazooza\ThuziFacebookSDK\Source\Src\Facebook.Samples.MvcFacebookApp\Models\TrackUserAttribute.cs:line 13 InnerException: </code> </pre> <p>After some uneventful research and not being fully understood about CAS Policy and how that has evolved with ASP.Net 4.0 my understanding is that the GlobalAssemblyInfo.cs file contained within all of the projects of the FacebookSDK solution has something to do with it.</p> <p>This line of code in the GlobalAssemblyInfo.cs file:</p> <pre> <code> #if !(SILVERLIGHT || TESTS) [assembly: AllowPartiallyTrustedCallers] #endif </pre> <p></code></p> <p>seems to be the culprit. According to this Microsoft expert:</p> <p><a href="http://www.simple-talk.com/dotnet/.net-framework/whats-new-in-code-access-security-in-.net-framework-4.0---part-i/" rel="nofollow">http://www.simple-talk.com/dotnet/.net-framework/whats-new-in-code-access-security-in-.net-framework-4.0---part-i/</a></p> <p>BusinessData has SecurityCritical level privileges. My class TrackUserAttribute.cs only has SecurityTransparent, so therefore cannot does not have privileges to invoke methods in the BusinessData assembly. Is this correct?</p> <p>I've tried all sorts of things to get this thing to work even removing [assembly: AllowPartiallyTrustedCallers] from the GlobalAssemblyInfo.cs file, but I get another problem with the .edmx file itself saying it can't load the metadata, so I assume it still has something to do with full trust privileges etc.</p> <p>I am sure there is a simple answer to this and am sure the guys who developed this SDK wrapper would have consider the fact that people will be extending their SDK to suit individual needs.</p> <p>What is the best approach for me to ensure abstraction of my data and anything else I want to abstract without having to tie it into the projects provided?</p> <p>For now and to continue with development and not be tied up in this for too long I've just stored my entity model (edmx) into the models folder of the Facebook.Samples.MvcFacebookApp. This works for now but I would much rather store the edmx in its own project.</p> <p>Cheers Rob</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload