从Monodroid类库访问资产 [英] access assets from monodroid class library
问题描述
是否可以从引用类库的Monodroid应用程序中的Monodroid类库访问文件(使用构建动作"AndroidAsset")?
Is it possible to access files (with build action "AndroidAsset") from a monodroid class library in a monodroid application that references the class library ?
我已经在类lib中创建了一个资产"文件夹,并添加了一个带有构建动作"AndroidAsset"的文本文件,但是从应用程序中,我无法通过Assets.Open("file.txt"); 访问它.
I have created an "Assets" folder in the class lib and added a text file with build action "AndroidAsset", but from the app I could not access it via Assets.Open("file.txt");
我希望类lib和主应用程序中的资产可以以某种方式合并" ...
I was hoping that the Assets from the class lib and the main application could somehow be "merged"...
推荐答案
否-您不能从类lib中访问资产,只能从主exe项目访问.
No - you a can't access the assets from a class lib - only from the main exe project.
这类似于Java Android项目的情况.
This is similar to the situation with Java Android projects.
解决此问题的一种方法可能是改为使用嵌入式资源-请参阅我在xamarin论坛上询问的此问题的答案-
One route around this might be to use embedded resources instead - see the answer to this question I asked on xamarin's forums - http://forums.xamarin.com/discussion/186/is-there-a-cross-platform-way-to-include-string-resources-from-class-library-projects - note that I haven't tried this yet
这篇关于从Monodroid类库访问资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!