[英]System.MissingMethodException error
我有這段代碼
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "DotNetOpenAuth.dll");
Assembly assembly = Assembly.LoadFile(path);
Type type = assembly.GetType("DotNetOpenAuth.OAuth2.UserAgentClient");
if (type != null)
{
MethodInfo methodInfo = type.GetMethod("ProcessUserAuthorization");
if (methodInfo != null)
{
object result = null;
ParameterInfo[] parameters = methodInfo.GetParameters();
object classInstance = Activator.CreateInstance(type);
if (parameters.Length == 0)
{
result = methodInfo.Invoke(classInstance, null);
}
else
{
object parametersArray = new object[] { "One", "Two" };
result = methodInfo.Invoke(methodInfo, parametersArray);
}
}
}
在線上
object classInstance = Activator.CreateInstance(type);
我收到一個錯誤
System.MissingMethodException
誰能幫助我調查問題?
在文檔中 (請參閱“例外”部分):
找不到匹配的公共構造函數。
因此,您要么需要DotNetOpenAuth.OAuth2.UserAgentClient
公共無參數構造DotNetOpenAuth.OAuth2.UserAgentClient
,要么必須使用另一個CreateInstance
重載並提供參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.