Skip to content

Commit

Permalink
Fix System.Security.VerificationException
Browse files Browse the repository at this point in the history
Fix System.Security.VerificationException : Operation could destabilize the runtime.
  • Loading branch information
scott-xu committed May 27, 2022
1 parent 179fc25 commit 6cdab16
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Ninject/Injection/DynamicMethodInjectorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class DynamicMethodInjectorFactory : NinjectComponent, IInjectorFactory
/// <returns>The created injector.</returns>
public ConstructorInjector Create(ConstructorInfo constructor)
{
var dynamicMethod = new DynamicMethod(GetAnonymousMethodName(), typeof(object), new[] { typeof(object[]) }, true);
var dynamicMethod = new DynamicMethod(GetAnonymousMethodName(), typeof(object), new[] { typeof(object[]) }, constructor.Module, true);

var il = dynamicMethod.GetILGenerator();

Expand All @@ -67,9 +67,9 @@ public ConstructorInjector Create(ConstructorInfo constructor)
public PropertyInjector Create(PropertyInfo property)
{
#if NO_SKIP_VISIBILITY
var dynamicMethod = new DynamicMethod(GetAnonymousMethodName(), typeof(void), new[] { typeof(object), typeof(object) });
var dynamicMethod = new DynamicMethod(GetAnonymousMethodName(), typeof(void), new[] { typeof(object), typeof(object), property.Module });
#else
var dynamicMethod = new DynamicMethod(GetAnonymousMethodName(), typeof(void), new[] { typeof(object), typeof(object) }, true);
var dynamicMethod = new DynamicMethod(GetAnonymousMethodName(), typeof(void), new[] { typeof(object), typeof(object) }, property.Module, true);
#endif

var il = dynamicMethod.GetILGenerator();
Expand All @@ -96,9 +96,9 @@ public PropertyInjector Create(PropertyInfo property)
public MethodInjector Create(MethodInfo method)
{
#if NO_SKIP_VISIBILITY
var dynamicMethod = new DynamicMethod(GetAnonymousMethodName(), typeof(void), new[] { typeof(object), typeof(object[]) });
var dynamicMethod = new DynamicMethod(GetAnonymousMethodName(), typeof(void), new[] { typeof(object), typeof(object[]) }, method.Module);
#else
var dynamicMethod = new DynamicMethod(GetAnonymousMethodName(), typeof(void), new[] { typeof(object), typeof(object[]) }, true);
var dynamicMethod = new DynamicMethod(GetAnonymousMethodName(), typeof(void), new[] { typeof(object), typeof(object[]) }, method.Module, true);
#endif

var il = dynamicMethod.GetILGenerator();
Expand Down

0 comments on commit 6cdab16

Please sign in to comment.