Castle.Core Trust Level issue - asp.net

My MVC Project had been running properly in localhost when I had published it on web, I had this error,
Inheritance security rules violated while overriding member: 'Castle.MicroKernel.DefaultKernel.InitializeLifetimeService()'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Inheritance security rules violated while overriding member: 'Castle.MicroKernel.DefaultKernel.InitializeLifetimeService()'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
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:
[TypeLoadException: Inheritance security rules violated while overriding member: 'Castle.MicroKernel.DefaultKernel.InitializeLifetimeService()'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.]
Castle.Windsor.WindsorContainer..ctor() +0
Blog.Core.Bootstrapper.Start(Assembly[] assemblies) +130
Blog.MvcApplication.Application_Start() +970
I have read this answer.
I recompiled Castle Project with those instructions. I have deleted Castle.Core.dll safely in my project and added recompiled the Castle.Core.dll. But I still have the same error.
What can I do? How can I solve this problem that I have been struggling with over the past 2 weeks?

User needs to find a hosting provider that supports Full Trust. Most providers who are ASP.Net friendly support Full Trust as there is no real reason these days not to.
This is most likely the answer to your question sir.

This could work
<system.web>
<trust level="Full" />
</system.web>
Try that on the web.config, cheers

Related

Nopcommerce security exception

When I publish the nopcommerce on the server, I got this error. My host provides me full trust level.
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 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 failed.]
Nop.Core.TypeConverterRegistrationStartUpTask.Execute() +0
Nop.Core.Infrastructure.NopEngine.RunStartupTasks() +487
Nop.Core.Infrastructure.NopEngine.Initialize(NopConfig config) +48
Nop.Core.Infrastructure.EngineContext.Initialize(Boolean forceRecreate) +92
Nop.Web.MvcApplication.Application_Start() +66
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.36366
how to solve this error?
Check if your hosting meets the requirements: Technology & System Requirements
Next check whether you done this right: Installation Guide
For me this seems like your installation has not enough rights.
According to installation guide you need to give nopCommerce write permission on following directories and files
\App_Data\
\bin\
\Content\
\Content\Images\
\Content\Images\Thumbs\
\Content\Images\Uploaded\
\Content\files\ExportImport\
\Plugins\
\Plugins\bin\
\Global.asax
\web.config

Elmah integration - Error 500 when trying to access elmah.axd

I'm trying to add the tool Elmah to my website to be able to log exceptions. Elmah is working since exceptions are logged into the table ELMAH_Error of my SQL Server Database.
The thing is, when I try to access the page elmah.axd, I get an Error 500. The problem is related to the sessionState which seems not to be activated. But if I look in the Web.config, I've got :
<sessionState mode="SQLServer" timeout="60" allowCustomSqlDatabase="true"
sqlConnectionString="data source=MYSERVER;Initial Catalog=ASPStateFicheClient;
user id=USERID;password=Password" cookieless="UseCookies" />
I'm working with .NET 3.5 and Webforms.
Here is the error shown on the website :
Server Error in '/' Application.
Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \\ section in the application configuration.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \\ section in the application configuration.
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:
[HttpException (0x80004005): Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \\ section in the application configuration.]
System.Web.UI.Page.get_Session() +2650952
MyFramework.HttpModules.ResultMessageModule.loadComplete(Object sender, EventArgs e) +67
System.Web.UI.Page.OnLoadComplete(EventArgs e) +8711878
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +735
Thank you in advance for you help,

Line numbers missing from exception stack trace when ASP.NET impersonation enabled

An ASP.NET 2.0 web application has been compiled with PDB symbols, deployed to a server running IIS 6.
In the web.config, user impersonation is enabled:
<identity impersonate="true" />
When an Exception is thrown, the stack trace is missing line numbers, making it very difficult to determine exactly where the exception is emanating from. eg.
System.NullReferenceException: Object
reference not set to an instance of an
object. at
MyApp.ReportingServices.WebForm.DA.AmoRepository.GetDimensions(String
perspective)
The login being used to access the website has no special rights or group membership on the server.
I managed to get a detailed stack dump for the exception by assigning the 'Debug Programs' user right to the particular login.
Once the exception was diagnosed I removed that user from that assignment.

Cause for ASP.NET Security Exception

My application is throwing a Security Exception with the following details:
Description: The application attempted to perform an operation not allowed by the security policy
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +58
System.Net.ServicePointManager.set_CertificatePolicy(ICertificatePolicy value) +54
com.paypal.sdk.core.APICallerBase.SetTrustManager() +114
The application's trust level is set to medium and I've added to the [assembly: AllowPartiallyTrustedCallers] attribute to my project's assembly.
What can I do to address this issue? Does the System.dll allow partial trusted callers?
In digging a bit, the paypal method SetTrustManager() may attempt to reassign the ServicePointManager's Certificate Policy. This is OK, but it requires UnmanagedCode permission for the underlying code group.
I suggest you provide this permission in the .Net Framework Config console, and see if that helps.
Alternatively you can set the application's config "TrustAll" parameter to False so that SetTrustManager doesn't mess with the Certificate policy (assuming of course that the said Certificate policy is readily ok for whatever certs you'll need to use, in other words, this TrustAll thing may move past this permission error, but fail later if the Certificates)
In similar situations, I've found that the tools on this MDSN page can be very useful.
(in resp. to javacavaj note) To allow calls to unmanaged code for some assemblies:
Disclosure: I'm not an expert on .NET security model; the following should allow you alter permissions granted to some of your assemblies for diagnostic purposes for the issue at hand. For production purposes, please have your .NET configuration reviewed by a qualified admin as he/she may both ensure that the configuration is safe and suggest some way to structure the code groups, permission sets and other elements in ways that facilitate administration and deployment.
You can alter the .NET security policy with Mscorcfg.msc, i.e. the .Net Framework Configuration console. The details may vary with the .NET version and Windows host, but in general:
start mscorcfg (Ctrl panel | Admin Tools | Msft .Net Framework Configuration)
Run Time Policy node, then Manchine (or Enterprise, but better mess w/ local cfg first...)
Permission Sets node, Click "Create New Permission Set) on right panel
Provide name/description, next
Security | Add
Select Enable Assy execution, Allow calls to unmanaged assemblies and other permissions you may need | OK
Pick Code Groups Nodes, and navigate down to the group the assembly in question may belong (easier, yet create a group for it; in general you know who qualifies for a given group by seeing the "membership condition" tab in the group properties. Try and use Strong Name or GAC when possible.
In the Code Group properties's select the desired Permission set; optinally verify that this set is as desired for a given permission with the "View Permission" button.
Et voila...
Rather than the above, I wish I knew of a web site where such procedure can be [better] described. Maybe this Overview of the .NET Security Model can be of help. Googling several of the keywords provided can probably yield relevant pointers as well.

security exception in asp.net

while i am running my web application, i got the security exception like this what is that means how it comes can u tell details. thank u it is the eception
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.
Description of the error is
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.
Did you add a <trust /> element to your web.config like the exception is suggesting? See trust Element (ASP.NET Settings Schema) from MSDN.

Resources