 |
|
|
 |
|
|
 |
|
|
I'm receiving the following error when adding the autoupdate.dll file to my project:
"Could not load file or assembly 'AutoUpdate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
Not sure what gives.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
NOw when I add the code as a module for AutoUpdate.vb it gives me this error:
Starting a second message loop on a single thread is not a valid operation. Use Form.ShowDialog instead
Any ideas?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
hi friends,
how can i save and retrieve word file into sql database using vb.net 2005.
thanx Naresh Rajput
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
Hi there,
First of all, compliments for the usefull article. I was developing something similiar to this for a huge project long time before. The software I'm working on now is a software that contains a lot of logic builded inside class libraries (DLL files). Compiling the new version of the software will generate new references to the libraries by using keys on the .exe file side.
If the developer team distributes a new release of a single class library (dll file), we do not need to update the whole software package. We would like to update only the single class library file (dll file). By reading a central update file on a webserver we would like to download/update only the files needed to be updated and not the whole software package.
The problem I'm facing now are the references/codes compiled in the binary executable .exe file of the software. The new updated class library will not always be accepted, because the .exe file has in my opinion a reference key to each .dll file inculded in the project.
Is there a way to solve this problem? How can I update only the files that need to be updated (dll files) without having the issue with the reference keys. The class libraries should stay protected as they are. Am I missing something here? Any suggestions?
Regards,
Sead
|
| Sign In·View Thread·PermaLink | 3.00/5 (2 votes) |
|
|
|
 |
|
|
this blog suggests it won't work for those of us using MSI installers, as the installer will simply revert the application files back automatically. true?
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
Is it not a little dangerous to remove the ability of updating the AutoUpdate program itself?
What happens when a patch/fix is required for the AutoUpdate program, how do you see this scenario being performed ?
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
1. Create a project - click File -> New -> Project -> Class Library 1.1. Name it whatever you want (as long as its name is AutoUpdate ) 1.2. Rename Class1.cs to AutoUpdate.cs (accepting to rename all references) 1.2. Double click AutoUpdate.cs and paste (replace whatever is in there) the following
using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Diagnostics; using System.Windows.Forms;
/// <summary> /// Class to update .exe and .dll through HTTP connection /// </summary> /// <author>Eduardo Oliveira</author> /// <Modified_by>Danny (dbembibre@virtualdesk.es)</Modified_by> /// <history Danny> /// Changed: C# translated and retouched /// Changed: Added method IsUpdatable() to verify if a new update exists /// Changed: Now you can update any file without need of exe file /// Changed: If something went wrong, you have a collection to rollback all files to the original state ///</history Danny> /// <Modified>Tiago Freitas Leal, Feb. 2008 - v.2.1.1</Modified> /// <history TFL> /// Changed: General refactoring of names /// Changed: Refactoring of properties to constants (preparing for resources) /// Changed: Remote URI doesn't depend on assembly name /// Changed: Ignore heading "." and "\" on file paths /// Changed: Ignore second instance of same file path /// Changed: Add "=ExactVersion" option /// Changed: ".ToDelete" filenames are prefixed with the old filename (avoid duplicate names) /// Changed: "return" happens always after "Dispose" operations /// Changed: Merge "IsUpdatable" into "UpdateFiles" /// Changed: Move delete operations to new public CleanUp() method /// Changed: Files to be deleted are made NOT ReadOnly before deletion /// Changed: Delete operates also on sub-directories ///</history TFL> public class AutoUpdate { // <File Path>;<MinimumVersion> [' comments ] // <File Path>;=<ExactVersion> [' comments ] // <File Path>; [' comments ] // <File Path>;? [' comments ] // <File Path>;delete [' comments ] // ... // Blank lines and comments are ignored // First parameter - file path (eg. Dir\file.dll) // Second parameter: // If the version is specified, the file is updated if: // - it doesn't exist or // - the actual version number is smaller than the update version number // If the version is specified precedeed by a "=", the file is updated if: // - it doesn't exist or // - the actual version doesn't match the update version // If it's an interrogation mark "?" the file is updated only if it doesn't exist // If the second parameter is not specified, the file is updated only if it doesn't exist (just like "?") // If it's "delete" the system tries to delete the file // "'" (chr(39)) start a line (or part line) comment (like VB)
// Method return values // - True - the update was done with no errors // - False - the update didn't complete successfully: either there is no update to be done // or there was an error during the update
// NB - "Version" refers to the AssemblyFileVersion as configured in file AssemblyInfo.cs
private const string ToDeleteExtension = ".ToDelete"; private const string UpdateFileName = "Update.txt"; private const string ErrorMessageCheck = "There was a problem checking the update config file."; private const string ErrorMessageUpdate = "There was a problem runing the Auto Update."; private const string ErrorMessageDelete = "There was a problem deleting files.";
#region "CleanUp"
public static bool CleanUp() { try { string file;
DirectoryInfo dir = new DirectoryInfo(Application.StartupPath); FileInfo[] infos = dir.GetFiles("*" + ToDeleteExtension, SearchOption.AllDirectories); foreach (FileInfo info in infos) { file = info.FullName; File.SetAttributes(file, FileAttributes.Normal); File.Delete(file); } return true; } catch (Exception ex) { MessageBox.Show(ErrorMessageDelete + "\r" + ex.Message); return false; } }
#endregion
#region "UpdateFiles"
public static bool UpdateFiles(string remotePath, bool DoUpdate) { if (remotePath == string.Empty) return false;
if (DoUpdate) { // Delete files before updating them CleanUp(); }
// execute the following line even for check runs System.Collections.Generic.List<AutoUpdateRollback> rollBackList = new System.Collections.Generic.List<AutoUpdateRollback>();
string remoteUri = remotePath; WebClient myWebClient = new WebClient();
bool retValue = false; try { // Get the remote file string contents = myWebClient.DownloadString(remoteUri + UpdateFileName); // Strip the "LF" from CR+LF and break it down by line contents = contents.Replace("\n", ""); string[] fileList = contents.Split(Convert.ToChar("\r"));
// Parse the file list to strip comments contents = string.Empty; foreach (string file in fileList) { string fileAux; if ((file.IndexOf("\'") + 1 != 0)) fileAux = file.Substring(0, ((file.IndexOf("\'") + 1) - 1)); else fileAux = file; if (fileAux.Trim() != string.Empty) { if (!string.IsNullOrEmpty(contents)) contents = contents + (char) (Keys.Return); contents = contents + fileAux.Trim(); } }
// Parse the file list again fileList = contents.Split((char) (Keys.Return)); string[] info; string infoFilePath; String infoParam; List<string> fileNameList = new List<string>(); Version Version1, Version2; FileVersionInfo fv; bool IsToDelete; bool IsToUpgrade; foreach (string file in fileList) { info = file.Split(Convert.ToChar(";")); infoFilePath = info[0].Trim(); infoParam = info[1].Trim(); while (infoFilePath[0] == '.' || infoFilePath[0] == '\\') { infoFilePath = infoFilePath.Substring(1, infoFilePath.Length-1); }
// ignore path names already on list (duplicates) if (fileNameList.Contains(infoFilePath.ToLowerInvariant())) { continue; }
// add path name to list fileNameList.Add(infoFilePath.ToLowerInvariant()); IsToDelete = false; IsToUpgrade = false; string fileName = Application.StartupPath + @"\" + infoFilePath; string tempFileName = Application.StartupPath + @"\" + infoFilePath + DateTime.Now.TimeOfDay.TotalMilliseconds; bool FileExists = File.Exists(fileName); if ((infoParam == "delete")) { IsToDelete = FileExists; // The second parameter is "delete" if (DoUpdate) if (IsToDelete) rollBackList.Add(new AutoUpdateRollback(fileName, tempFileName + ToDeleteExtension, "Delete")); } else if ((infoParam == "?")) { // The second parameter is "?" (check if the file exists and it TRUE, do not update IsToUpgrade = !FileExists; } else if (infoParam != string.Empty && (infoParam[0] == '=' && FileExists)) { // The second parameter starts by "=" // Check the version of local and remote files fv = FileVersionInfo.GetVersionInfo(fileName); Version1 = new Version(infoParam.Substring(1, infoParam.Length - 1)); Version2 = new Version(fv.FileVersion); IsToUpgrade = Version1 != Version2; IsToDelete = IsToUpgrade; if (DoUpdate) if (IsToUpgrade) rollBackList.Add( new AutoUpdateRollback(fileName, tempFileName + ToDeleteExtension, "Upgrade")); } else if (FileExists) { // Check the version of local and remote files fv = FileVersionInfo.GetVersionInfo(fileName); // If 2nd parameter is empty, do nothing as file already exists if (infoParam != string.Empty) { Version1 = new Version(infoParam); Version2 = new Version(fv.FileVersion); IsToUpgrade = Version1 > Version2; IsToDelete = IsToUpgrade; if (DoUpdate) if (IsToUpgrade) rollBackList.Add( new AutoUpdateRollback(fileName, tempFileName + ToDeleteExtension, "Upgrade")); } } else { IsToUpgrade = true; }
if (DoUpdate) { if (IsToUpgrade) myWebClient.DownloadFile(remoteUri + infoFilePath, tempFileName); // Rename the file for future deletion if (IsToDelete) File.Move(fileName, tempFileName + ToDeleteExtension); // Rename the temporary file name to the real file name if (IsToUpgrade) File.Move(tempFileName, fileName); }
if (IsToUpgrade || IsToDelete) retValue = true; }
// This reruns the updated application //Process.Start(Application.ExecutablePath); // Don't use it here or you will end in an endless loop. } catch (Exception ex) { MessageBox.Show("There was an error. Trying to roll back"); if (DoUpdate) { foreach (AutoUpdateRollback rollBack in rollBackList) { if (rollBack.Operation == "Delete" || rollBack.Operation == "Upgrade") { if (File.Exists(rollBack.Renamed)) File.Move(rollBack.Renamed, rollBack.Original); } } MessageBox.Show(ErrorMessageUpdate + "\r" + ex.Message + "\r" + "Remote URI: " + remoteUri); } else MessageBox.Show(ErrorMessageCheck + "\r" + ex.Message + "\r" + "Remote URI: " + remoteUri);
retValue = false; } finally { myWebClient.Dispose(); // execute the following line even for check runs rollBackList.Clear(); }
return retValue; }
#endregion }
public class AutoUpdateRollback { #region Properties
private string _renamed, _original, _operation;
public string Operation { get { return _operation; } set { _operation = value; } }
public string Original { get { return _original; } set { _original = value; } }
public string Renamed { get { return _renamed; } set { _renamed = value; } }
#endregion
#region Constructor
public AutoUpdateRollback(string Original, string Renamed, string Operation) { _original = Original; _renamed = Renamed; _operation = Operation; }
#endregion } 2. Add a new project of type Windows Application named "AutoUpdateTest" 2.1. Add a reference to the AutoUpdate project 2.2. Rename Form1.cs to Startup.cs 2.3. Click View Code and paste (replace whatever is in there) the following
using System; using System.Diagnostics; using System.Windows.Forms;
namespace AutoUpdateTest { public partial class Startup : Form { public Startup() { InitializeComponent(); }
private void Startup_Load(object sender, EventArgs e) { Show();
//Change to reflect your RemotePath string RemotePath = "http://localhost/AutoUpdateTest/"; label1.Text = RemotePath; Form helper = new Updated.ShowVersionForm(); helper.Show(); MessageBox.Show("Checking if update is needed..."); if (AutoUpdate.UpdateFiles(RemotePath, false)) { MessageBox.Show("Update is needed."); if (AutoUpdate.UpdateFiles(RemotePath, true)) { MessageBox.Show("Auto Update succedeed!"); Dispose(); Process.Start(Application.ExecutablePath); Application.Exit(); } } else { MessageBox.Show("No update is available."); AutoUpdate.CleanUp(); } }
private void button1_Click(object sender, EventArgs e) { Close(); } } } 3. On IIS create a virtual directory named "AutoUpdateTest" 3.1. Put your sample files in there. 3.2. Put there an Update.txt like this one
\Updated2.exe ; 'Get Updated2.exe if it doesn't exist (ignore "\") .\Updated3.exe ; ? 'Get Updated3.exe if it doesn't exist (ignore ".\") .\Updated3.exe ; delete 'This line is ignored as it's the second instance of the same file path ..\Updated4.exe ; =1.0.0.3 'If actual Updated4.exe isn't this version, get it (ignore "..\") Updated5.exe ; delete 'Delete Updated5.exe Updated.exe ; 1.0.0.3 'If actual Updated.exe version is smaller than 1.0.0.3, get it 'Update2.exe ; delete 'ignore this line 'the lines below just test the same features on sub-directories TST\TSTUpdated.dll ; 1.0.0.1 TST\SubSub\SUBUpdated.dll ; 1.0.0.1 \TST\SubSub\Slash.dll ; 1.0.0.1 .\TST\SubSub\DotSlash.dll ; 1.0.0.1 .\TST\SubSub\Trash.dll ; delete 4. Build and execute AutoUpdateTest.exe
NB - If you have questions, just reply to this message. I'll receive a notification and will answer.
modified on Friday, February 8, 2008 6:54 PM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
yes,it can update while single folder,but how can i update with sub folder? any advise?
God helps those who help themselves
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
yeah,i got how to update subfolder, i had made a mistaken when i updated! thank you!
God helps those who help themselves
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
plz check it. i send yesterday a ticket to the Code Project team, but nothing happens, yet.
The old version works fine, but when i dont need the autoupdater.exe now, i will be change the updateSystem of my program!
regrads
modified on Friday, December 07, 2007 2:20:21 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
okay i use the C# code from dbembibre, build an DLL and use this in my VB.Net project.
THX dbembibre for the C# Code!!
EDIT: there is only a little bug in the C# code. When the Update.txt has NO Comment ('Comment) the return of "isUpdatable" is always false!
so i change all
string Aux = string.Empty;
to
string Aux = F;
modified on Monday, December 10, 2007 3:36:31 AM
|
| Sign In·View Thread·PermaLink | 4.00/5 (1 vote) |
|
|
|
 |
|
|
Thanks Eduardo,
This is a simple library, but perfectly adequate for a small project and really kicked me along in getting my function going.
Regards, Paul
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Ok maybe someone can help me out. It seems no matter what I do I keep getting a 404 error even after all the files listed in my Update.txt has been downloaded. I went step by step witht the debugger and after the last file I get the error message on 'System.Diagnostics.Process.Start(Application.ExecutablePath, Microsoft.VisualBasic.Command())'. Anyone else run into this.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
It seems that the updater can't find the program it is trying to start. Is the program still in the folder? Have you maybe changed it's name during update?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Will this code work for updating a BHO written in C#? taking in concern that the update will be on DLLs not Executables and also registering and de-registering in the GAC.
Thanks in advanced
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I have been trying to get this application to function. I see that a new file is created with a series of numbers and ending extension of.ToDelete as well as a new application executable but the download never completes before I receive a DOS windows 16-Bit I/O SubSytem error asking me to close or ignore. I have tried to ignore it but this does nothing. I am currently compiling the code under VB.NET 2005.
Jerry
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
I'm curious why you used a custom GetVersion function to convert the Version number into a zero padded string for comparison? Why can't you use the .NET built in Version class? One of the problems with the first auto-update version was that version were string compared instead of Version compared.
I modified the GetVersion function to be:
Private Function GetVersion(ByVal Version As String) As Version Return New Version(Version) End Function
Or, I could replace all instanced of GetVersion() in the code with New Version().
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
This code worked great (after a minor tweak to work with version 1.1 of the framework). Here is the change I made:
Dim Contents As String Dim myDatabuffer As Byte() = MyWebClient.DownloadData(RemoteUri & UpdateFileName) Contents = System.Text.Encoding.ASCII.GetString(myDatabuffer)
Thanks again for the code!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
can i ask a sample for the update.txt...
something with folders and files... if its ok with you.....
hello
|
| Sign In·View Thread·PermaLink | 1.80/5 (3 votes) |
|
|
|
 |
|
|
seconded. any chance of a sample 'MyUpdate.dat' file? I don't see one in the download. Thanks!
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
|
myfile.exe;1.0.0.5 *.ToDelete;delete
Save it as a .txt or .dat
First line is the file you would like to be downloaded Second line is the file(s) you would like to be deleted.
* Remember to make the assemblyversion in VB .Net equal to the version in the updatefile * If you use .dat as updatefile, create .dat as a MIME type if you use IIS.
Eelco
P.s. in the source comments this is provided as well (maybe not so clear, but understandable.
|
| Sign In·View Thread·PermaLink | 3.50/5 (3 votes) |
|
|
|
 |