3

I'm trying to build iOS app using Microsoft EWS managed API. I've downloaded the msi from http://www.microsoft.com/download/en/details.aspx?id=13480 and copied the DLL under the solution folder. When building for the simulator, it builds and runs fine, but when trying to target the physical device, mtouch fails with:

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

I diligently added:

System.DirectoryServices.dll
System.Configuration.dll
System.Security.dll
System.DirectoryServices.Protocols.dll
System.EnterpriseServices.dll

with a growing feeling of not being on the right track, but when mtouch complained about native System.EnterpriseServices.Wrapper.dll, I gave up.

I've tried to play with Project Options/iPhone build SDK and Linker options.

I've also tried both 32-bit and 64-bit versions of Microsoft.Exchange.WebServices.dll

P.S. I know that I could consume EWS without Managed EWS API, but writing and parsing all these XML requests and responses is such a pain.

poupou
  • 43,413
  • 6
  • 77
  • 174
Nina
  • 45
  • 8

2 Answers2

1

Both the MonoTouch's linker and the AOT compiler needs all dependencies to be present when doing their work. That, and missing symbols (types, methods...), makes it hard (but not totally impossible) to re-use pre-built binaries from another version of the framework.

It also explains why this can sometime (no missing symbols) work on the simulator. By default the simulator builds are set to "Don't link" (no linker) and the JIT (no AOT) is used. This allows missing references/symbols to go unnoticed... until they are (potentially never) needed.

You can turn off the linker for device builds - but that won't help the AOT compiler. OTOH you can try to satisfy the linker and it could be able to remove enough of the code to let the AOT compiler do its work properly. Sadly when things go down to native code, like System.EnterpriseServices.Wrapper.dll, your options becomes much more limited.

poupou
  • 43,413
  • 6
  • 77
  • 174
0

You cannot use a Windows DLL with MonoTouch - it is not compiled for the iOS architecture. You have to either have a DLL that was compiled specifically for MonoTouch, or if you have the source you can build it yourself.

Jason
  • 86,222
  • 15
  • 131
  • 146
  • 1
    Sorry, but that's not quite true. I referenced in MonoDevelop many assemblies built in Visual Studio from source and, yes, they work for both Simulator and iPhone. – Nina Nov 22 '11 at 20:16
  • 1
    Are you sure? From the MT FAQ - "To reuse existing .NET code with MonoTouch, you must recompile your libraries with MonoTouch's compiler and base assemblies." (http://support.xamarin.com/customer/portal/articles/136796-can-i-use-standard-desktop-mono-assemblies-or-net-assemblies-with-monotouch-) – Jason Nov 22 '11 at 20:26
  • Yes, I'm positive. But I suspect that my test assemblies were too simple and generic... I hoped there is some way to trick the linker, since the Simulator works fine, even though Microsoft.Exchange.WebServices references native DLLs – Nina Nov 22 '11 at 20:29