Link to home
Start Free TrialLog in
Avatar of OddiC
OddiC

asked on

CAS, .NET, and Assembly Calling Permissions... Why won't my permission.Assert() take?

I kept getting a SqlClientPermission error from a custom .NET component I built that calls a local database on my test server. After some research, I decided to use a SqlClientPermission object (code below), however, that has not resolved the issue.

Now (with the code below trying to grant my code Unrestricted access), I get the error:

"Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

All of my Zones are configured for Full Trust (via the 2.0 Framework Configuration Tool). I cannot figure out what the issue is. Any and all suggestion, references, and help are very greatly appreciated. There has got to be a way to fix this... but I can't see it!!!  :)

Thanks a ton in advance.
SqlClientPermission permission = new SqlClientPermission(PermissionState.Unrestricted);
            permission.Assert();

Open in new window

Avatar of OddiC
OddiC

ASKER

Addt'l Info that should help:

My component is being called from from an SSRS Report (it fails in ReportViewer control, ReportServer, and ReportManager interfaces/tools). It's being called from the <Code> section (the .dll is referenced by the report RDL).

Also, here is the full SqlClient Exception I got ((names omitted for anonymity)):

System.Security.SecurityException: 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)
   at System.Security.PermissionSet.Demand()
   at System.Data.Common.DbConnectionOptions.DemandPermission()
   at System.Data.SqlClient.SqlConnection.PermissionDemand()
   at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.SqlClient.SqlConnection.Open()
   at MyClass.MyMethod.GetData() in C:\Documents and Settings\Me\My Documents\Visual Studio 2008\Projects\MyProj\MyReportProj\GetDataSource cs:line 117
The action that failed was:
Demand
The type of the first permission that failed was:
System.Data.SqlClient.SqlClientPermission
The Zone of the assembly that failed was:
MyComputer
ASKER CERTIFIED SOLUTION
Avatar of James Murrell
James Murrell
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of OddiC

ASKER

Thanks for the tip- but I had already tried adjusting CAS policies and zone trust settings to no avail.. ugh! Luckily, I found a *temporary* solution. I edited the rsservpolicy.config file, added a Full Trust (local) permission policy, and applied that policy to all of SSRS.

Obviously this is a security hazard and not the ideal solution.

Does anyone out there know how I could set similar security to allow my custom component (located in the SSRS Repert Server bin folder) to work?

All help is very much appreciated!