的代码看起来未处理如下:错误:System.Reflection.TargetParameterCountException是由用户代码
public static class ResLocator
{
public static string Resolve(Type assemblyObjectType, string resourceName)
{
MethodInfo resourceLocatorMethod = typeof(System.Web.Handlers.AssemblyResourceLoader).GetMethod(
"GetWebResourceUrlInternal", BindingFlags.Static | BindingFlags.NonPublic, null,
CallingConventions.Any, new[] { typeof(Assembly), typeof(string), typeof(bool), typeof(bool), typeof(ScriptManager) }, null);
string url = string.Format("/{0}", resourceLocatorMethod.Invoke(
null,
new object[] { Assembly.GetAssembly(assemblyObjectType), resourceName, false })
);
return url;
}
}
错误:System.Reflection.TargetParameterCountException是由用户代码未处理的,上来就调用。
我不确定我的代码有什么问题。
除了你依靠内部实现细节来开始?那么这听起来像你用错误的参数调用方法。该方法在哪里申报? (如在,你有链接到源?) –
可能[这一个](https://referencesource.microsoft.com/#System.Web/Handlers/AssemblyResourceLoader.cs,c3179e7329c55e12),@JonSkeet。 –
那么,如果OP提供了3个参数,并且该方法有5个参数,那么这个错误就可以理解。 –