无法使用 System.XML.Linq [英] Unable to use System.XML.Linq

查看:44
本文介绍了无法使用 System.XML.Linq的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 Mono for Android 的项目.使用 Xamarin 阅读跨平台文档后.我将数据层放在一个单独的项目中,打算将它移动到我的 Mono for Android 项目,然后将这些文件链接到我的 Mono Touch 项目,也许有一天可能是 Windows Phone 8 项目.

I am working on a project using Mono for Android. After reading a cross-platform document with Xamarin. I had my data layer in a separate project and was going to move it to my Mono for Android project and then link those files to my Mono Touch project, and one day perhaps a Windows Phone 8 project.

当我移动代码时,由于 System.Xml.Linq 引用,我现在无法编译.参考显示在 Mono for Android 项目中,但我无法使用它.我认为针对 Froyo 可能是问题所在,但将项目升级到 Gingerbread 或 Ice Cream Sandwich 并没有帮助.

When I moved the code, I am now unable to compile because of the System.Xml.Linq reference. The reference shows in the Mono for Android project, but I am unable to use it. I thought aiming for Froyo may be the problem, but upgrading the project to Gingerbread or Ice Cream Sandwich didn't help.

有人知道我做错了什么吗?我是一名经验丰富的 .NET 开发人员,并且非常了解引用在项目中的工作方式,但这让我感到困惑.

Does anybody know what I am doing wrong? I am a seasoned .NET developer and am well aware of how references work in project, but this one has me stumped.

原始代码正在处理的项目是针对 Mono/.NET 4 框架

The project the original code was working on was targeting the Mono/.NET 4 framework

推荐答案

您对 System.Xml.Linq 的引用是指向 .Net 版本还是 Mono 版本?Mono 的版本将是 2.0.5.0.

Is your reference to System.Xml.Linq pointing to the .Net version or the Mono version? The one for Mono will have Version 2.0.5.0.

此外,是对 Android 类库/应用程序或常规 .Net 类库中的 System.Xml.Linq 的引用.如果它是一个 .Net 类库,我会尝试将您的 Android 应用程序中的库作为编译 (dll) 引用而不是项目引用来引用.这不是一个完美的解决方案,但我发现当我需要引用我在多个解决方案中使用的库时,这很有效.参考通常可以正常工作,但如果 Mono 版本不支持任何内容,则可能会导致问题.

Also, is the reference to System.Xml.Linq in a Android Class Library/Application or in a regular .Net Class library. If it is a .Net Class library, I would try referencing the library in your Android application as a compiled (dll) reference and not a project reference. It is not a perfect solution, but I have found that this works when I needed to reference libraries that I use across multiple solutions. The reference will generally work out fine, but if there is anything that is not supported in the Mono version, then it can cause issues.

假设您的代码在类库中,最好的办法可能是创建库项目的 Mono 特定版本.您可以导入和使用相同的类文件,但只需添加一些条件编译符号即可使其为 Mono 正确编译.如果您对此不熟悉,请查看 Json.NetServiceStack 管理多个平台的代码.

Assuming you have your code in a class library, your best bet may be to create a Mono specific version of your library project. You can import and use the same class files, but just add some Conditional compilation symbols to have it compile properly for Mono. If you are not familiar with this, take a look at how Json.Net or ServiceStack manages code for multiple platforms.

这篇关于无法使用 System.XML.Linq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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