问题标签 [typeloadexception]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - ServiceStack TypeLoadException - 未知来源
一点背景知识:我最近从其源代码 ( https://github.com/ServiceStack/ServiceStack ) 重新编译了 ServiceStack 库。在完成一些错误修复后,我还重新编译了 ServiceStack.Text 项目。我将 ServiceStack.Text dll 文件复制到 ServiceStack 项目的“lib”文件夹中(因为 ServiceStack 解决方案不包括 Text 中的序列化程序,所以它在那里)。
现在我得到 TypeLoadExceptions,如下:
System.TypeLoadException:来自程序集“ServiceStack.ServiceInterface,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”的“ServiceStack.ServiceInterface.Testing.MockHttpResponse”类型中的方法“get_StatusCode”没有实现。在 System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) 在 System.Reflection.RuntimeAssembly.GetExportedTypes() 在----我的代码从这里...----
我不确定问题可能是什么。我怀疑这可能是一个循环 DLL 引用问题(DLL Hell),因为引用了 ServiceStack.OrmLite(它还引用了该项目中的其他解决方案);但是,在删除对 ServiceStack 项目的所有引用后,我仍然没有解决问题。
这篇文章似乎有一些想法,但我没有任何运气来完成这些: TypeLoadException says 'no implementation',but it is implemented
dynamics-crm-2011 - Extension Methods for CRM 2011 Online Instances Causing TypeLoad Exceptions
I am writing a plugin for a client on a CRM Online trial tenant (so assume it has latest patches etc.) and have come across an error I’ve not seen before. Generally speaking I always use an extension method along the lines of the following, just for clarity of code really:
Nothing hugely controversial there I think? Anyway for whatever reason if I include the class file as part of a plugin for this client, I get the following error thrown:
There is no trace included, which shows the plugin isn’t even executed (even if the first line of code is throwing an exception!).
I did a bit of digging and it seems that for this client/instance at least:
- If I include a static class file (public static class Foo
) with any method, I get this error, whether the class is actually used by code or not
- When the error is generated, the plugin itself is not executed (the exception occurs before any code)
Anyone seen anything like this before or have any insight into System.TypeLoadException
exceptions?
firefox - Selenium:WebDriver - 每次我运行最基本的项目时都未处理 System.TypeLoadException
错误详情:
System.TypeLoadException 未处理
HResult=-2146233054
消息=无法从程序集
>“WebDriver,版本=0.0.0.0,文化=中性,PublicKeyToken=null”加载类型“OpenQA.Selenium.Firefox.FirefoxDriver”。
Source=WebDriver
TypeName=OpenQA.Selenium.Firefox.FirefoxDriver
StackTrace:在 System.AppDomain._nExecuteAssembly(RuntimeAssembly 程序集,String[] args)
的 Driver.Main(String [] args ) 在 System.AppDomain.ExecuteAssembly(字符串 assemblyFile,证据assemblySecurity, String[] args) 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext
>executionContext, ContextCallback 回调, 对象状态, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
>ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext .Run(ExecutionContext executionContext,
>ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
InnerException:
我在 Windows 8 上运行 Visual C# 2010。我将目标框架更改为 .Net 框架 4(来自 .Net 框架 4 客户端配置文件)。我尝试了三大浏览器:
每次都出现同样的错误(基本上,无论如何)。代码直接来自他们的文档: http ://docs.seleniumhq.org/docs/03_webdriver.jsp#introducing-the-selenium-webdriver-api-by-example
任何帮助将不胜感激。刚开始使用 Selenium,希望能自动化一些简单的任务来开始。如果我在得到答案之前弄清楚了,我会把它作为更新发布。
编辑:尝试清理一下格式。
c# - TypeLoadException 与 D3DotNetAPI
我正在尝试使用 D3DotNetAPI 创建 Windows Phone 7 应用程序。
这是文档的链接:D3DotNetAPI 文档链接
我只是想按照示例进行操作:
我抛出这个异常:
我不确定,但我的异常可能与此堆栈溢出答案类似
PS:相同的示例在 Win32 应用程序上运行良好。
c# - 动态模块什么时候可以有类型加载异常?
我有一个动态模块,它会在我的应用程序运行时将类型添加到其中。该模块是通过以下代码创建的:
应用程序的其他部分有时也会在模块的程序集中调用 GetTypes()。有时,当发生这种情况时,我会为动态模块中的一种类型获得 TypeLoadException。堆栈跟踪是:
我的问题是:什么可能导致此异常?运行时模块是真正的线程安全的,还是在创建类型的过程中会出现调用 GetTypes() 的竞争条件?
编辑:这是一小段代码,可以为我可靠地重现该错误。现在看来,如果在 DefineType() 和 CreateType() 之间调用 GetTypes(),就会发生异常:
c# - TypeLoadException 说“没有实现”,但它已经实现了——有什么解决方案吗?
我不得不创建新问题,因为我的答案被认为是不好的
我指的是这个已经回答的问题。
Kiquenet已经在对答案的评论中询问了它,但没有人回答他。
现在,当我们都知道它为什么会发生时,任何人都可以判断是否(以及如何)有任何不涉及重建项目的问题的解决方案?
在我的情况下,程序集是动态加载的,除了在不同版本的项目之间共享之外,每次我需要新版本的加载程序集时都重新构建是不可接受的。
所有接口均已正确实现,并且诸如“无限引用”/“版本不变”之类的选项将是完美的。
c# - 如何对未指定类型的 TypeLoadException 进行故障排除?
我有一个引用 Windows Phone 7.1 库的 Windows Phone 7.1 应用程序。该库引用了包含 Windows Phone 7 或更高版本作为目标的 PCL。
有一次,应用程序尝试从库中创建一个类的新实例,该库扩展了 PCL 中的一个类。PCL 类有一个受保护的构造函数,所以我在库类中重写它以使其公开。构造函数采用 1 个参数。在应用程序中,我创建了这个参数的一个实例,并将它传递给库中的构造函数,它没有自己的代码,只是: base()
传递给另一个构造函数。
我在 Windows Phone 模拟器中运行该应用程序,一切正常。应用程序加载,我浏览了几个屏幕。
我打了一个断点并单步执行。我很好地进入了库的构造函数,但是当我尝试更进一步,这将进入 PCL 的构造函数时,我只得到一个 TypeLoadException,上面写着“加载类型时发生故障”。堆栈跟踪在库构造函数处停止,并且没有内部异常。
我也试过 Windows Phone 7.8 模拟器。而且我还尝试使用无参数构造函数直接在库类的构造函数中创建新实例,只是说: base(new ...)
但它都以同样的方式失败。
我不知道如何找出问题所在,因为我不知道它可能试图寻找什么不可用。我在项目的构建目录的清单中看到了库和 PCL 程序集。
我的 google fu 快干了。有人对我可以继续寻找的任何想法有什么想法吗?
谢谢。
c# - TypeLoadException:来自程序集的方法没有实现。尽管进行了多次清理仍无法解决
两个月后我回到了我的程序(控制台应用程序)。它以前工作正常。但突然我得到这个错误。我Google API
在程序中使用:
我已经清理了我的解决方案并重新构建。清除了我的文件夹bin
和obj
文件夹,然后再试一次。
我什至开始创建一个新项目并复制代码并加载DLL
文件,但出现了同样的错误。
我已经阅读了一些关于此的其他帖子,TypeLoadException
但它们主要解决我DLL
在两个地方有不同版本的程序,这使程序感到困惑。
但事实并非如此。而且该方法实际上确实有一个实现。因为它以前工作得很好。
我不明白这两个月发生了什么。就是我买了一台新的笔记本电脑。但是我也在我的旧笔记本电脑上检查了这个程序,但它在那里也不起作用。
我应该补充一点,该项目也在Github
. 也许这会有所帮助。
c# - .net 4.0 安全模型。另一个“类型违反的继承安全规则......”异常
我想我坚持使用 .net 4.0 新的安全模型。一般来说,我只想将第 3 方程序集加载到沙箱中。听起来很容易,对吧?尽管如此...
我的解决方案中有 2 个项目:CrossAppDomain.exe 和 UntrustedCode.dll。在 CrossAppdomain 中,我为所有编组对象创建了以下基类:
并为我将使用的对象创建了基类
在 UntrustedCode.dll 我创建了派生类
要创建 UntrustedClass 的实例,我使用以下工厂:
问题来了:
在 Factory.Create() 中,只有当我使用 Activator.CreateInstance 时,我才成功创建了 AppDomainWorker 类。而更直接的 AppDomain.CreateInstanceAndUnwrap 失败了。这看起来很不稳定,我的意思是这是错误或安全漏洞。但是好的,解决方法有效
在 AppDomainWorker.Create() 中,我得到 TypeLoadException:类型违反的继承安全规则:'UntrustedCode.UntrustedClass'。派生类型必须要么与基类型的安全可访问性相匹配,要么难以访问。我不知道如何解决它。这是我的问题
PS 我知道 [assembly: SecurityRules(SecurityRuleSet.Level1)] ,但我想知道如何让事情在 .net 4.0 安全模型中工作
编辑:在添加 [assembly: AllowPartialTrustCallers] 之后,我遇到了一堆新问题:我需要使用 [SecuritySafeCritical] 明确标记所有使用 LogManager.GetCurrentClassLogger() 创建 nlog 记录器的代码,然后是使用记录器的初始化字段的所有代码。这是不可接受的。所以也许还有其他方法?
c# - 重新导入资源中的图像后未处理 TypeLoadException
重新导入资源中的 2 个图像后出现此错误。
我可能只是失去了我的全部工作,请帮助我。谢谢