如何将资产文件包含在ARM平台的.NET Standard 1.4库中?

编程入门 行业动态 更新时间:2024-10-25 08:26:44
本文介绍了如何将资产文件包含在ARM平台的.NET Standard 1.4库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果平台是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库中?

本文发布于:2023-11-17 05:49:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609051.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   库中   资产   文件   平台

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!