icon in task bar will not change when winform is published - winforms

I have a winform app running on .net 4. When a certain condition happens, the icon running in the task bar changes from ping_logo to ping_logo_red. (the icon i'm talking about is the one that shows up when you run an application. You click on it and it will restore the windows to the screen or minimize it) The way that the icon is changing is as follows.
I added the ico files as Resources. In the code I change the resource being used
Me.Icon = My.Resources.ping_logo_red
Here is the thing. This works when I run the exe from my machine from the solution bin/release folder. When I publish this and install it from the published location, the icon does not change.
In the publish tab under the project both ping_logo.ico and ping_logo_red.ico are included in the publish status.
what have I not done that is keeping the icon from working in the published app. I've tried to uninstall the app and install it fresh but that doesn't seem to make a difference.
thanks
shannon

If you are using ClickOnce to publish your application then you need to set the icon property in the properties window of your project.
Right click your project -> Properties
Go to application tab
Select your icon file towards the bottom.
Another idea is changing the CopyToOutput property of your .ico file to "Copy Always" or "Copy If Newer".

Related

How to add new images in Visual Studio 2017 WPF application?

I am failing to find fast way to add images in Visual Studio 2017 WPF Application.
In previaus versions you could Browse for new images and add to Resources folder.
Are these features removed?
Before:
Now:
Double click the project Properties item in Solution Explorer
Go to the Resources tab
Click on the small downward triangle next to "Add Resource" and select "Add Existing File". This will open a file selection dialog. Navigate to your images folder and select the images you want to include.
This will create a Resource folder in your project.
In solution explorer, select each image in turn and change the Build Action in Properties to Content or Resource.
You should simply be able to drag and drop it in, try rebuilding the project and ensuring the image is set as a resource file. If its still not working try closing down and reopening visual studio.

Deploying Silverlight Application on IIS7

We have a silverlight application written in Visual Studio (VS) 2010 and we want to deploy it on a Windows Server 2008 R2 box (IIS7). To deploy it in VS I did a right click on the MyProject.Web project, selected "Publish...", from the "Publish method" I selected "File System". I copied the folder over to "C:\inetpub\wwwroot" on the server. In IIS Manager I did a right click on the folder, selected "Convert to Application", a window popped up, where you can select the application pool. I selected the default (.NET 4), I clicked on "Test Settings..." it failed (that was a bad sign), clicked ok.
When I try to access the website from a browser a message box pops up saying do you want to open or save "MySilverlightApp"?
Basically, it wants to download the xap file like it would download a text file or a doc file, it doesn't "run" it.
I have checked the forums and most cases the issue is that the MIME file types are not set up, but I have checked that it's all looks good, and it should as well because on IIS7 it's all set up by default so I am puzzled a bit here.
Thanks for your help.
I have just realized that you tried something about mime types so I need to edit my answer. I want to share a link to provide you a guide. It may be helpful to see if you miss a point.
http://www.iis.net/learn/web-hosting/web-server-for-shared-hosting/configuring-iis-for-silverlight-applications
The route cause of the issue was that the XAP file (inside the ClientBin folder) was the default document.
When I set the aspx file (in the application root folder) as the default document, it started to work fine.

WPF installation

I'm new to WPF, and created a 1st simplistic WPF application that I want it to run in a webbrowser, IE or Fox.
1 - Within the Visual Studio project, I created a /Images folder with a few .jpg files
On the WPF xaml form I have 1 image and 1 button.
When application starts, the image displays /Images/img1.jpg
When User clicks the button the image must display /Images/img2.jpg
How can I force the VS publisher to include the Images folder? Apparently I can't see it in the ApplicationFiles ?
2 - Though I was able to program and run this small app on my local computer, I'm getting lost when it comes to deploying to my hosting ASP where I have a Windows hosting account that runs .NET 3.5!
From Microsoft WPF website they say I shall deploy 3 files:
"The Application Executable .exe
The Deployment Manifest .xbap
The application Manifest .manifest
The .xbap file contains the information that ClickOnce uses to deploy the application and has the .xbap extension."
But I can's see no .xbap files at all within the published stuff!!!
Any clue please?
To answer your first question:
The images will be embedded in the compiled application, so you will not see the images in the application files.
Note:
The build action of images added to your project is 'Resource' by default - leave this as is.
Do not use the resources tab in the Project properties window, just drop and drag the images into the Images folder in the solution explorer.
To help answer your second question:
Did you create the project as an WPF Browser Application?
In your .csproj file you should see the following:
<HostInBrowser>true</HostInBrowser>
<Install>False</Install>
<ApplicationExtension>.xbap</ApplicationExtension>
<TargetZone>Internet</TargetZone>
If not, just recreate the project as a WPF Browser Application and copy your files from the existing project to the new one.

How to make .exe file programmatically set to run as admin always in vista?

I have written a winform application in C#. When I run the program for some functionality it required admin permission. After Installation If I set the .exe file to run as admin manually (by clicking right mouse button on .exe file) then my program run perfectly.
Now I need user not to set the run as admin property after installation by clicking right mouse button. I need to set this programaticaly somewhere in the code that user no need to bother about this. This specific problem is only arise for Windows Vista. Can anyone help me out?
You need to add a manifest to the app that specifies it require admin privileges. Read more on MSDN.
Update: You can add a manifest to your project by right-clicking on the project and selecting Add / New Item / Application Manifest File. This will add a new file called app.manifest to your project and will reference it from the project properties, in the Manifest dropdown on the Application tab. The default manifest template even has a nice comments on how exactly to change the required UAC execution level.
You need to specify the requestedExecutionLevel in the manifest.
See here for a detailed explanation:
http://petesbloggerama.blogspot.com/2007/04/making-your-assembly-run-as.html

No "Start" menu shortcut using ClickOnce

I am publishing a .NET 3.5 SP1 WPF application through ClickOnce. By default, when the user clicks on the published link the application gets installed and a menu and shortcut are added to the client's Start/All Programs menu.
How can I prevent the shortcut/menu from being created? (Users need to run the application solely by clicking on the hyperlink to the ".application" file on a web page.)
For this behaviour, set it as online only. Project properties -> Publish -> "The application is available online only" (radio button).
It will still do the same local caching of files etc; it is mainly the start-menu that changes (I don't have a full list of the differences).
This can also be changed in the .application file by setting <deployment install="false"

Resources