发布后图标不起作用

编程入门 行业动态 更新时间:2024-10-27 09:36:48
本文介绍了发布后图标不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个简单的应用程序。单击按钮时,tasbar图标会发生变化。当我从visual studio运行这个应用程序时,一切正常,但是当我发布WPF应用程序时,任务栏图标不起作用(没有)。

I have a simple application. When you click a button, the tasbar icon changes. When I Run this app from visual studio, everything works fine, but when I publish the WPF app, the taskbar Icon does not work (there is none).

构建动作设置为嵌入式资源/总是复制,我也测试了资源但它不起作用。

The build action is set to "embedded resource/copy always", I have tested "Resource" as well but it doesn't work.

var iconUri = new Uri("pack://application:,,,/images/internet_connection.ico", UriKind.RelativeOrAbsolute); this.Icon = BitmapFrame.Create(iconUri);

框架左上角的图标发生变化,但任务栏中的图标没有变化。

the icon in the top left corner of the frame changes, but the one in the taskbar doesn't.

有人可以帮我吗?

@Edit,

感谢@ Pavel的评论,我得到了它的工作。但现在仍然存在一个问题:

I got it to work thanks to @Pavel's comment. But now one problem remains:

当我在visual studio中运行它时,我这样做:

When I run it in visual studio, and I do this:

var iconUri = UriHelper.GetUri(this.GetType(), "images/local_network.ico"); this.Icon = BitmapFrame.Create(iconUri);

图标发生变化。但是对于已发布的版本,它不会改变。

The Icon changes. But with the published version, it doens't change.

@@编辑,

好的这是当我按下按钮时的代码:

Ok so this is my code when I press a button:

var iconUri = UriHelper.GetUri(this.GetType(), "images/internet_connection.ico"); this.Icon = BitmapFrame.Create(iconUri); mNotifyIcon = new NotifyIcon { BalloonTipText = "The app has been minimised. Click the tray icon to show.", BalloonTipTitle = "The App", Text = "The App", Icon = BitmapFrame.Create(iconUri) }; BitmapImage image = new BitmapImage(); image.BeginInit(); image.UriSource = UriHelper.GetUri(this.GetType(), "images/internet_connection.png"); image.EndInit(); TaskbarItemInfo = new System.Windows.Shell.TaskbarItemInfo() { Overlay = image };

它做什么:从VS运行时:任务栏中的图标发生变化,覆盖层工作,应用程序顶角的图标发生变化。

what does it do: When running from VS: the icon in the taskbar changes, the overlay works, the icon in the top corner of the application changes.

构建运行exe后:任务栏中的图标不会改变,覆盖层工作,应用程序右上角的图标发生变化。

After build running the exe: the icon in the taskbar DOES NOT change, the overlay works, the icon in the top corner of the application changes.

任何人都可以解释一下吗?

Can anyone explain this ?

推荐答案

我认为这条线适合你(你忘了......;组件/....):

i think this line works for you (you have forgot the ...;component/....):

var iconUri = new Uri("pack://application:,,,/YourProjectName;component/images/internet_connection.ico", UriKind.RelativeOrAbsolute);

图标使用

Build Action = Resource Copy to OutputDirectory = Do not copy

更多推荐

发布后图标不起作用

本文发布于:2023-11-13 12:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584346.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图标   不起作用

发布评论

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

>www.elefans.com

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