在模块CommonLanguageRuntimeLibrary中找不到类型System.ApplicationException [英] Cannot find type System.ApplicationException in module CommonLanguageRuntimeLibrary

查看:280
本文介绍了在模块CommonLanguageRuntimeLibrary中找不到类型System.ApplicationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过CodenameOne的IKVM版本运行了一个第三方Android库,并成功导入了输出.dll作为对我在Visual Studio中的UWP应用的引用.尝试编译项目时,我得到一个构建错误:

I ran a 3rd party Android library through CodenameOne's version of IKVM and successfully imported the output .dll as a reference to my UWP app in Visual Studio. Upon trying to compile the project I get a single build error:

(在错误列表"窗口中)

(from the Error List window)

在CommonLanguageRuntimeLibrary模块中找不到类型System.ApplicationException

Cannot find type System.ApplicationException in module CommonLanguageRuntimeLibrary

(在输出"窗口中)

程序文件(x86)\ MSBuild \ Microsoft \ WindowsXaml \ v14.0 \ 8.2 \ Microsoft.Windows.UI.Xaml.Common.targets(352,5):Xaml内部错误错误WMC9999:找不到类型System.ApplicationException在CommonLanguageRuntimeLibrary模块中.

Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v14.0\8.2\Microsoft.Windows.UI.Xaml.Common.targets(352,5): Xaml Internal Error error WMC9999: Cannot find type System.ApplicationException in module CommonLanguageRuntimeLibrary.

根据我的阅读,<.c0>在UWP的.Net中已贬值,相反,您应该只使用System.Exception

我不知道如何解决和/或更正此错误,因为它来自库而不是我自己的代码.

I don't know how to work around and/or correct this since it's coming from a library and not my own code.

谢谢.

推荐答案

我们的IKVM端口还不太完善. IKVM是使用.Net 2.0进行编译的,某些要素(例如反射要素,某些日期要素,线程等)是通过使用该接口的UWP项目中需要包含的接口来排除的.

Our port of IKVM isn't quite turn-key. IKVM is compiled using .Net 2.0, and some things (e.g. reflection stuff, some date things, threads, etc...) are factored out using interfaces that need to be included in the UWP project that uses it.

如果您尚未实现这些接口,或者您使用的是CN1不需要的代码路径,那么您可能正在着手使用.Net 2.0类的JDK或IKVM运行时部分(例如,此异常).

If you haven't implemented these interfaces, or you are using code paths that we don't need for CN1, then you may be embarking of parts of the JDK or IKVM runtime that use .Net 2.0 classes (e.g. this exception).

当前,在UWP项目中仅需要实现两个接口:

Currently there are only two interfaces that need to be implemented in your UWP project:

  1. RuntimeReflectionHelper.
  2. NativeThreadHelper

您可以在CN1端口中看到如何初始化它们

You can see, in the CN1 port how they are initialized here

以下是 RuntimeReflectionHelper 在UWP项目中实现这些功能可以解决以下事实:IKVM是针对.Net 2.0编译的,因此这些实现可以直接使用UWP API.

Implementing these inside the UWP project gets around fact that IKVM is compiled for .Net 2.0, so that these implementations can use UWP APIs directly.

即使这样,您也可能会遇到问题. IKVM的该端口沿CN1端口发展,并且实际上仅针对我们的用例进行了测试.如果我们不需要CN1,则某些通用方法可能无法实现.

Even with this, you will probably run into issues. This port of IKVM is evolving along side the CN1 port, and it is really only tested for our uses cases. Some common methods may be unimplemented if we didn't require them for CN1.

您应该意识到的其他一些限制:

Some other limitations you should be aware:

  1. 如果要相互引用,则项目中IKVM编译的代码必须是单个.dll文件的一部分.例如.如果将两个库lib1.jar和lib2.jar编译为lib1.dll和lib2.dll,则lib1中的代码无法引用lib2中的类,反之亦然.在CN1中,我将所有.class文件捆绑到单个.jar中,然后再通过IKVM运行,因此这对我们来说不是问题(因此,我花了很多时间来修复它).

  1. The IKVM-compiled code in a project needs to be part of a single .dll file if you want it to refer to each other. E.g. If you compile two libraries, lib1.jar and lib2.jar to lib1.dll and lib2.dll, then code from lib1 can't references classes from lib2 and vice versa. In CN1 I bundle all .class files into a single .jar before running it through IKVM so that isn't an issue for us (hence why I didn't spend much time trying to fix it).

如果您的目标是发布到Windows应用商店,则其DotNetNative工具链中当前存在一个错误,该错误会导致其阻塞包括try/catch块的同步方法. Microsoft可能会在将来的版本中修复此问题,但我可以通过在所有类上运行预转换来将所有此类方法转换为其本机工具链可接受的形式来解决此问题. 此处应用此预处理的ANT任务的一部分. 此处是用于此ANT任务的类预处理器项目进行实际的预处理.

If your goal is to publish to the Windows store, there is currently a bug in their DotNetNative toolchain that causes it to choke on synchronized methods that include try/catch blocks. This will likely be fixed by Microsoft in future releases, but I get around this by running a pre-transformation on all classes to convert all such methods into a form that is acceptable to their native toolchain. Here the part of our ANT task that applies this preprocessing. Here is the class preprocessor project for the ANT task that this uses to do the actual preprocessing.

正如我之前说的,如果您在已经被大火烧过的小径之外探索,将会遇到困难.

As I said before, expect to run into difficulties if you're exploring outside the trails that have already been blazed.

这篇关于在模块CommonLanguageRuntimeLibrary中找不到类型System.ApplicationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆