I have an application that is running fine.
I just want to add the auto update feature in that application so that the application can automatically download the updates and install it on the computer.
The easiest way to do this is to make your application a ClickOnce application. It is a method of application deployment which has a very simple process for deploying new versions and having the client check for and install updates. Here is a CodeProject articles which has a full overview
http://www.codeproject.com/KB/install/QuickClickOnceArticle.aspx
It depends on how your application is structured and what kind of files you want to update.
But, basically, what you'll need is a "place" (like a WebService, for example), where your application will get the necessary info to update. Then it's downloading the necessary files and placing them in the correct folders.
I'd also advice you to write a new program, "updater", whose whole purpose it's to update your "main" program.
It's difficult to give you code on how to do this, as it it's more like a pattern that you'll have to implement.
Edit Also, as said by JaredPar, some platforms may provide tools to do this.
Related
I searched that question over the internet and here , and saw all kinds of different solutions.
The most common solution suggested was ClickOnce .
My problem is :
my application is a backup application.
It runs 24/7 , and I want the update to be automatically without any user interface.
As backup apps usually runs on servers and aren't monitored at all times.
ClickOnce offers great update solution but it is with user interface and it isn't what I need.
The best thing I could think of is to build a separate app that my main app will call it,
the update app will close the main , download the update , extract the update , and recallthe main app , and then close itself.
I have several problems with my approach :
1. Where to place the folder(named: Update) containing the update exe file and all dlls that is neccecery to update. Is it a good idea to place it inside my main app folder ?
2. What will happen if I need to update the update.exe file ?
I would really appreciate if you could shed some light in this matter with your experience.
You can programmatically run ClickOnce. Will that work for your purposes?
http://msdn.microsoft.com/en-us/library/ms404263.aspx
I need to develop an application that will run on clients. The main focus is to let the application update another -specific- application and be able to monitor own defined states for clients. I'm considering something like a console application with TopShelf because it makes debug a lot easier. However... to install or update this specific application I must use a MSI. But if for example I create a process that executes msiexec the client/end user will be prompt with UAC. This is a big issue because clients should be updated unattended. And UAC must stay the way it is : highest level.
I've read a lot of questions/answer concerning UAC prompt... and to be honest I'm starting to doubt my own approach. I was not able to find any question that I could relate to.. so I would appreciate it if someone could give me some good advise, tips, references etc on a possible way to approach this issue.
Thanks in advance
Create a Task Scheduler job with the "Run with highest privileges" option checked.
You can easily create this job programatically, even using a XML configuration file.
This way the user is prompted to allow UAC only once (when first clicking an exe for example).
I need to update my executable with also the dll linked..
I've read about the AppDomainSetup.ShadowCopyFiles but I'm in trouble trying the right steps to do what I need
the question are:
the shadow copy I need to create only when I notify an update or each time I launch my executable?
what is the right step to copy and update the dlls and the .exe?
Creating a shadow copy is not going to update your application. The general sequence of auto-updating requires a third application that manages the process. It looks something like this.
Main application finds update and downloads update files to temp location
Main application launches updater application and terminates itself
Updater application copies update files over main application files
Updater application launches main application and terminates itself
Obviously there is going to be error handling logic built in to this. But that is the general idea. Shadow copies are nowhere in there.
Making use of the shadow copy feature of .NET is not a bad idea. It will allow you to update your assemblies without having to exit the application BUT you will need to restart the application in order to run the updated version. Shadow copy will simply allow you to overwrite the assemblies and nothing else.
Note that you cannot enable shadow copy on the default AppDomain. This means that you will need a loader that will create the AppDomain, and execute your application. Have a look at this answer for the steps you need to take and for a simple implementation.
If all you want to do is allow updates to be installed without having to exit the application then this is the simplest approach I can think of.
You should also have a look at Microsoft's ClickOnce technology. It solves a lot of the common problems of deploying and updating .NET GUI applications.
I’m currently working on a Visual Studio 2010 setup Project and would like to know if the following is possible:
1) Run the setup project in a way that the default forms don’t show, instead I’d show my own custom form that subscribes to setup project events. This way I'd show install messages and increase my own progress bar.
2) If 1 is possible, I would need a way to specify the default location.
3) I have a separate library project, where I have a custom install class (inherits from “System.Configuration.Install.Installer”) from within the install handler I’d like to be able to show custom windows forms, and control choices made by the user. I guess this is possible by adding a reference to system.windows.forms, but would this be the correct way to go about this? If I couldn't hide the default install form, these custom forms would appear over the default install one and I think it would look too great.
Suggestions, links etc appreciated
Thanks!
*UPDATE 1 *
Could I launch an .msi from c# code but also passing in a value.?
Just what this guy does here:
link
But passing in a value... then from my custom install class I take actions depending on this value.
UPDATE 2
Seems like I can:
link code project
UPDATE 3
I'm considering in doing the following, I'll start testing with a winforms app.
1) Launch winforms application.
2) Make a few webService calls, display data, user makes selection.
3) As per link in update 1, launch process(silent mode) and per update 2, pass in selected values.
4) Use some cross process events mechanism (WCF) so that my custom install class can notify my form of the different steps its running and update progress bar and messages.
You can create custom forms but the declaration needs to be done inside MSI. You can show a custom dialog via a custom action but that will not help you much since msi does this:
Load custom action dll
If it is managed the CLR is started and your maanged code executed
When the custom action is left the dll is unloaded and the clr is shut down
This is done every time a custom action is called. This is one of the main reasons why custom actions are normally written in C++.
To be more flexible you should use the WIX toolkit which allows .NET integration as good as it can be with MSI. MSI itself knows nothing about .NET and is a world of its own.
MSI itself defines dialogs and controls inside the msi via tables like the Dialog and Control table.
You could create a dialog and store your state in a msi property between each several msi actions which need to happen e.g. to calculate the disc space for the selected features and so on. But I doubt that this solution will be performant and I fear that starting and shutting down the CLR so often inside one process will expose you to CLR bugs that no one has encountered before.
To set the target location you only need to call the MSI method MsiSetTargetPath which you can PInvoke very easy.
To disable the normal UI you can override it completely or partially vis MsiSetExternalUI but I have not tried to disable only specific dialogs. If you want to hide specific dialogs you should check the msi tables of your current MSI to check if you can set a msi property to make the dialog think it has already been shown.
Yours,
Alois Kraus
As far as I know the setup projects made by Visual Studio are very limited unless you use custom actions. These Custom Actions can take a lot of time to create and debug so it might be wiser to use a more mature/featured tools such as Installshield
EDIT As for showing windows using winforms: that is ok but: a nice setup allows a silent/scripted install, make sure you allow this. Another thing to look out for is machines not having .NET and thus not being able to show the Forms... IMHO that is a no-no unless you are sure .NET (correct version) is present.
EDIT 2 In response to some comments: There are some scenarios that can't be implemented with VISUAL STUDIO Setup and Deployment projects. I am not saying that Windows Installer is bad. E.g., Try to make a custom installer to decide where an application will be installed and skipping the standard window that the project generates. I am not saying that custom actions are limited but they are IMHO not easy either.
Also, when you want use custom WinForms instead of Installer forms you have to make sure that the bootstrap of the .NET framework is done BEFORE showing any (WinForm) windows. It might be possible but if you want such customisation you might be better of with a more flexible tool.
I wrote a console program in c# that takes up to three files as input, and does some data calculations on them.
I'd like to make a simple frontend that allows the user to easily
import files - basically choose up to three files to be routed to the backend code
change settings - I have about 10 settings that I'm currently storing in an app.config file. maybe a simple settings box would be nice
see what's going on - the console program shows some status messages that might be useful to display on a GUI
I have practically no experience with windows forms or GUI design, so I really don't know where to begin. I compiled the backend stuff into a *.dll and am currently playing around in design mode of sharpdevelop...but i really have no idea how to get the two to work together.
any pointers would be greatly appreciated!
The usual pattern, in cases like these, is to make the main features of the application into a class library and call that from a wrapping executable, such as a console app, winforms app or webforms app (if possible). That way you can easily adapt the interface as needed and simply route input and output to and from the class library.
Edit: I realize this isn't a very indepth answer, but I hope it helps to get started at least, together with any other answer that may arrive.
If you want to get started with GUI design in .NET, I recommend you choose WPF (Windows Presentation Foundation). This is the latest technology released in the UI/graphics area by Microsoft and is where everything is heading now. (Windows Forms won't be obsolete for a long time, though it is surely but slowly becoming deprecated.) I noticed however that you are using SharpDevelop, which doesn't yet have real support for WPF (as far as I know), whereas it certainly does for WinForms. If there's any chance you can use Visual Studio, I recommend you begin by learning WPF. You have the advantage of not being confused by previous experience with the styles and methodologies of WinForms, so it would very much be the right way to go.
Whichever you wish to learn, the Getting Started page of WindowsClient.NET (the official MS site for both WinForms and WPF) would be a great resource. There's also a few MSDN articles on getting started with WPF.
Hope that helps.
Have you tried Visual Studio Express editions? They're free and come with a designer for either WinForms or WPF applications.
As a first pass you'll need 3 text areas for the filenames, with associated buttons to bring up the file open dialog (it doesn't actually open the file just returns the filename).
A label to display the status - updated from your worker code.
Then either the various radio buttons, check boxes etc for your configuration settings.
Oh and don't forget the "Start" button to set off your process.
If your process takes a while you ought to use a background worker thread. You can then implement a "Cancel" button to safely abort the process and tidy up if it goes wrong.
There will be optimisations and reorganisations that you can do once you've got it working.
Your question is quite indistinct. If you're asking about working with GUI, you should read some book on Windows Forms.
And if you're asking about how to put your dll in your new windows forms application, then you should just add a reference to it in winforms project's properties and then use classes from dll's namespace.