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 external 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.
Related
This is starting to annoy me. I have a UWP that allows you to open up a separate windows forms app to take advantage of tesseract. The app works fine when running on its on, however as soon as I call upon it to run using the UWP, the app crashes and gives me the error that it could not find the file specified, that file being the tesseract folder. I have it referenced within the app as
var path = "C:\\Users\\dan\\source\\repos\\TesseractApp\\packages\\Tesseract.4.1.1";
Is this something really simple I'm missing? If anything I'd like to copy the Tesseract.4.1.1 folder to directory, but that doesn't seem to work either. Hopefully this is clear.
EDIT - I believe it is just the exe file not working properly. I think I'm not copying over enough files into the Assets folder of the UWP and the exe of the tesseract app does not have what it needs to work.
I'm new to Xamarin.Forms and I am finding it impossible to change the application's icon for my app.
I used a cross-platform template in VS2017. I changed all the icon files in #mipmap-XXXX. When I run in the emulator the app icon changes but not on my device.
Does anyone have a proven method for getting this working. I'm sure it's possible but I can't find any information that helps.
If you're creating projects using the newest VS/Xamarin update, you should notice a folder in the Android project (under Resources) called mipmap-anydpi-v26, or similar. In this folder, you will find two XML files: icon.xml and icon_round.xml. If you open these files, you'll notice that they reference :
launcher_foreground - your icon image.
launcher_background - background color of your icon, mainly used for round icons.
When you are assigning the app icon and you reference icon, you are actually referencing the XML file, not the images. The XML file then retrieves the correct image size from the other mipmap folders.
Thanks both for your comments. However, neither completely solved the problem. In the end I looked in the file system and removed all icon.png images. I cleaned and rebuilt the app and nothing changed when I deployed it. I then repeated the above on all the launcher_foreground.png files and replaced them with appropriately sized ones. Now my application icon is what I wanted.
I seems that even though there is a icon.png file in each of the mipmap-xxxx folders, it is the launcher_foreground.png file that holds the application icon.
I am creating a PDF document, using MigraDoc. The image is located in the root folder of the project, so I use this code to insert it in the PDF-document:
Image img = tfLogoDate.AddImage("../../db_logo_500p.png");
The Build Action is set to 'Content':
This works fine during development, using the Visual Studio debug build. But when I create a build with ClickOnce (publish), it says that the image is not found.
Am I using the wrong Build Action? Or is it because the relative path changes, when I use ClickOnce to publish my application?
I found a way to make it work, by changing the image location. I now use this instead:
// I have added the 'pack://(...)' in front of the path
Image img = tfLogoDate.AddImage("pack://application:,,,/../../db_logo_500p.png");
I had to use the following settings for the PNG-file:
Build Action: Content
Copy to Output Directory: Do not copy
If anyone knows exactly why the above works, I would be delighted to know. But the most important thing is, that it works...
I have a question which will probably be quite vague.
I'm developing a Windows Forms application in C# that can read and write games to an Access database. Every game has an attribute that links to an Image in the resource folder.
While debugging I was able to just read and write my screenshots to the following path:
"..\\..\\Resources\\Screenshots\\";
I tried publishing my application earlier today to test if it would still work and if not, to locate the path where the Resource folder would be when published.
So far I have the feeling that the resources just get burned into the exe file or one of the other files it generates.
Is it in any way possible to have a real folder in the published version of an application from which I can keep reading and writing my images like I did while debugging?
Thanks in advance.
Yes your screenshots will be compiled into the assembly as resources when publising.
As for the real folder, you can absolutely do that. Make sure you give your app the right path to that folder.
I don't know if I asked it right, but basically what happened is that I made a winform app which loads its image from the resource folder.
The problem is that when I build the project and get the exe and give it to a friend, he won't have that resource folder like I do, so he'll get an error saying missing file.
How can I somehow mix, or combine, or attach the image with my app?
You need to add it to the project by navigating to the Properties Window and going to the resource tab and adding the image from there.
Alternatively, from the PictureBox Control you can import resource from your computer.
if you don't need to update it in the future, compile your program with the image property build action set to embedded resource.
if you need to change it in the future compile with property build action set to content.