views:

64

answers:

2

Hi,

I have a web part and the dll is deployed to the bin of the web application.I have created a custom cas policy and deployed( wss_custom). Just for the sake of testing i have given Unrestricted access to whatever IPermission i knew (around 10). Most of the IPermissions i got is from the PermCalc.exe. Yet i get the following error generated by the web part:

System.Security.Policy.PolicyException

The problem is that i am not able to determine as to what permission is required to be given in the custom cas file.

Appreciate your suggestions.

Thanks

+1  A: 

Hi Taha

My general advice to find which CAS permissions you need are:

Give your dll SecurityPermission(ControlEvidence = true, ControlPolicy = true) (and of cause also Execution = true and what else you might need)

Catch the Exception and output Exception.ToString() not only Exception.Message

Then you should get a precise listing of the first Permission that failed, add that and try again.

Per Jakobsen
Hi Per,Thanks for your reply.But i guess the dll the exception occurs when the dll is getting loaded and therefore the exception cannot be caught in the code.Might be i have not fully understood your reply. Request you to provide more information.In my current case, the web part dll does not ask for any permission(in the assembly info) and everything is granted through a custom cas file
Faiz
Hi Taha, Usually the exception doesn't occur until the method requiring the permission is called.So make sure that the overloaded methods CreateChildControls, RenderContent, ... that you use only contains a try catch outputting error and a call to a helper method doing the real stuff and you should be able to get traces you need
Per Jakobsen
Thanks Perk.Your first comment did help to an extent.However i just wanted to add that we have to set the Full Trust in the web.config to catch the exact permissions required and once successfully created the cas, make entry for the custom trust level in web.config
Faiz
That helped.thanks
Faiz
A: 

Try to enable logging of .net assembly loader and see what happens with "fuslogvw.exe" tool (see http://msdn.microsoft.com/en-us/library/e74a18c4(VS.80).aspx for more details)

naivists
Hi,Thanks. id ran the tool fuslogvw.exe and the last statement in the log is Assembly is loaded in default load context.
Faiz