Problem loading Assemblies in MonoTouch Project

柔情痞子 提交于 2019-12-09 13:48:25

问题


I am building a Monotouch (trial) 4.0.3. project. It compiles with the warning:

Warning: Library 'loader.dll' missing in app bundle, cannot extract content

All of the other dlls are successfully bundled during build, and this one was working before. After compiling with the warning, it crashes on load at runtime (on the simulator) with a segmentation fault when it fails to load the assembly.

I have searched for this warning and I haven't been able to find any references to it. Does anyone know why the assembly is not being added to the app package?


回答1:


It sounds like the linker is removing the loader.dll because it thinks nothing uses it. Try setting the project's linker setting to "link sdk only".




回答2:


mhutch is correct, the linker is opportunistically pruning out the library. However, the default linker setting is not to link anything, so his solution will only work in the rare case that you're linking all assemblies (which you don't want to do with MonoTouch because references to the SDK should never be embedded).

The workaround is to just new up an instance of something in the library you want to use, from inside the calling assembly.

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MyLibrary;

namespace MyApp
{
    public class Application
    {
        static void Main(string [] args)
        {
            new MyLibrary.DontPruneMeBro();

            UIApplication.Main(args, null, "AppDelegate");
        }
    }
}

As an aside, I don't know what iOS developers do, since this behavior would make run-time access to satellite libraries impossible.



来源:https://stackoverflow.com/questions/6298439/problem-loading-assemblies-in-monotouch-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!