Remove ClickOnce from a WinForms app - c#

I have a WinForms application that was going to use ClickOnce. But it turns out ClickOnce won't work for my application, so I'd like to remove it. Only...there doesn't seem to be an obvious way to do this. There's no "Un-ClickOnce" button. Does anybody know what steps I need to take to get my app to be like it was before ClickOnce integrated itself?
(I know I can create a new project and import stuff into it, but it seems silly to have to do that, so I'm hoping there's another way.)

Other responses here are not correct or helpful. It is incorrect to state that it never needs removing.
One such example I experienced recently was when the application had a need for administrative privileges. Any attempt to embed administrative requirements into the manifest will result in the application not even compiling while ClickOnce is still present in the solution.
The following two steps enabled me to turn off ClickOnce (in Visual Studio 2010):
In the project properties,
Signing tab: Untick "Sign the ClickOnce manifests"
Security tab: Untick "Enable ClickOnce security settings"

I agree with the others, there is no need to "remove ClickOnce".
If you are really going for it though, IIRC all ClickOnce settings are in the .csproj file for the project, so remove all XML tags there that relate to ClickOnce. (maybe easiest to compare to a new app that hasn't been deployed with CO ever to see what tags are not there)

If you refer the the ClickOnce Application Deployment Manifest files that appear in your Debug folder, go to Project Properties -> Security and uncheck 'Enable ClickOnce Security Settings'
You can also go to Project Properties -> Signing and uncheck 'Sign the ClickOnce manifests', but this is not necessary because it does not have what to sign if you do the first uncheck.
Now if you go to debug and delete .application files, at rebuild, there will not appear again.

I believe the only thing that is left from ClickOnce once you stop deploying it is file publish.xml that tells you about what you have deployed thus far and what version you are at. Otherwise there is really nothing there that need concern you, just deploy from the bin folders as you would without ClickOnce.

Just in case this helps anyone...
My problem was specifically that I had a dependant "Class Library" project that had the "sign the clickonce manifest" checked but disabled so it could not be unchecked. My solution was to:
Convert that project to a windows app,
Re-open the properties panel,
Remove the click once manifest signing from the signing tab on the properties panel,
Convert the project back to a "Class Library".
I consider it an MS bug (still in VS2019 16.0.1 which I'm using now) but the workaround fixed it.
Good Luck!

Related

What files are published when using Click Once deployment?

When I click "Publish" in my project properties, what files are actually getting published? I spent some time yesterday searching MSDN, but didn't find a clear answer.
I assumed (perhaps incorrectly) that it was publishing the latest version in source control, so I always made sure I had my changes checked in before clicking "Publish". But now I'm highly suspicious, based on a bug that was reported, that it has been publishing the Debug configuration on my laptop. I have code that should only execute in debug mode (#if DEBUG...), and it seems to be executing that code in production.
This is my first WinForms application and first time using ClickOnce deployment. Any guidance would be greatly appreciated.
What code is getting published? Latest in source control, most
recent build on build server or from local machine?
What settings do I need to set (and where are they) to ensure that my
application is published using the Release configuration?
TIA
UPDATE(S):
Here is what I see on the Publish tab
Does the Build tab come into play at all?
The Configuration setting on the Build tab is what matters when Publishing, correct? Not the selection in the toolbar?
For ASP.NET applications, when you go to publish, there will be a configuration option under settings:
The code you have locally is what gets compiled and published through Click Once. For non ASP.NET applications, the build configuration selected in visual studio is what ultimately gets published.
For this specific case, you have "Define DEBUG constant checked". That will cause the code marked as #DEBUG to be executed. It doesn't matter what the build configuration is if that is checked.
I tried on some settings on my project.
1) Select Configuration Manager by right clicking on your Solution.
2) When i clicked publish, here is what i get in output window
3) If you want to control what files (dependencies) are included as part of deployment, this can be controlled from Application Files button on the publish tab of project properties.
Here is an image.
Hope that helps.

Visual Studio Setup Project not removing DLL

I have a problem regarding the Visual Studio Setup Project and uninstalling an application.
This is a very basic installer, installing an ApplicationLauncher.exe C# .NET 4.0 console application and an Application.Common.dll (a dependency of the application ApplicationLauncher.exe).
The installation is a success, copying both the exe and DLL into the program files folder C:\Program Files (x86)\Company\ApplicationLauncher\.
My problem comes when uninstalling the application (through the MSI) - the uninstall seems successful, however it leaves Application.Common.dll behind, and doesn't remove it as I would expect.
I've used ProcessExplorer to make sure nothing else is using the DLL, no explorer windows are open during the uninstall.
Is this the expected functionality and do I have to create a custom action to remove this DLL? Or have I done something wrong? :S
It seems I was able to fix this issue by renaming the solution and product name of the application, I'm not sure how this fixed it, but it did.
My only thoughts here is this traversed through to the installer, where the application installed into a different folder, thus not applying the same permissions to the DLL..
It's not expected, no. It will happen if you ever done any of the following with your setup and installed it:
Marked the file Permanent.
Marked the file SharedLegacyFile true.
These are project settings, but if you set either of them and do the install it will stay behind. You can unset them in the setup project but that's too late - you've marked that component permanent or sharedlegacy on the system. If you use a brand new system, like a fresh virtual machine, reset these values if they are set and rebuild the MSI and do the install/uninstall does it still happen?
I had the same problem. Then I have tried to install and unistall my app on Windows XP and that had worked.
Renaming the ProductCode is treating the symptoms not the cause. The problem occurs when the uninstaller doesn't remove the dll. The next install will use the dll again and can't remove it on an uninstall event because it's still used by the other program.
These steps hopefully solve the problem:
Install your Software
Open CMD (with admin privileges) and run:
msiexec /x {ProductCode} /L*V "C:\CustomPath\FileName.log"
The ProductCode can be found when hitting F4 on the Setup Project
Open the log file and search for the lines that look something like this:
Disallowing uninstallation of component: {6CEC09F6-9108-7062-A692-2BCBACEE3BD8} since another client exists
Disallowing uninstallation of component: {A0A0FA84-CC0D-C5C4-1F57-169788C4482D} since another client exists
Disallowing uninstallation of component: {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} since another client exists
All these components have to be removed from the registry by hand. To do this the GUID (e.g. {6CEC09F6-9108-7062-A692-2BCBACEE3BD8}) first has to be converted into a packed/compressed GUID (e.g. 6F90CEC6801926076A29B2BCCAEEB38D). I found a Website where one can run a script to do this. Find the following code on the website and replace the right side with the GUID from the log.
string inStrGUID = "{6CEC09F6-9108-7062-A692-2BCBACEE3BD8}";
Open the registry (as an administrater) and search (Edit -> Find...) for the compressed GUID (uasually it's somewhere in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\)
Delete the folder that is equal to the compressed GUID. The values inside the folder should be a path to the dll.
Once deleted select the parent folder (...\S-1-5-18\components) and hit Edit -> Find...
Repeat these steps (4-7) for all components from the log file.
It's also a good idea to delete all files still present in the original folder that weren't uninstalled.
Can one prevent this from happening?
I don't know. This really isn't that easy to reproduce. Some other post on SO have suspected the install/uninstall option in Visual Studio to be the cause of the problem but I have a different theory:
This bug might be the result of RemoveExistingProducts in InstallExecuteSequence in the Setup being executed too late and therefore not removing dlls at the right time. This bug is known for years and can be fixed by doing this. If you need help with Orca this explains how to install it.

Error - Unable to access the IIS metabase

After installing Visual Studio 2012 and opening my solution I get a series of errors in this form:
The Web Application Project Foo is configured to use IIS.
Unable to access the IIS Metabase. You do not have sufficient privilege to access IIS web sites on your machine.
I get this for each of our web applications.
Things I have tried:
Running Visual Studio as Administrator
Running aspnet_regiis.exe -ga MyUserName
Running aspnet_regiis.exe -i
These seem to be common solutions for this problem but I have not had any success with them.
Is there anything else I can try to do?
On Windows 8 Pro:
%systemroot%\inetsrv\config
On Windows 7 and 8.1 and 10
%systemroot%\System32\inetsrv\config
(Where %systemroot% is usually C:\Windows)
Navigate to the appropriate location above in Windows Explorer. You will be blocked access with a popup which says:
"You don't have access to this folder - Click continue to permanently get access to this folder"
Click 'continue' for this folder, and with the Export folder underneath. I changed the shortcut back to "Run as me" (a member of the domain and local administrators ) and was able to open and deploy the solution.
I think you are not running visual studio with administrator permissions. Look that:
http://bloggingabout.net/blogs/rick/archive/2012/10/04/unable-to-access-the-iis-metabase.aspx
To quote
The solution to this is simple: start your Visual Studio with "Run as
Administrator". You can do this by right clicking the shortcut and
selecting "Run as Administrator".
I think we encountered a similar problem at work. For us, the solution was to go into Control Panel -> Programs and Features -> Turn Windows Features on or off... inside that, we had to select Internet Information Services -> Web Management Tools -> IIS 6 Management Compatibility -> IIS Metabase and IIS 6 configuration compatibility.
Give that a try and let me know if it helps!
Note: We're running IIS 7.5 on Windows 7 using both Visual Studio 2005 and 2010 and doing stuff with super-old-school WebServices (.asmx)...
I resolved this issue by granting IIS AppPool identity permissions to the %systemroot%\inetsrv\config
If you are working on a project which does not require the use of IIS, then a workaround to open the project with this error is to simply right click on the unloaded project and click edit, search for:
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="">
<WebProjectProperties>
<UseIIS>True</UseIIS>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
and set USEIIS to false
<UseIIS>False</UseIIS>
reload the project by right clicking on it after saving changes.
I have had two seperate types of problem lead to this error, and thought I'd share...
1. The directory was on an network share and due to UAC restrictions, was
unable to be accessed -- even when running as an admin.
2. The directory was on a drive that didn't exist...
Both of these stem from an unfortunate (imo) choice by MS to put things in the Documents or My Document directory, combinee with really lousy error messages. In both of the above cases the fundamental problem was that the IISExpress Config file goes in My Documents, and it either didn't exist or couldn't be accessed.
Thank you to everyone that answered. Since this was closed for a long time I couldn't provide much feedback, but I did eventually fix my problem. I tried many of these other solutions and they didn't fix my issue, but I'm sure they help when the root cause is different.
My Solution
I solved this problem by turning off the IIS and .Net Framework features within Windows 7 and then turning them back on. It seems like this re-installation is what fixed my issue. I still don't know what caused the problem, but at least one other developer on my team had the same issue.
Navigating to folder: %systemroot%\System32\inetsrv\config presents a security dialog. Click continue and this may resolve the issue. This has worked on two separate Win 10/VS 2017/IIS machines.
On a windows 81, from an admin command prompt, use:
icacls "C:\Windows\System32\inetsrv\config" /t /grant "IIS AppPool\DefaultAppPool":(R)
Then go back in VS, right click on the failed project, choose Reload.
Credit to: IIS7 Permissions Overview - ApplicationPoolIdentity
I had this problem - the symptoms were the same, but the issue I had was that I had set the "My Documents" folder to be on a network share, and the share was not accessible.
The root problem was that the IIS config files located at %USERPROFILE%\Documents are not accessible. Once I changed the "My Documents" folder location (I modified the reg value), it started working again.
I know that this may not be a common scenario that you might run into, but I've posted it here because it gives the same symptoms.
I came across this today and fixed the problem by removing the IISUrl from the Project file:
Right click project
Click Edit
Delete the following line:
<IISUrl>http://localhost:xxxxx </IISUrl>
Reload project
Now add a new IIS virtual directory by right clicking Project > Properties > Web and selecting Use Local IIS Web Server (Uncheck Use IIS Express) and clicking the Create Virtual Directory button.
You might run across this problem and have same problem as me. I "solved" it before and then power outage and computer crashed, not sure why a registry setting reverted but it is the SOURCE of my problem.
I tried all the running as adminstrator
All the IIS / IIS express re-installs.
Various "hacks"
Came down to having to fix the registry again.
Could not as administrator even open regedit (Need to access registry since problem is not with gpedit.msc admin template )
UnHookExec.inf on desktop
Just save UnHookExec.inf and install it by right clicking and selecting install. Installing the file will not show any popup or notice box.
http://www.tweakandtrick.com/2011/04/enable-regedit-registry-editor.html
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal pointing to non-existant fileshare. Changing that to local path solved this problem for me. – Pasi Savolainen Jul 14 '14 at 8:41
(changed from \\cs2data\home\stickelt\my documents to c:\dev )
Now ALL is good and Visual Studio opened solution with 15 projects and connects to IIS and does not complain about not being able to access iis metadata
I had never ran into this before, as nobody at current job had this problem ( many have been here a long time, some got clones of other machines that "worked" and many are on another domain etc.. )
I just had this issue today and I found that I didn't open VS as 'Run as Administrator'.
After doing this, I was able to publish the Service.
If you have administrator permissions, Right Click to Visual Studio icon > properties and then advanced, "Run as administrator" check.
You can run visaul studio as administrator directly anymore.
This way, formal and so basic.
In addition to the answer by #nologo, I also had to use IIS. So I changed the
<UseIIS>True</UseIIS>
to 'False' first.
Opened the solution and ensured that the project could be loaded.
Close solution and that instance of Visual Studio
Change the value to 'True' again
Open the solution.
This time, I didn't get any error/warning. I could also run with Ctrl+F5 or F5 without any problem while my project was mapped to an IIS website.
Changing this key worked for me:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal
The location didn't exist.
Go to the root directory of your project and find the following file:
YourProjectName.csproj.user - inside it, make sure UseIISExpress is set to false:
<UseIISExpress>false</UseIISExpress>
If that alone doesn't work try the following as well and try again:
YourProjectName.csproj - inside the main project file, make sure both UseIIS and UseIISExpress are set to false:
<UseIIS>True</UseIIS>
<UseIISExpress>false</UseIISExpress>
After changing these I was able to load the project again.
Note: Make sure you run your VS as an Administrator, as mentioned in the other answers.
I also had a similar problem. My solution is an extension to the answer "Run as admin" which I hope someone might find useful.
I was running VS2012 and almost every time I had to do the Right Click, Run As Administrator. I got tired of this so instead I went into its properties on the shortcut, clicked advanced, and then clicked the "Run as Administrator" option. Now VS2012 always runs as administrator whenever I open it from that shortcut.
The from that shortcut bit is important. I proceeded to branch my project, and download the branch to a new local folder. Then, when I opened it from the shortcut I had no problem. But if I went directly into the folder, and ran the project locally without the shortcut, it did not run as administrator and I got this error.
Once I opened VS2012 as usual first, then using File/Open/Project It worked again no problem. (because I was running as admin). But I wasn't running as admin when I opened the solution using windows file manager.
The other suggestions seem somewhat extreme, but this is pretty simple so I would tend to give this a try first.
Hope this was helpful.
This seems like one of those "All errors lead to this message" type of bugs.
Mine was that the App Pool was just turned off. I turned it back on, and everything worked fine.
One more thing you could try:
Check if you have pending Windows updates.
If you do, please reboot before trying anything else.
I tend to never shut down my machine, so I had plenty of them waiting for a reboot. And that fixed it.
I tried everything above. The credit goes to all of the responses above. Having tried all of the suggestions on their own, I just assembled this combination of suggestions in an order that made sense to me. Note my Documents folder is on a shared drive. The subst/IISExpress stuff is not applicable unless you're in the same boat.
Configure VS to run as admin
Uninstall IIS via Add/Remove Programs, Windows Features
Reboot
Run WinRAR or something similar as admin and archive C:\windows\system32\inetsrv\
Run cmd as admin and rmdir /s c:\windows\system32\inetsrv\ to completely remove all traces of the last install. Leave elevated cmd prompt open for later.
Reinstall IIS with IIS 6 Metabase compatibility (doubt this was necessary)
Leave Default AppPool and Default Website as-is (I had previously deleted both)
Ran C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ga MYDOMAIN\scottt732
Ran C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
Also, because my Documents folder is on a share drive, I was having IIS Express issues. I don't use/like IIS Express, but Visual Studio complained about it.
From elevated cmd prompt, ran subst U: c:\Temp. Created C:\Temp\Documents\ and copied the IISExpress folder from my U drive.
Created CustomUserHome key in HKCU\Software\Microsoft\IISExpress with C:\Temp\Documents\IISExpress
This allowed me to get Visual Studio to open my web projects and edit the properties. I tweaked the projects to store web server settings in a user file and adjusted it to use a Custom URL (not sure if this was necessary)
I may/may not have to run the subst command each time I restart. Don't care.
And after throwing in the towel 3 times and spending roughly ~6 hours I can open web projects in Visual Studio (2015 Update 2).
I just had the same issue with me today. And I found it annoying. Though I have other two websites already under development from the same IIS but still was not able to create new site. Strange, but I did this.
Delete the site from IIS
Create new site, give it a name "new_site"
Select Application Pool other than the site name itself. So it wont be messing up with default settings.
Keep IP "unassigned" if you are running it from same machine
give it some unused port
Run Visual Studio as "Run as Administrator" by right-clicking on VS executable shortcut.
You are done!
You do not need to turn off/re-install anything other than what I have stated since it works.
Let me know if anybody had the same issue just like me and solved the same way. I think it was not the issue but a wrong way of creating website on localhost which Visual Studio rejects to open.
I hope this will help newbies.
Create a shortcut to the "devenv.exe"
select the "Run as administrator" option for the shortcut
doble click on the short cut and reopen your project
I had the same problem after Adding feature from this link afterward I followed this article the issue was gone.
I did a repair of Visual Studio 2015 to solve this.
The repair took a long time, but it solved the issue while doing much of the above did not. I am running Win 7 enterprise.
Open visual studio command prompt and type below command and run
aspnet_regiis -ga machinename\ASPNET
After running the above command Reset the IIS and test the application that resolve your issue.
If above command doesn’t resolve your problem then try to run below command in visual studio command prompt:-
aspnet_regiis -i
Alternatively we can run above command from our windows command prompt also
Go to the Start menu and open Run and enter and click OK
%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe –I
After that Reset the IIS and test the application that resolves your issue
In Visual Studio 2015:
I changed UseIIS in .csproj file to false and it worked for me.
<UseIIS>False</UseIIS>
In my message, beside complaining about "Unable to access the IIS metabase", it also mentions can't access "<IISUrl>http://localhost:6416/</IISUrl>". Right click on the unload project, click Edit, find the line "<IISUrl>http://localhost:6416/</IISUrl>", comment it out. Reload and it should work. This has to do with administrator doesn't have permission to access that address.
I had a similar problem. Visual Studio would not load any web projects and showed the error: creation of virtual directory <myproj:myport> failed. Unable to access the IIS metabase.
In my case it was actually IISExpress that was at the root of the problem. Right clicking on IIS Express in Programs and Features in the control panel and choosing repair fixed the issue in less than two minutes.
I'm using Win 8 Pro and VS 2013.
After trying everything in this page... I simply reinstalled IIS Express 8 and everything works fine now (even without running as an admin).
My conclusion is that this is a rather generic error and there are multiple root causes.

Disable Publishing in MSBuild

I have an application that I wrote in C# and build in VisualStudio. One day I was exploring the 'publish' tab in the project properties section just to see what it did. Now everytime I build my application, I get a whole bunch of files related to ClickOnce installers (*.application, *.deploy, etc.) that I don't really want anymore. How do I disable or otherwise stop these items from appearing when I build my project??
I solved the problem by unchecking 'Sign ClickOnce Manifests' in the 'Signing' tab as well as 'Enable ClickOnce security settings' in the 'Security' tab.
For WinForms Windows Application
Go to: Project > Properties > Security
Then uncheck 'Enable ClickOnce security settings'
2 ways to do it,
Go to the web project and click on properties, go to the 'Package/Publish Web' tab and uncheck the option
Over ride it from your build definition, click edit on your build defination, go to process tab and expand advanced and pass the following argument /P:CreatePackageOnPublish=false
HTH
Cheers, Tarun
In vs 16.5 go to project=>properties=>package/publish and enable it.
Web Deployment Overview for Visual Studio and ASP.NET

Simplifying setup and deployment in c#

I have made an application, which keeps getting updated frequently. So every time a change occurs, i've to include it's fresh builds to the setup and deployment program again and again. Is there any way to simplify the procedure? The files to be added are static in number and exist in a folder. I've heard we can write installer classes in c#, does my requirement has any thing to do with it?
I think ClickOnce doesn't suit my requirement because, for the first time i want it to run like a setup package, since it has some packages and some settings needed to be implemented on the user's machine at the time of install. Can click once help me with that? Also i want to run my application as an administrator and it references to many external dll files. So will it help my purpose?
I finally did it using clickonce deployment. I used content files to mark all the files i wanted to copy to the target computer and used clickonce deployment. Then i modified the way my program starts, so that i can lauch the installer script i wanted to run only when the app runs for the first time. Further i hosted it on IIS and had to change lot of MIME types and add new ones for the download to work over internet
Look into something called "ClickOnce" deployment. It automates a lot of what you're talking about.
EDIT: You can add custom installer actions to a ClickOnce project just like any other, to set up additional components and whatnot. As for permissions, ClickOnce will let you run as administrator if you so choose, but that sort of thing isn't recommended, and it might whine about it.
You can use ClickOnce (http://msdn.microsoft.com/en-us/library/t71a733d(VS.80).aspx) which simplify the deployment process.
Maybe you can also automate the build process using NANT (http://nant.sourceforge.net/).
HTH
Yes, you can do that.
I assume you want the client to update itself when ever there is a new version.
This needs a few changes in the client code. Essentially how it works is check for availablilty of new version at a predefined location. Update you new versions to this location. On the client side, show a message to the user if he/she wants to upgrade to the new version.
You can find a link to sample project out here and here.
You can add a Setup project in your solution inside Visual Studio and then add your other project(s) outputs, or static files to the Setup project as references. The Setup project will then detect your dependencies automatically and each time you do a Rebuild All (or you rebuild/build your Setup project) it will automatically include all the necessary files.
What type of project is it? In many cases, ClickOnce can do the job for you, at nominal effort.
Beyond that - you can usually hook your installer build into your build process; some tools will do this for you.
Installer classes run at the client - so I don't think they relate to your build process...
I would flag the files as Content in their respective properties and then in the deployment project right click the project, go to File System and then right click the folder, click Add and select Content Files from the dialog box. This should copy the newest files over every time you build the deployment project.

Categories