简体   繁体   English

EXE 文件未使用所需的图标进行编译

[英]EXE file not getting compiled with required icon

I have a VSTO application that is developed as an add-in for Outlook using .NET. When I build the application (in Release or Debug mode), I get 2 files, one is <project_output>.MSI and the other is setup.exe file.我有一个 VSTO 应用程序,它使用 .NET 作为 Outlook 的加载项开发。当我构建应用程序时(在发布或调试模式下),我得到 2 个文件,一个是 <project_output>.MSI,另一个是 setup.exe文件。 My goal is to change the default icon of the setup.exe file.我的目标是更改 setup.exe 文件的默认图标。

  1. I have tried changing it by opening the setup.exe file in Visual Studio and importing the icon, this seems to do the trick but I don't think it is a good solution as every time I build, I would have to do that.我尝试通过在 Visual Studio 中打开 setup.exe 文件并导入图标来更改它,这似乎可以解决问题,但我认为这不是一个好的解决方案,因为每次构建时,我都必须这样做。

  2. I have tried this as well, where I specified the image file(.ico) in project properties.我也试过这个,我在项目属性中指定了图像文件(.ico)。 . . This is not working.这是行不通的。 I tried ending the explorer.exe task and re-running it (it was mentioned in one of the answers in StackOverflow, and helped in clearing cache).我尝试结束 explorer.exe 任务并重新运行它(它在 StackOverflow 的一个答案中提到,并帮助清除缓存)。

The requirement is the setup.exe file should have the icon that I set (in any way using visual studio) and not the default icon on building the project(in any mode) .要求是setup.exe 文件应该有我设置的图标(以任何方式使用 visual studio)而不是构建项目时的默认图标(在任何模式下)

image of output setup.exe output setup.exe 的图像

Thanks in advance.提前致谢。

You can change the Icon of Form in the Form Properties.您可以在表单属性中更改表单的图标。

• You can also use the application Properties, Project > "Project Name" Properties > Application > Icon and Manifest ( Select the Icon that you want ) • 您还可以使用应用程序属性,项目 >“项目名称”属性 > 应用程序 > 图标和清单(Select 您想要的图标)

Once done, select the form and double click until you hava the Form_Load, under it type完成后,select 表单并双击直到您拥有 Form_Load,在其下方键入

this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); 

for NotifyIcon type对于NotifyIcon类型

NotifyIcon.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);

You can also set the icon for other forms也可以设置其他图标 forms

Form2 frm2 = new Form2(); 
frm2.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);

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

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