Monotouch - DLL 上缺少方法

发布于 2024-09-28 13:09:35 字数 3447 浏览 0 评论 0原文

我正在尝试使用 Monotouch 在 .Net 中为 iPhone 创建一个项目。我的问题是:

我有一个由 Visual Studio 2010 生成的 DLL。该 DLL 只有一个接口和其他两个类。我可以在 Visual Studio 中的项目中毫无问题地使用,但是当我尝试在 Monotouch 中使用相同的项目时,出现此错误:

Building: HelloWorld (Debug|iPhoneSimulator)
构建解决方案 HelloWorld
构建:HelloWorld(调试|iPhoneSimulator)
正在执行主编译...
更新代码隐藏文件
更新了 MainWindow.xib.designer.cs
/Developer/MonoTouch/usr/bin/smcs /noconfig “/out:/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/bin/iPhoneSimulator/Debug/HelloWorld.exe” “/r:/Developer/MonoTouch/ usr/lib/mono/2.1/System.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" "/r:/Developer/MonoTouch/usr/lib/mono/ 2.1/System.Core.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Runtime。 Serialization.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.ServiceModel.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.ServiceModel.Web。 dll" "/r:/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/bin/Abcom.EmailService.ContractsCS.dll" /nologo /warn:4 /debug:+ /debug:full /optimize- /codepage :utf8 "/define:DEBUG" /t:exe "/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/MainWindow.xib.designer.cs"
“/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/Main.cs”“/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/Class1.cs”
程序集 /Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/bin/Abcom.EmailService.ContractsCS.dll 中缺少方法 .ctor,类型为 System.Runtime.Versioning.TargetFrameworkAttributeThe class System.Runtime.Versioning.TargetFrameworkAttribute 无法已加载,在 Abcom.EmailService.ContractsCS 中使用找不到自定义 attr 构造函数图像:/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/bin/Abcom.EmailService.ContractsCS.dll mtoken:0x0a000001 未处理的异常:System.TypeLoadException:无法从程序集“Abcom.EmailService.ContractsCS”加载类型“System.Runtime.Versioning.TargetFrameworkAttribute”。 at(包装器托管到本机)System.Reflection.Assembly:InternalGetType(System.Reflection.Module,string,bool,bool) 在 System.Reflection.Assembly.GetType (System.String name, Boolean throwOnError, BooleanignoreCase) [0x00000] in :0 在 System.Reflection.Assembly.GetType(System.String 名称)[0x00000] 中:0 在 Mono.CSharp.RootNamespace.GetTypeInAssembly (System.Reflection.Assembly 程序集,System.String 名称) [0x00000] 中:0 在 Mono.CSharp.RootNamespace.LookupTypeReflection (Mono.CSharp.CompilerContext ctx, System.String name, Location loc, Boolean Must_be_unique) [0x00000] 中:0 在 Mono.CSharp.GlobalRootNamespace.LookupTypeReflection (Mono.CSharp.CompilerContext ctx、System.String 名称、位置 loc、布尔 Must_be_unique) [0x00000] 中:0 在 Mono.CSharp.Namespace.LookupType (Mono.CSharp.CompilerContext ctx, System.String name, Location loc) [0x00000] 中:0 在 Mono.CSharp.Namespace.Lookup (Mono.CSharp.CompilerContext ctx, System.String name, Location loc) [0x00000] in :0 在 Mono.CSharp.TypeManager.CoreLookupType (Mono.CSharp.CompilerContext ctx、System.String ns_name、System.String name、Kind type_kind、Boolean required) [0x00000] 中:0 在 Mono.CSharp.TypeManager.InitCoreTypes (Mono.CSharp.CompilerContext ctx) [0x00000] 中:0 在 Mono.CSharp.Driver.Compile () [0x00000] 中:0 在 Mono.CSharp.Driver.Main (System.String[] args) [0x00000] 中:0 构建完成 -- 1 个错误,0 个警告 - - - - - - - - - - - 完毕 - - - - - - - - - - - 构建:1 个错误,0 个警告

有人知道这里发生了什么吗?

问候, 克劳迪奥

I'm trying to create a project in .Net for IPhone using Monotouch. My problem is:

I have a DLL generated by Visual Studio 2010. This DLL just have an Interface and two other classes. I can use with no problems in my project in Visual Studio, but when I try to use the same one in Monotouch, i've got this error:

Building: HelloWorld (Debug|iPhoneSimulator)
Building Solution HelloWorld
Building: HelloWorld (Debug|iPhoneSimulator)
Performing main compilation...
Updating CodeBehind files
Updated MainWindow.xib.designer.cs
/Developer/MonoTouch/usr/bin/smcs /noconfig "/out:/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/bin/iPhoneSimulator/Debug/HelloWorld.exe" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Runtime.Serialization.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.ServiceModel.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.ServiceModel.Web.dll" "/r:/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/bin/Abcom.EmailService.ContractsCS.dll" /nologo /warn:4 /debug:+ /debug:full /optimize- /codepage:utf8 "/define:DEBUG" /t:exe "/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/MainWindow.xib.designer.cs"
"/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/Main.cs" "/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/Class1.cs"
Missing method .ctor in assembly /Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/bin/Abcom.EmailService.ContractsCS.dll, type System.Runtime.Versioning.TargetFrameworkAttributeThe class System.Runtime.Versioning.TargetFrameworkAttribute could not be loaded, used in Abcom.EmailService.ContractsCSCan't find custom attr constructor image: /Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/bin/Abcom.EmailService.ContractsCS.dll mtoken: 0x0a000001
Unhandled Exception: System.TypeLoadException: Could not load type 'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly 'Abcom.EmailService.ContractsCS'.
at (wrapper managed-to-native) System.Reflection.Assembly:InternalGetType (System.Reflection.Module,string,bool,bool)
at System.Reflection.Assembly.GetType (System.String name, Boolean throwOnError, Boolean ignoreCase) [0x00000] in :0
at System.Reflection.Assembly.GetType (System.String name) [0x00000] in :0
at Mono.CSharp.RootNamespace.GetTypeInAssembly (System.Reflection.Assembly assembly, System.String name) [0x00000] in :0
at Mono.CSharp.RootNamespace.LookupTypeReflection (Mono.CSharp.CompilerContext ctx, System.String name, Location loc, Boolean must_be_unique) [0x00000] in :0
at Mono.CSharp.GlobalRootNamespace.LookupTypeReflection (Mono.CSharp.CompilerContext ctx, System.String name, Location loc, Boolean must_be_unique) [0x00000] in :0
at Mono.CSharp.Namespace.LookupType (Mono.CSharp.CompilerContext ctx, System.String name, Location loc) [0x00000] in :0
at Mono.CSharp.Namespace.Lookup (Mono.CSharp.CompilerContext ctx, System.String name, Location loc) [0x00000] in :0
at Mono.CSharp.TypeManager.CoreLookupType (Mono.CSharp.CompilerContext ctx, System.String ns_name, System.String name, Kind type_kind, Boolean required) [0x00000] in :0
at Mono.CSharp.TypeManager.InitCoreTypes (Mono.CSharp.CompilerContext ctx) [0x00000] in :0
at Mono.CSharp.Driver.Compile () [0x00000] in :0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in :0
Build complete -- 1 error, 0 warnings
---------------------- Done ----------------------
Build: 1 error, 0 warnings

Somebody knows what's going on here?

Regards,
Claudio

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

轻拂→两袖风尘 2024-10-05 13:09:35

凯文是对的。

.NET 有多个“配置文件”,这些配置文件由其锚定“mscorlib.dll”控制。所有其余程序集均从锚定的 mscorlib.dll 开始流动。您会注意到,您不应该真正在 4.0 系统上混合使用 2.0 mscorlib 编译的程序集,反之亦然(它们可能可以工作,但不能保证可以工作)。

因此,一般来说,您需要使用同一系列的程序集来编译代码。使用 4.0 mscorlib 时,您使用 4.0 系列程序集;当使用2.0、3.5和3.5sp1时,您使用2.0 mscorlib;使用 Silverlight 时,您使用 Silverlight 2.1 mscorlib API 集。

MonoTouch 引入了自己的锚定 mscorlib,版本为 2.1.0.0(与 Silverlight 相同),我们的 API 就从这个程序集中开始流动。

这就是为什么您需要使用 Mono 的程序集为 2.1.0.0 配置文件重建库。

Kevin is correct.

.NET has several "profiles" and the profiles are governed by their anchoring "mscorlib.dll". From the anchoring mscorlib.dll, all the rest of the assemblies flow. You will notice that you should not really mix an assembly compiled with a 2.0 mscorlib on a 4.0 system, or the other way around (they might work, but they are not guaranteed to work).

So in general, you need to compile your code using the same family of assemblies. When using the 4.0 mscorlib, you use the 4.0 family of assemblies; When using the 2.0, 3.5 and 3.5sp1, you use the 2.0 mscorlib; When you use Silverlight, you use the Silverlight 2.1 mscorlib set of APIs.

MonoTouch introduces its own anchoring mscorlib, versioned as 2.1.0.0 (the same one as Silverlight) and from this assembly, our API flows.

That is why you need to rebuild your libraries using Mono's assemblies for the 2.1.0.0 profile.

春夜浅 2024-10-05 13:09:35

您无法链接到使用 Visual Studio 编译的 DLL。您必须使用 Monotouch 重新编译 DLL 才能使用它。

You can't link against DLLs compiled with Visual Studio. You have to recompile the DLL with Monotouch in order to use it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文