我正在尝试使用Microsoft EWS托管API构建iOS应用。我从http://www.microsoft.com/download/en/details.aspx?id=13480下载了msi并将DLL复制到了解决方案文件夹下。 在为模拟器构建时,它可以构建并运行良好,但在尝试定位物理设备时,mtouch会失败:
Compiling to native code
/Developer/MonoTouch/usr/bin/mtouch -v --nomanifest --nosign -dev "/Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.app" -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 "/Users/Projects/HelloMonoTouch/MyEWSApp/ThirdParty/Microsoft.Exchange.WebServices.dll" -linksdkonly -sdk "5.0" "/Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.exe"
Framework is: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk
Copied /Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.exe to /Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.app/MyEWSApp.exe
Copied /Developer/MonoTouch/usr/lib/mono/2.1/mscorlib.dll to /Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.app/mscorlib.dll
Copied /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll to /Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.app/monotouch.dll
Copied /Developer/MonoTouch/usr/lib/mono/2.1/System.dll to /Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.app/System.dll
Copied /Developer/MonoTouch/usr/lib/mono/2.1/Mono.Security.dll to /Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.app/Mono.Security.dll
Copied /Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll to /Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.app/System.Core.dll
Copied /Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll to /Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.app/System.Xml.dll
Copied /Users/Projects/HelloMonoTouch/MyEWSApp/ThirdParty/Microsoft.Exchange.WebServices.dll to /Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.app/Microsoft.Exchange.WebServices.dll
Linking SDK only for assembly /Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.exe into /Users/Projects/HelloMonoTouch/MyEWSApp/bin/iPhone/Release/MyEWSApp.app
Could not link assemblies: System.IO.FileNotFoundException: Could not resolve: System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00000] in <filename unknown>:0
at Mono.Linker.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00000] in <filename unknown>:0
at Mono.Linker.LinkContext.Resolve (IMetadataScope scope) [0x00000] in <filename unknown>:0
at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00000] in <filename unknown>:0
at Mono.Linker.Steps.LoadReferencesStep.ProcessAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00000] in <filename unknown>:0
at Mono.Linker.Steps.BaseStep.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0
at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0
at MonoTouch.Tuner.Linker.Run (Mono.Linker.Pipeline pipeline, Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0
mtouch exited with code 1
我努力地补充道:
System.DirectoryServices.dll
System.Configuration.dll
System.Security.dll
System.DirectoryServices.Protocols.dll
System.EnterpriseServices.dll
越来越感觉没有走上正轨,但当mtouch抱怨原生System.EnterpriseServices.Wrapper.dll时,我放弃了。
我尝试使用Project Options / iPhone build SDK和Linker选项。
我也尝试了32位和64位版本的Microsoft.Exchange.WebServices.dll
P.S。我知道我可以在没有Managed EWS API的情况下使用EWS,但是编写和解析所有这些XML请求和响应是非常痛苦的。
答案 0 :(得分:1)
MonoTouch的链接器和AOT编译器在完成工作时都需要存在所有依赖项。那个和缺少的符号(类型,方法......)使得从另一个版本的框架重用预先构建的二进制文件变得困难(但并非完全不可能)。
它还解释了为什么有时可以(没有丢失的符号)在模拟器上工作。默认情况下,模拟器构建设置为“不链接”(无链接器),并且使用 JIT (无AOT)。这样就可以忽略缺失的引用/符号......直到它们(可能永远不需要)为止。
您可以关闭设备构建的链接器 - 但这对AOT编译器没有帮助。 OTOH你可以尝试来满足链接器,可以能够删除足够的代码让AOT编译器正常工作。遗憾的是,当事情归结为本机代码时,例如 System.EnterpriseServices.Wrapper.dll ,您的选项会变得更加有限。
答案 1 :(得分:0)
您不能将Windows DLL与MonoTouch一起使用 - 它不是针对iOS架构编译的。你必须有一个专门为MonoTouch编译的DLL,或者如果你有源代码,你可以自己构建它。