Quantcast
Channel: Xamarin.Mac — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 1429

NSApplication.Init() finding missing 'dependencies'

$
0
0

Hello! I am porting to Xamarin.Mac a set of interconnected assemblies which constitute a windows service.
I have recreated their source trees in Xamarin.Mac projects and they compile. I have another application-type project which is intended to wrap and serve as an entry point for the services assemblies. This other project does some minor installation stuff that requires NSTask, so I have to call NSApplication.Init() or the construction of NSTask (an NSObject) throws a null reference exception. This works fine, until I add code to call my Service.EntryPoint.Main(), at which point the NSApplication.Init() call suddenly starts throwing a missing DLL exception

System.IO.FileNotFoundException: Could not load file or assembly 'System.Web' or one of its dependencies
  at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) [0x001e8] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.8.2.22/src/mono/mcs/class/corlib/System/AppDomain.cs:777 
  at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
  at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.8.2.22/src/mono/mcs/class/corlib/System/AppDomain.cs:714 
  at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName)
  at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.8.2.22/src/mono/mcs/class/corlib/System.Reflection/Assembly.cs:606 
  at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1 assemblies, System.Reflection.Assembly assembly) [0x0001c] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/src/ObjCRuntime/Runtime.cs:339

So, I gather that for whatever reason NSApplication.Init() is reflecting through the code, I guess preloading assemblies or something. But, why does it think I need System.Web? It's obviously getting that idea from examining the other code I linked in, but none of those other projects even reference System.Web, and they all compile.

I have found I can just put NSApplication.Init() in a try block and throw away the exception, and then I am able to continue and even create NSObjects. But I assume whatever NSApplication.Init() was doing got interrupted, so is it in an unstable state now?


Viewing all articles
Browse latest Browse all 1429

Trending Articles