Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MethodInfo.GetCustomAttribute上的FileNotFoundException_C#_.net_Asynchronous_Reflection_System.reflection - Fatal编程技术网

C# MethodInfo.GetCustomAttribute上的FileNotFoundException

C# MethodInfo.GetCustomAttribute上的FileNotFoundException,c#,.net,asynchronous,reflection,system.reflection,C#,.net,Asynchronous,Reflection,System.reflection,我的目标是在上传的dll中显示有关某些类的方法的信息。加载程序集、查找所需的类及其方法已成功完成。现在,我试图展示一个方法是否声明为“async” 我找到了一条线索,告诉我如何做: 不管怎样,在测试的时候,当我称之为 (AsyncStateMachineAttribute)methodInfo.GetCustomAttribute(typeof(AsyncStateMachineAttribute)) 我得到了System.IO.FileNotFoundException-“无法加载文件或程序集

我的目标是在上传的dll中显示有关某些类的方法的信息。加载程序集、查找所需的类及其方法已成功完成。现在,我试图展示一个方法是否声明为“async”

我找到了一条线索,告诉我如何做:

不管怎样,在测试的时候,当我称之为

(AsyncStateMachineAttribute)methodInfo.GetCustomAttribute(typeof(AsyncStateMachineAttribute))

我得到了System.IO.FileNotFoundException-“无法加载文件或程序集“{assembly identifier}”或其依赖项之一。系统找不到指定的文件。”

我在一个未答复的线程中发现了此异常,但它对我没有帮助:

我知道我正在研究的方法有一个我的代码不知道的属性。我不想加载该引用,因为它只是一个测试用例,在相同的情况下可以找到许多其他不同的属性

所以,我需要回答两个问题中的一个:

  • 是否有方法获取属性“AsyncStateMachineAttribute”(如果存在),忽略其他属性上的错误

  • 是否有其他方法检查方法(来自MethodInfo)是否异步

  • 提前感谢!:)