monodroid异常而装载组件 - >未能加载程序集System.Net [英] monodroid exception while loading assemblies -> Could not load assembly System.Net

查看:183
本文介绍了monodroid异常而装载组件 - >未能加载程序集System.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的组装一些业务功能(调用一个Web服务的reciving一些数据,让数据返回到列表中)。该组件的开发和使用Visual Studio编译。

我把组装和在iPhone应用程序项目中引用该组件与MonoDevelop的和MonoTouch的。它完美地工作。

现在我做了一个新的项目在MonoDevelop的一个Android应用程序与MonoDroid。在code编译完美。但是,当我要部署在Android应用程序我得到这个异​​常:

<$p$p><$c$c>/Library/Frameworks/Mono.framework/External/xbuild/Novell/Novell.MonoDroid.Common.targets: 错误:异常而加载组件: System.IO.FileNotFoundException:找不到无法加载程序集System.Net,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e。 也许它不会在单声道存在Android的个人资料? 文件名:System.Net.dll   在Monodroid.Tuner.MonoDroidResolver.Resolve(Mono.Cecil.AssemblyNameReference参考,Mono.Cecil.ReaderParameters参数)[0x00000]与&lt;文件名未知&GT;:0   在Monodroid.Tuner.MonoDroidResolver.Resolve(Mono.Cecil.AssemblyNameReference参考)[0x00000]与&lt;文件名未知&GT;:0   在Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(System.Collections.Generic.List`1组件,Mono.Cecil.AssemblyDefinition组装)[0x00000]与&lt;文件名不明&GT;:0   在Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(System.Collections.Generic.List`1组件,Mono.Cecil.AssemblyDefinition组装)[0x00000]与&lt;文件名不明&GT;:0   在Xamarin.Android.Tasks.ResolveAssemblies.Execute()[0x00000]与&lt;文件名未知&GT;:0

据我所知,单在系统组件中的S​​ystem.Net程序集。我的系统组件中引用了我的项目。

任何想法?

解决方案
  

据我所知,单有System.Net大会在系统组装。

没有。有一个 System.Net 空间里面的System.dll中的组装

System.Net.dll在MonoTouch的,我不认为有对单声道为Android是(有没有我最后一次检查; - )

有一个在Silverlight中System.Net.dll。它包含 Web客户端的WebRequest WebResponse类 ...这是,在常规的框架(包括MonoTouch的和Mono Android版)System.dll中的一部分。

常规的.NET框架有一个System.Net.dll - 但它从在Silverlight中提供的完全不同。这是令人困惑的,是国际海事组织一个非常糟糕的决定。

  

我把组装和在iPhone应用程序项目中引用该组件与MonoDevelop的和MonoTouch的。

这可能在MonoTouch中使用的模拟的时候是工作,因为JIT正在使用(和失踪将参考只要是没有必要的code忽略不计)。然而,如果你试图链接您code(它默认情况下不链接)在模拟器上努力构建设备,那么我非常有信心,你会打了一个类似的错误信息(即MonoTouch的连接器和/或AOT编译器会抱怨缺少参考)。

简而言之:您需要重新编译源$ C ​​$对MonoTouch的和单C为Android SDK组件。这是唯一的安全的方式,以确保你不会遗漏类型的引用(或添加程序集引用不存在的)。

I've got a small assembly with some business-functionality (calling an webservice an reciving some data and give the data back in a list). This assembly was developed and compiled with visual studio.

I took the assembly and referenced this assembly with MonoDevelop and MonoTouch in an iPhone app project. It works perfectly.

Now I made a new project for a Android app in MonoDevelop with MonoDroid. The code compiles perfect. But when I want to deploy the app on the android I get this exception:

/Library/Frameworks/Mono.framework/External/xbuild/Novell/Novell.MonoDroid.Common.targets:
Error: Exception while loading assemblies: 
System.IO.FileNotFoundException: Could not load assembly 'System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. 
Perhaps it doesn't exist in the Mono for Android profile?
File name: 'System.Net.dll'
  at Monodroid.Tuner.MonoDroidResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Monodroid.Tuner.MonoDroidResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00000] in <filename unknown>:0 
  at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (System.Collections.Generic.List`1 assemblies, Mono.Cecil.AssemblyDefinition assembly) [0x00000] in <filename unknown>:0 
  at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (System.Collections.Generic.List`1 assemblies, Mono.Cecil.AssemblyDefinition assembly) [0x00000] in <filename unknown>:0 
  at Xamarin.Android.Tasks.ResolveAssemblies.Execute () [0x00000] in <filename unknown>:0 

As far as I know Mono has the System.Net assembly in the System assembly. I the System assembly is referenced in my project.

Any ideas?

解决方案

As far as I know Mono has the System.Net Assembly in the System Assembly.

No. There is a System.Net namespace inside the System.dll assembly.

There is no System.Net.dll in MonoTouch and I don't think there's on in Mono for Android either (there was not last time I checked ;-)

There is a System.Net.dll in Silverlight. It contains WebClient, WebRequest, WebResponse... that are, in the regular framework (including MonoTouch and Mono for Android) part of System.dll.

The regular .NET framework has a System.Net.dll - but it's totally different from the one provided in Silverlight. That's confusing and was a very bad decision IMO.

I took the assembly and referenced this assembly with MonoDevelop and monotouch in an iPhone app project.

It may be working in MonoTouch when using the simulator because the JIT is being used (and missing references will be ignored as long as the code is not needed). However if you try to link your code (it's not linked by default) on the simulator or try to build for devices then I'm very confident you'll hit a similar error message (i.e. MonoTouch linker and/or AOT compiler will complain about the missing reference).

In short: you need to re-compile your source code against MonoTouch and Mono for Android SDK assemblies. That's the only safe way to ensure you won't be missing type references (or add assembly references that does not exists).

这篇关于monodroid异常而装载组件 - &GT;未能加载程序集System.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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