The error about "Attempt to access the method failed"
My web app was running fine on my localhost. After deploying onto a shared server (1&1), I'm getting the following error - any ideas? If I remove the mediachase stuff from my web.config, my app works.
Attempt to access the method failed.
[MethodAccessException: Attempt to access the method failed.]
System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags) +0
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +212
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) +55
System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) +18
Mediachase.FileUploader.McHttpModule.694a7e1d01f817ae(Object 337e217cb3ba0627, EventArgs fbf34718e704c6bc) +1109
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
Answer:
You are right. It's a problem with Medium Trust. ASP.NET 2.0 with Medium-trust turn-off ReflectionPermission.
To solve it, now, I can suggest you two way:
First, Turn-on ReflectionPermission
Find *:\WINDOWS\Microsoft.NET\Framework\v2.0.*\CONFIG\web_mediumtrust.config file.
Create a copy.
Opend web_mediumtrust.config file.
Add lines into SecurityClasses section
<SecurityClasses>
<!-- Mediachase FileUploader.Net Addon -->
<SecurityClass Name="ReflectionPermission" Description="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral,PublicKeyToken=b77a5c561934e089"/>
<!-- Mediachase FileUploader.Net Addon -->
Add lines into PermissionSet section named ASP.Net
<PermissionSet
class="NamedPermissionSet"
version="1"
Name="ASP.Net">
<!-- Mediachase FileUploader.Net Addon -->
<IPermission
class="ReflectionPermission"
version="1"
Unrestricted="true" />
<!-- Mediachase FileUploader.Net Addon -->
Save file and run web.app all should work.
More info: http://blog.chilkatsoft.com/?p=116
Second, Giving Full Trust to a Strong-Named Assembly in a Medium Trust Environment
You send me your order information and I'll send strong-named Mediachase FileUploader.Net assembly and a modification file.
More info: http://west-wind.com/WebLog/posts/6344.aspx