Many applications end up working perfectly on the developer's machine. However once the application is deployed into a setup package and ready for the public, the application could suddenly give the user the most horrible experience of his life. There are plenty of issues that developers don't take into consideration. Amongst the many issues, 3 can stand above the rest if the application isn't tested thoroughly:
To prevent issues from arising and having to re-deploy continuously which would only result in embarrassing yourself and the company, there are certain procedures to follow to make sure you give the user a smooth experience when installing your application.
Wise has a Dialog that prompts the user for the installation directory:
✅ Figure: Wise Prompts the user for the installation directory and sets the path to a property in wise called "INSTALLDIR"
An embedded script must be used if the pathname is necessary in the application (i.e. like .reg files that set registry keys in registry)
The .reg file includes the following hardcoded lines:
'[HKEY_CLASSES_ROOT\SSWNetToolkit\shell\open\command]<a href="mailto:%27@=%22\%22C:\\Program">@="\"C:\\Program</a>Files\\SSW NetToolKit\\WindowsUI\\bin\\SSW.NetToolkit.exe\" /select \"%1\""
This should be replaced with the following lines:
'HKEY_CLASSES_ROOT\SSWNetToolkit\shell\open\command'<a href="mailto:%27@=%22\%22REPLACE_ME\">' '@="\"REPLACE_ME\'</a>" /select \"%1\""Dim oFSO, oFile, sFileSet oFSO = CreateObject("Scripting.FileSystemObject")sFile = Property("INSTALLDIR") & "WindowsUI\PartA\UrlAcccess.reg"Set oFile = oFSO.OpenTextFile(sFile)regStream = oFile.ReadAll()oFile.CloseappPath = Replace(Property("INSTALLDIR") & "WindowsUI\bin\SSW.NetToolkit.exe", "\", "\\")regStream = Replace(regStream, "REPLACE_ME", appPath)Set oFile = oFSO.OpenTextFile(sFile, 2)oFile.Write regStreamoFile.Close
Figure: The "REPLACE_ME" string is replaced with the value of the INSTALLDIR property in the .reg file
this.pictureReportSample.Image = Image.FromFile(@"Reports\Images\Blank.jpg");
❌ Bad code - FromFile() method (as well as Process.Start()) give the relative path of the running process. This could mean the path relative to the shortcut or the path relative to the .exe itself, and so an exception will be thrown if the image cannot be found when running from the shortcut
string appFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location;string appPath = Path.GetDirectoryName(appFilePath);this.pictureReportSample.Image = Image.FromFile(appPath + @"\Reports\Images\Blank.jpg");
✅ Good code - GetExecutingAssembly().Location will get the pathname of the actual executable and no exception will be thrown
This exception would never have been found if the developer didn't bother to test the actual installation package on his own machine.