如果平台是ARM,那么谁都知道引用资产的正确方法是什么? 在x86中,我可以使用appX文件夹进行链接,但是在ARM上不起作用
Anyone know what is the correct way of referencing assets if the platform is ARM? In x86 I can use appX folder with linking but its not working on ARM
谢谢
推荐答案如果要从.NET Standard库获取资产文件,则需要将文件标记为EmbeddedResource和Copy Always.
If you want to get assets files from a .NET Standard library, you would need to mark the file as EmbeddedResource and Copy Always.
然后,您需要添加一种方法来在.NET Standard库的类中获取这些文件.例如:
Then, you need to add a method to get these files in your .NET Standard library's class. For example:
namespace ClassLibrary1 { public class Class1 { public static Stream GetImage() { var assembly = typeof(Class1).GetTypeInfo().Assembly; Stream stream = assembly.GetManifestResourceStream("ClassLibrary1.Assets.dog.jpg"); return stream; } } }请注意此行assembly.GetManifestResourceStream("ClassLibrary1.Assets.dog.jpg");
ClassLibrary1是名称空间,Assets是库项目中的Assets文件夹,dog.jpg是文件.
The ClassLibrary1 is the namespace, the Assets is the Assets folder in the library project, the dog.jpg is the file.
在我的示例中,我将图像文件放在Assets文件夹中,如果将其放在项目的根目录中,则此行应如下所示:
In my sample, I put the image files in the Assets folder, if put it in root directory of project, then, this line should be like this:
assembly.GetManifestResourceStream("ClassLibrary1.dog.jpg");
您可以使用以下代码查看所有嵌入式资源:
You could use the following code to see all embedded resource:
foreach (var res in assembly.GetManifestResourceNames()) { System.Diagnostics.Debug.WriteLine("found resource: " + res); }然后,在您的主项目中,您可以调用此方法来获取这些文件.
After that, in your main project, you could call this method to get these files.
更多推荐
如何将资产文件包含在ARM平台的.NET Standard 1.4库中?
发布评论