XamlParseException on System.Drawing.Icon in WPF C#
I set up a NotifyIcon to store my application in the system tray. For the Icon I was using
myNotifyIcon.Icon = new System.Drawing.Icon(@"c:\MyIcon.ico");
and this works. However I would like to store my icon in my project directory and refer to it where I deploy my app rather than have some ex开发者_StackOverflowternal image. i tried just
myNotifyIcon.Icon = new System.Drawing.Icon("MyIcon.ico");
and this where i get the XamlParseException when I try to run the app. The image does exist in the root of my project. Does anyone know the solution to this? Should I be using a PNG instead? I tried researching Pack Uris but i was just getting more confused and i am not sure thats what i need here. Thanks!
It sounds like you are not copying the icon to the deployment directory on build. Make sure the .ico is sitting alongside your .exe rather than just in your project directory.
精彩评论