问题标签 [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.

0 投票
1 回答
604 浏览

wcf - 如何解决自托管 WCF 服务的 TypeLoadException

我有一个带有配置文件的网络托管项目,我将托管类型从 iis 托管更改为 wcf 自托管,但我遇到了一些问题,请帮我解决这些问题:

这是配置文件:

这是我使用的自托管代码:

异常截图: 在此处输入图像描述

这是异常细节:

0 投票
2 回答
247 浏览

c# - 从 Windows 应用商店应用程序调用桌面应用程序

我有一个使用 c# 开发的 Windows 窗体桌面应用程序。我想利用 WinRT 应用程序(尤其是 Windows 10)中可用的动态磁贴功能。活动磁贴中的数据将使用 WMI 查询 (Win32_LogicalDisk) 获取。我该如何做到这一点?我不想重写整个应用程序。动态磁贴应在背景上更新,单击磁贴时,需要调用我的桌面应用程序 exe。是否可以从 Windows Store 应用程序中获取 WMI 数据并调用 exe?我尝试使用http://blogs.msdn.com/b/dmx/archive/2014/04/30/how-to-trigger-a-desktop-process-from-windows-store-中给出的代理 Windows 运行时组件apps-the-easy-way-using-the-brand-new-visual-studio-templates.aspx。但是当我得到一个'TypeLoadException'时无法让它工作。

提前致谢。

0 投票
1 回答
90 浏览

c# - 重新托管的工作流设计器在加载时抛出 TypeLoadException

我正在尝试在我的 WPF 应用程序中重新托管工作流设计器。

但是,当我尝试初始化它时,我会收到一个TypeLoadException包含以下消息的对话框:

“无法从程序集 'Reporting.Primitives,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null' 加载类型 'Reporting.Primitives.Documents.IDocField`1'。”

我已经尝试将其剥离并在这里得到了简单的调用代码:

正是调用Load导致了异常。

这是奇怪的部分:解决方案中没有名为IDocField<T>.

有一个IDocField和一个DocField<T> : IDocField,所以它似乎是IDocField<T>从某个地方发明了这种类型。

我没有任何反射电话正在寻找IDocField<T>

我还尝试将应用程序周围的代码移动到不直接引用的各种模块中,Reporting.Primitives但无济于事。

有一个IUiDocField<T>界面浮动。

奇怪的是,我IDocField<T>前段时间确实写了一个接口,但现在不在解决方案中,所以我不明白为什么会导致问题。

0 投票
0 回答
204 浏览

c# - 在 Windows 运行时 8.1 中执行代码之前的 TypeLoadException

我正在初始化日志,如下所示。

我将函数称为:

在执行上述行时,我收到异常:

App.Forms.WindowsPhoneShared.DLL 中出现“System.TypeLoadException”类型的异常,但未在用户代码中处理其他信息:无法从程序集“mscorlib”加载类型“System.ICloneable”,版本=4.0.0.0,Culture=中性,PublicKeyToken=7cec85d7bea7798e'。

在此处输入图像描述

即使我在InitializeLogging函数中设置了断点,它甚至没有进入该函数,在此之前它会抛出异常。为了准确找到它的中断位置,我一一评论并发现是因为下面的行。

如果您看到,我iniFile只在settingsIniFilePath存在时阅读,但文件本身不存在,仍然会引发异常。

0 投票
1 回答
379 浏览

c# - 从 WCF Svc 标记文件中的名称引用(加载)泛型类型

在 WCF Svc 标记文件中,我想使用泛型类型作为工厂:

我的泛型类的定义是这样的:

如何使用给定的类型作为模板类型引用此类型,我的意思是这样的:

通过查看MSDN Type.GetType文档,我尝试了以下操作,但没有成功:

输出:

“/”应用程序中的服务器错误。解析器错误描述:解析服务此请求所需的资源时发生错误。请查看以下特定的解析错误详细信息并适当地修改您的源文件。

解析器错误消息:在服务编译期间无法加载 CLR 类型“Tools.Services.ServiceHostFactory`1[WebSrv.MyService]”。验证此类型是否定义在位于应用程序的 \App_Code 目录中的源文件中、包含在位于应用程序的 \bin 目录中的已编译程序集中,或者存在于安装在全局程序集缓存中的程序集中。请注意,类型名称区分大小写,\App_Code 和\bin 等目录必须位于应用程序的根目录中,不能嵌套在子目录中。

输出:

“/”应用程序中的服务器错误。无法加载文件或程序集“Tools.Services”或其依赖项之一。该系统找不到指定的文件。

输出:

“/”应用程序中的服务器错误。无法加载文件或程序集“Tools.Services”或其依赖项之一。该系统找不到指定的文件。

这甚至可以以通用方式实现吗?

0 投票
0 回答
423 浏览

c# - TypeLoadException 未处理

在单击提交按钮后运行WPF应用程序时抛出以下错误:

如何解决这个问题。请帮我。

0 投票
1 回答
1024 浏览

xamarin - System.TypeLoadException 无法加载类型 CategoryActivity

我编写了一个具有以下定义的 Activity 类

此活动类的目的是将所有类别显示为列表项。

但是当我运行应用程序时,它会返回以下异常:

0 投票
1 回答
447 浏览

c# - 加载 ILmerged 程序集时出现 FileNotFoundException

我有几个程序集合并为一个。这是我的命令。

问题出在 .\Intuit.Ipp.Data.dll 程序集上。它的名字是 .\Intuit.Ipp.Data.dll,但在文件属性 Intuit.IPP.Data.dll(capital IPP) 中。其他程序集正确加载并且在描述中没有这样的东西。这可能会导致此错误吗?我如何编辑这个?异常消息:

=== Pre-bind state information === LOG: DisplayName = Intuit.Ipp.Data (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name: Intuit.Ipp.Data | Domain ID: 1 WRN: A partial bind occurs when only part of the assembly display name is provided. WRN: This might result in the binder loading an incorrect assembly. WRN: It is recommended to provide a fully specified textual identity for the assembly, WRN: that consists of the simple name, version, culture, and public key token. Newtonsoft.Json 也不会加载。其他组件 - 好的。

0 投票
1 回答
729 浏览

json.net - System.TypeLoadException: Inheritance security rules violated by type: 'System.Net.Http.Formatting.JsonContractResolver'

I'm getting a very annoying error about System.Net.Http.Formatting.JsonContractResolver having inheritance security rules violated in a project which uses PCLs.

Here is the setup and how I tracked down the problem.

Project 1 - Custom.WebApi (portable, targeting .net 4.5, Core 5.0, Win8, Xamarin.Android, Xamarin.iOS, Xamarin.iOS(Classic))

This project is an abstraction over HttpClient to unify the return types of Get, Post, Delete, ... and depends ONLY on Newtonsoft.Json and .NET with this profile.

We are using Newtsonsoft.Json pcl version 6.0.8.($packagesFolder\Newtonsoft.Json.6.0.8\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll)

Project 2 - Custom.WepApi.Tests (unit test project)

This is a test project for the WebApi project. It references full version of 6.0.8 ($packagesFolder\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll)

This project is able to run tests against WebApi project no problem.

Project 3 - MyWebsite (ASP.NET WebApi site)

This project is a WebApi project where the response types are unified and found in the Custom.WebApi project. This references a bunch of 3rd party stuff, but also Newtonsoft.Json v 6.0.8 full ($packagesFolder\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll)

Project 4 - MyWebsite.Tests

To test the web project, I have a test project that calls endpoints using Custom.WebApi implementation. This project also references newtonsoft.json version 6.0.8. However, this references is purely to fix errors observed when running. Nothing in this project depends on Newtonsoft.Json, but if I do not explicitly add a reference to it, it will fail with TypeLoadException. Adding the reference seems to make that go away.

When I run the Project 4 tests, they all fail, indicating that the website is having TypeLoadException on Startup. After a TON of investigation, I noticed that when the MyWebsite project builds, the Newtonsoft.Json.dll in the bin folder is overwritten with the portable version and fails.

If I change the test project to reference the same portable newtonsoft.json.dll, the test project fails with the same error. Using the full version, no error is observed.

If I manually replace the dll in the bin folder of MyWebsite, it is overwritten again upon build. I have made sure the references are correct in MyWebsite .csproj file, including the hint path.

So, either I need to resolve why it believes there is an inheritance security rule violation (looking at the source code did not reveal anything obvious about access modifiers not matching), or it needs to stop overwriting the Newtonsoft.Json.dll in the MyWebsite bin folder.

To further complicate things, this replacement only occurs SOMETIMES. If I Start Without Debugging, it seems to not happen all the time and executing the Unit Tests succeeds against the deployment when the dll is not replaced with portable version.

0 投票
0 回答
53 浏览

java - TypeLoadException in Universal App using IKVM converted library

Im using a library written in Java which uses common-math3 library from Apache. I have a Universal Windows App need to use above library, so my choice is to use IKVM for converting the library into a .Net dll.

I converted the library into the dll, and successfully used it in Windows Form and WPF application with .Net 4.6.1 platform without any errors. However when using in Universal App, the System.TypeLoadException occurred when I call the function from library. More detail the function I called is a constructor with parameter

Im not sure the error occurred because of type compatibility b/w Java and .Net, but I used double[][], and double[] type in .Net for above call.

Does anyone know how to overcome this issue?

Thanks