System.Security.SecurityException: That assembly does not allow partially trusted callers.

Posts   
 
    
matlaf
User
Posts: 95
Joined: 25-Jan-2005
# Posted on: 05-Mar-2006 00:41:17   

Hi,

I have an exception when executing generated code on my ISP server.

System.Security.SecurityException: That assembly does not allow partially trusted callers.

The stacktrace :

[SecurityException: That assembly does not allow partially trusted callers.] Laf.Portail.Shared.LLBLGEN.DatabaseSpecific.DataAccessAdapter.CreateDynamicQueryEngine() +0 SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CreateSelectDQ(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfoObjects, IPredicateExpression filter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize) +19 SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollectionInternal(IEntityCollection2 collectionToFill, IRelationPredicateBucket& filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, Int32 pageNumber, Int32 pageSize) +771 SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchNewEntityInternal(IEntityFactory2 entityFactoryToUse, IRelationPredicateBucket& filterBucket, Context contextToUse) +202 SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchNewEntity(IEntityFactory2 entityFactoryToUse, IRelationPredicateBucket filterBucket, IPrefetchPath2 prefetchPath, Context contextToUse) +119 SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchNewEntity(IEntityFactory2 entityFactoryToUse, IRelationPredicateBucket filterBucket) +15 Laf.Portail.Shared.Managers.User.GetUtilisateurEntity(String nomutilisateur) +193

I read from different website that strong-named assembly cannot be called from partialy trusted assembly and most ISP run asp.net application from their costumer at partialy thrusted level.

A solution from microsoft is to add [assembly:AllowPartiallyTrustedCallers] in the assemblyinfo.cs.

http://msdn.microsoft.com/library/default.asp?url=/ ....

Do you think this solution add to LLBLGEN can solve my problem?

Thanks for your support service.

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 05-Mar-2006 02:26:11   

Hi

I have asked other members to provide feedback on this subject and am sure they will respond ASAP, but from a personal point of view, can you try it if it not not a big effort please.

Thanks.

matlaf
User
Posts: 95
Joined: 25-Jan-2005
# Posted on: 05-Mar-2006 02:53:06   

I cannot test all the problem.

The problem appear when an partially trusted assembly call a strong-named assembly.

The only test that I made it remove the spec of the strong-key in the assemblyinfo.cs of the LLBLGEN assembly and reupload them to my website.

After this all appear to be ok.

The real test is rebuild the library with strong-key spec and with the new attribute [assembly:AllowPartiallyTrustedCallers]. I cannot make this test since I do not have the strong-key file.

Thanks,

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 05-Mar-2006 04:42:30   

It is very unlikely that you will get a strong name key file from LLBLGen.

You can create one of your own using the Visual Studio command line tool.

Open the Visual Studio Command Prompt and enter sn -k yournewkeyfilename.snk

Then use that file to provide a strong name to the appropriate assembly.

matlaf
User
Posts: 95
Joined: 25-Jan-2005
# Posted on: 05-Mar-2006 05:21:07   

I know that I will no get the strong key of LLBLGEN wink . I just, with my test, restricted research on strong-named assembly while without strong key all is ok.

I read much article today. It seem you must add [assembly:AllowPartiallyTrustedCallers] when you strong-named an assembly and you want partial trusted assembly to access your code.

I think that the LLBLGEN support team will be able to confirm that.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 05-Mar-2006 10:06:58   

That attribute was added to the runtimes in the latest release. So if you run the latest runtime libraries, you'll have that attribute and you shouldn't have this problem anymore.

Frans Bouma | Lead developer LLBLGen Pro
changomarcelo avatar
Posts: 62
Joined: 15-Feb-2007
# Posted on: 15-Feb-2007 23:59:23   

Hi, I have a similar problem. I'm using a version of LLBLGenPro from november 2005. I can't tell you exactly which one because I'm travelling now and I don't have that app with me.

The exception I have is this:

Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.] System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) +0 System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) +270 System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) +163 System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) +192

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

Is this something LLBLGen pro is doing? How can I solve it? I can't buy a newer version now.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 16-Feb-2007 09:19:17   

You should download the latest build for v1.0.2005.1, it has the partialtrusted callers attribute applied to it.

Frans Bouma | Lead developer LLBLGen Pro
Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 16-Feb-2007 09:23:02   

From Frans's previous post, this seems to be solved in march 2006. I think you should download the latest release out there of the version that you are already using. You won't have to buy anything.