Hi,
My web application use Castle.Core. When it is hosted on a medium trust
environment, I've got the following error message :
*Inheritance security rules violated while overriding member:
'Castle.Core.Logging.LevelFilteredLogger.InitializeLifetimeService()'.
Security accessibility of the overriding method must match the security
accessibility of the method being overriden. *
*[TypeLoadException: Inheritance security rules violated while overriding
member:
'Castle.Core.Logging.LevelFilteredLogger.InitializeLifetimeService()'.
Security accessibility of the overriding method must match the security
accessibility of the method being overriden.]*
* Castle.DynamicProxy.ProxyGenerator..ctor(IProxyBuilder builder) +0*
* Castle.DynamicProxy.ProxyGenerator..ctor() +63*
It happens when I try to make a new instance of ProxyGenerator.
In the source code, I saw that :
public ProxyGenerator(IProxyBuilder builder)
{
this.proxyBuilder = builder;
if (this.HasSecurityPermission())
{
this.Logger = new TraceLogger("Castle.DynamicProxy"
, LoggerLevel.Warn);
}
}
private bool HasSecurityPermission()
{
return new SecurityPermission
(SecurityPermissionFlag.ControlEvidence | SecurityPermissionFlag.ControlPolicy).
IsGranted();
}
It seems that the HasSecurityPermission method return *true* even in medium
trust. I looked at the history of the method and it seems to be old, maybe
this code don't work anymore with .net 4.5. I try to make it work but
couldn't find a way.
Is there a way to make dynamic proxy work under medium trust ?
Instead of instanciating a Logger on the ProxyGenerator constructor, why
not adding a signature wich take ILogger parameter ? For example :
public ProxyGenerator(IProxyBuilder builder, ILogger logger)
{
this.proxyBuilder = builder;
this.logger = logger;
}
My application is hosted on IIS, and the only modification I made was to
set <trust level="Medium" />. I use version 3.2.1 of Castle.Core provided
by nuget.
Thanks for the help,
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/groups/opt_out.