I am having a winform application and a visual studio installer set up project with the project output set to this winform application.
This winform gets invoked from a website as an msi installer which saves the values in the registry for invocation of the winform app the next time as a uri protocol scheme.
Now from the web I want to check 2 things:
1.) Is this application already installed on the client machine?
For this I can put a registry checking code to check for application installed or not
string regKey = #"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(regKey))
{
if (key.GetSubKeyNames().Any(keyName => key.OpenSubKey(keyName).GetValue("DisplayName") == "My App's Display Name"))
Console.WriteLine("Already installed...");
else
Console.WriteLine("Start installing...");
}
2.) What is the version of the application installed.
For the version, the registry values as described in point 1 also gives other parameters like "DisplayVersion" and "version, VersionMajor and VersionMinor".
So for the version what is the best way to update the assembly version of the winform application. Should I change the AssemblyInfo class of the winform app or should I change the version in the set up project properties?.
Set up project property:
Also in the registry I get following dword values of versions, how to decode these hexadecimal values to get the version number?.
Related
I have tried to create an .exe file to my WPF App and SQL Server related databse with EF Core using Windows Setup Installer Project.
I included all the dll's files from /bin/Release and built it for any CPU.
The Setup Project has been created successfully and it worked on my PC as I expected.
Otherwise when I try to install the Setup File on another PC, I can't even open it up and see what's wrong.
I guess the problem comes from the database but I can't find anything helpful on the internet.
So you get the application installed, run it and nothing happens, right? Here is what you do:
Run it. Watch nothing happen
Hit the Windows key and type "Event"
When "Event Viewer" appears in the list of applications, run it
In Event Viewer, go to Windows Logs >> Application
Near the top there will probably be an error entry. It will probably be related to your application. And if you were missing a key file needed to run your application, like a DLL, the name of the file will probably be in there in the details section
Go back to your installer and add that missing file. Or if that file is part of some support package (like, say, MS Redistributable for Visual C++) then add the installer for that too.
I need a single exe-file on a windows pc executing a .Net WPF program. This file must be signed with a code authentication certificat. With this certificat the exe-file is executed on foreign windows system without system warnings or administration rights after copy deployment by user to a trusted place.
I can do this with VS2019 and .Net 4.7.2. But I want go forward to VS2022 and .Net 6.0. Below a simple sample working with VS2019. You can step over signtool, because in VS 2022 already fails the posibility to create a single exe files. Same happens with VS 2019 and .Net 5.0 already in the past, but I find some post with information that single exe-file with WPF first work in future with .Net 6.0. Now, after release of .Net 6.0 and VS2022 I try it again. More options in deployment assistent for single file are available, but nothing creates a single exe-file!
Working process in VS2019:
I create WPF-App (.Net Framework) WPF4Test using .Net Framework 4.7.2
I put code sign command ("C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\signtool.exe" sign /a /n "my company name" /t http://timestamp.comodoca.com/authenticode $(TargetPath)) in postbuild step
I build release and enter password of certificate during sign process
bin\Release folder contains 3 files (WPF4Test.exe, WPF4Test.exe.config, WPF4Test.pdb)
I copy WPF4Test.exe to share folder and application is executable and signed
I test process in VS2022 with .Net 6
I create WPF-Application WPF6Test using .Net 6.0
I deploy Application in a folder (in assistant i must select folder twice) (default set configuration Release and destination runtime portable)
pubxml is created and i publish application
deployment folder contains 5 files (WPF6Test.deps.json, WPF6Test.dll, WPF6Test.exe, WPF6Test.pdb, WPF6Test.runtimeconfig.json)
I copy WPF6Test.exe to share folder, but application not start without error message
If I copy the whole folder to share and application run.
I can delete WPF6Test.deps.json and WPF6Test.pdb, but i need 3 files (WPF6Test.dll, WPF6Test.exe, WPF6Test.runtimeconfig.json).
I go back to VS2022 and add additional pubxml file with changed profil option (deploment mode independent, create single file, activate compile ready to run).
But now I get 7 files (D3DCompiler_47_cor3.dll, PenImc_cor3.dll, PresentationNative_cor3.dll, vcruntime140_cor3.dll, WPF6Test.exe, WPF6Test.pdb, wpfgfx_cor3.dll).
What do I have to do to get a single exe file?
How I can sign this exe file during publishing process?
You need to set 'IncludeAllContentForSelfExtract' in the project file or if you using the CLI to build 'IncludeNativeLibrariesForSelfExtract'.
Even if you tick or set single exe if you are producing a self contained exe it will not including the native libraries.
Project File (your-project.csproj)
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
.Net CLI
dotnet publish -r win-x64 /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --self-contained true
Edit your publish profile settings,
Select Deployment mode as Framework-dependent
Select the target runtime to something other than Portable (Produce single file is not available for Portable)
Under File Publish options, select Produce single file
Save the profile settings and try publishing again.
This should produce a single exe file.
If you select the Deployment mode as Self-Contained or independent, it will produce 7 files as you mentioned.
Hope this helps for publishing to a single file!
I am using a variation of Jeff Atwood’s Unhandled Exception handler it steps in when there is an Unhandled Exception in the application. It then logs the error, generates a screen shot and notifies the user.
When compiled in a solution the project generates an EXE that is called when needed. In updating the program I am using Visual Studio 13 to edit the existing settings items in the project properties. In the code I use commands such as this from ConfigurationManager.
string appProduct = unhandledExceptions.Properties.Settings.Default.AppProduct;
I was happy to see that it worked and reflected the changes I made in the IDE. However I couldn’t find the settings in the solutions generated confg file (MyApplication.exe.config). I assumed it was reaching back to the other project folder for the UnhandledExceptions.exe.config.
I created an installer and installed it to a virtual machine. My settings carried over, but again I could not see a config file.
It turns out the values are embedded in the executable UnhandledException.exe.
The project does not have any resources listed. Searching the web and StackOverflow looking a questions that want to do this, and there are a lot of them, it seems this was generally considered not possible and not desirable. Questions usually end in “You don’t want to do that, it’s called config for a reason”.
I may want to turn this off, so it is editable externally. The properties of app.config in both projects are identical.
What setting is making this possible after all? Is it a new capability with Visual Studio 2013?
There is no Visual Studio setting required. If you don’t want the user to have access to the configuration file, don’t include it in the distribution. One can always be added if the settings names are known.
In the description below application generically represents the name of the application being used.
I’ve found through observation some interesting things about the way ConfigurationManager works.
For User settings it will look in the following places in order of priority:
user.config for the application in the user’s AppData area
application.exe.config in the program folder
application.exe itself
Each setting is searched for individually. If your application requests a setting that is not found in either user.config or the application.exe.config it will get it from the executable.
For Application settings it looks in the following places in order of priority:
application.exe.config in the program folder
application.exe itself.
There is no equivalent to user.config for application settings.
Opening the application.exe in the Visual Studio IDE does not reveal a resource for the configuration information.
application.exe.config is handy because it can be modified externally and used as a default value for new installations. Once a setting is overridden in the user.config the value in application.exe.config is ignored.
The same is not true for the AppSettings section, the older configuration method from .Net 1.0. If I delete the configuration file it does not have them in the executable.
These observations were made with Visual Studio 2013 Update 4 and tested in Windows 7 Professional 64-bit. I suspect they are true in all versions.
'Hi all, I downloaded Xilium.CefGlue and built the source on Visual Studio (xilium-xilium.cefglue-b22787699e57), I also downloaded cef_binary_3.1453.1236_windows_xilium and copied the libcef.dll to the Xilium Winforms demo as the apps requires it to run but when I run it I get the following error:
An attempt was made to load a program with an incorrect format.
Exception from HRESULT: 0x8007000B
I've targeted x86, can I get some help?
Thanks
Ok, here's the steps I used to get the samples working in VS 2012:
Get the code from Xilium.CefGlue on github. (The one I used was c3d674a3a8)
Open the Xilium.CefGlue solution in VS2012
Remove or don't build the CefGlue.Demo.GtkSharp project (it didn't interest me & I didn't have the needed libraries)
In the Configuration Manager, select Active Solution Platform to be x86
Ensure that the target framework settings cooperate between projects. (e.g. CefGlue.Demo & CefGlue.Demo.WinForms by default are v2.0, but they depend on CefGlue which is v4.5) (For simplicity I set them all to v4.0 Client profile and it worked.)
Build solution — should succeed
Copy Xilium files from the unzipped cef_binary_3.1453.1236_windows_xilium to the output folder (bin\x86\Debug or bin\x86\Release). Minimum requirement seems to be:
libcef.dll and icudt.dll from .\Debug or .\Release
cef.pak and the locales\ folder from .out\Debug or .\Resources
Set CefGlue.Client as the StartUp Project
Run it
The code snippet below works absolutely fine on my development PC and another users PC.
The application was installed to the other users PC using 'ClickOnce'.
ReportWindow reportWindow = new ReportWindow();
Reports.rptDrawAmountSummary rpt = new Reports.rptDrawAmountSummary();
rpt.SetDatabaseLogon(clsArbitrageDB.userID, clsArbitrageDB.password);
reportWindow.crystalReportsViewer1.ViewerCore.ReportSource = rpt;
When I attempt to run the application installed (using ClickOnce) on a different PC the report presents a dialog box displaying the ServerName and two input fields one for UserID (pre-populated) and one for the Password (empty). When I enter the password it says 'Logon Failed'.
The information is definitely correct because this same information is used to provide user access to the application.
I am relatively sure it is WPF CrystalReportViewer related but unsure how to resolve.
UPDATE: Have since determined that if I install the application on any PC that does not have VS2010 installed it has the error. Also, on the PCs with VS2010 installed Crystal Reports for VS2010 doesn't even have to be installed.