Include data files when publishing a WPF App [duplicate] - wpf

I am trying to deploy my first WPF, C# application to many desktops. For most records in the case database there is a large PDF which I want to store separate from the database and is displayed when a button is pressed (PDF filename equals the id number). It is a search only program, no data is being saved back to the database by users. There are approximately 32,000 pdfs and this number will grow. When I tried to list these files in the project and use ClickOnce to Deploy VS said I had exceeded the maximum manifest size.
Is there a way to deploy my app with ClickOnce and then copy the files with some type of post-install command? Thank you.

Add the files to your project. Mark the Build Action as Content and the Copy to local directory to Always. Then it will include the files with your deployment.
You can also check the Application Files dialog to see if they are there. And if the files have a file extension of XML or something that indicates data, you want to change the option from Include(Data) to Include or Include(Required). If you include a file as data, it is put in the DataDirectory after deployment.
Select a data file in Solution Explorer.
In the Properties window, change the Build Action property to the Content value
2. To mark files as data files
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Publish tab.
Click the Application Files button to open the Application Files dialog box.
In the Application Files dialog box, select the file that you wish to mark as data.
In the Publish Status field, select Data File from the drop-down list.
3. To mark files as prerequisites
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Publish tab.
Click the Application Files button to open the Application Files dialog box.
In the Application Files dialog box, select the application assembly (.dll file) that you wish to mark as a prerequisite. Note that your application must have a reference to the application assembly in order for it to appear in the list.
In the Publish Status field, select Prerequisite from the drop-down list.
Source: MSDN - How to: Specify Which Files Are Published by ClickOnce

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.

icon in task bar will not change when winform is published

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".

Including sqlite.db file in a WPF ClickOnce deployment

I built a small app with VS 2010 in WPF. I have used to store data in SQL lite. I have bound a dropdown field from SQL lite dataconnection.
When I run this application in VS it was worked fine. And published it as a click-once app.
I have added SQL Lite.db file to application files and it appears in Project Properties ->
Publish tab -Application Files.
I set the file's Build Action to "Content", and in
Application files, set it to "Include".
But still the dropdown field doesn't have any values.
most likely the path to database gets lost. See Accessing Local and Remote Data in ClickOnce Applications - you need to make your sqlite file as Data (not Content as you did), and use ApplicationDeployment.CurrentDeployment.DataDirectory folder as a base folder for it.

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

Resources