简体   繁体   English

C# Class 库 - 将图像构建操作更改为资源会将其从项目中删除

[英]C# Class library - Changing image build action to resource removes it from the project

I have a C# class library project, in which I would like to use some images as assets.我有一个 C# class 库项目,我想在其中使用一些图像作为资产。 However whenever I change the build action to "Resource" the file gets excluded from the project and I cannot include it again.但是,每当我将构建操作更改为“资源”时,该文件就会从项目中排除,我无法再次包含它。 Did I miss something or why does the file remain excluded.我错过了什么或者为什么文件仍然被排除在外。

@DeJoon. @DeJoon。

Base on my test, change the build action to "Resource" the image will get excluded from the project in C# class library (.Net Core/.Net 5).根据我的测试,将构建操作更改为“资源”,图像将从 C# class 库(.Net Core/.Net 5)中的项目中排除。

In the C# class library (.Net Framework) change the build action to "Resource" the image is displayed correctly in the project.在 C# class 库(.Net Framework)中,将构建操作更改为“资源”,图像在项目中正确显示。

You could try the following steps您可以尝试以下步骤

  1. Right-click the project and select Unload Project.右键单击项目并 select 卸载项目。
  2. Right-click the project and select Edit Project File.右键单击项目并 select 编辑项目文件。 Make sure your file is as follows:确保你的文件如下:

在此处输入图像描述

3.After saving the file, right click on the project Reload Project, and then you can see the image. 3.保存文件后,右键单击项目Reload Project,即可看到图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM