Security Exception

Topics: Data Access Application Block
Dec 29, 2009 at 6:57 AM

Hi

When I try to call this from my App code

Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase();

I have the following exception

Security Exception

<!-- body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } -->

Server Error in '/Demos' Application.

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: That assembly does not allow partially trusted callers.

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: That assembly does not allow partially trusted callers.]
   Demo.DAL.Database..cctor() +0



Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

<!-- [SecurityException]: That assembly does not allow partially trusted callers. at Demo.DAL.Database..cctor() [TypeInitializationException]: The type initializer for 'Demo.DAL.Database' threw an exception. at Demo.DAL.Database.ReadAll(String stp) at Demo.DAL.ContactCategory.GetAllCategories() at Demo.BLL.ContactCategory.GetAllCategories() at _Default.Page_Load(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() 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.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.contactdemo_contact_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) -->


Thank u

Jan 4, 2010 at 2:48 AM
Edited Jan 5, 2010 at 6:05 AM

Hi,

Are the assemblies out-of-the-box? Are they not modified and rebuild? Have you tried adjusting the trust-level of the .NET configuration on your machine?

Related Thread: http://entlib.codeplex.com/Thread/View.aspx?ThreadId=13470

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com