的MissingMethodException抛出GetExportedTypes

编程入门 行业动态 更新时间:2024-10-09 23:17:45
本文介绍了的MissingMethodException抛出GetExportedTypes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我收到抛出的MissingMethodException当我打电话GetExportedTypes,在code:

I'm getting a MissingMethodException thrown when I call GetExportedTypes, the code:

Assembly.LoadFrom(assemblyPath).GetExportedTypes();

例外(名称混淆):

The exception (names obfuscated):

System.MissingMethodException was unhandled Message="Method not found: 'Void Namespace.IMyMethod.MyMethod(UInt32, Namespace.IMyOtherMethod ByRef, UInt32 ByRef)'." Source="mscorlib" StackTrace: at System.Reflection.Assembly._GetExportedTypes() at System.Reflection.Assembly.GetExportedTypes() at ConsoleApplication1.Program.Main(String[] args) in C:\Documents and Settings\jpealing\My Documents\Visual Studio 2008\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 16 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

的异常没有内部异常或其它细节值得一提。

The exception has no inner exception or other details worth mentioning.

是什么原因造成的?我该如何解决这个问题?

What causes this? How can I fix it?

反射器没有问题,加载这个组件:

Reflector has no problems loading this assembly:

  • 这是注册在GAC
  • 只引用mscorlib中。
  • 在我没有建立组装 - 只有1我的机器上版本的程序集

更新:

在问题的组件,似乎是一个组件内置使用的 Tlbexp.exe - 这很可能是这个正在某种差异

The assembly in question appears to be an assembly built using Tlbexp.exe - it seems likely that this is making some sort of difference.

推荐答案

据我可以看到它只是预计某些组件抛出此异常 - 的 GetTypes 方法抛出了类似的例外 - ReflectionTypeLoadException ,但此异常也有一个类型中这似乎是被成功加载类型的列表属性。

As far as I can see it is simply expected that certain assemblies throw this exception - the GetTypes method throws a similar exception - ReflectionTypeLoadException, however this exception also has a Types property which appears to be the list of types that were successfully loaded.

现在我已经适应我的code,使其调用此方法,而不是和捕捉由此导致的异常:

For now I have adapted my code so that it calls this method instead and catches the resulting exception:

try ( return assembly.GetTypes(); ) catch (ReflectionTypeLoadException ex) { return ex.Types; }

它不是pretty的,但它似乎工作。

Its not pretty, however it does appear to work.

更多推荐

的MissingMethodException抛出GetExportedTypes

本文发布于:2023-11-12 13:03:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581576.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:抛出   MissingMethodException   GetExportedTypes

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!