Windows 10 cannot associate file to clickonce application - windows-10

I have a clickonce application which works fine on windows 7.
When it's being installed on a windows 10 machine, it seems that the specific file for our application cannot be properly associated to the clickonce application.
If I click right on the file, and choose "open with", I can see in the list "ClickOnce Application Deployment Support Library". But if I choose this option, I get a message saying "this application cannot be executed on your PC". If I decide to choose directly the .exe file of the clickonce application (C:\Users\xxx\AppData\Local\Apps...), it will not work properly (version & update detection).
I am able to install my application and I am able to run it properly from the start menu. The only thing not working is the file association. I have tried to uninstall, and reinstall, but it doesn't change anything.
Edit :
I have installed the application on another windows 10 machine, and everything works fine (including the file assocation "automatically when installed & when specifiying it manually"). So I think the problem is not "generic" for all windows 10 machines.

I was able to reproduce montueron's issue. After turning on logging (https://msdn.microsoft.com/en-us/library/dd996997.aspx) and setting the logging location (https://msdn.microsoft.com/en-us/library/ms404265.aspx), I was able to determine that the file association was being skipped: File association for ".tiff" skipped, since another application is using it.
Here is what I did to solve my problem on Windows 10. My goal is to associate my ClickOnce program, "Tif2PDF", with .TIF and .TIFF image files.
Create a unique file association in the ClickOnce Publish settings in Visual Studio 2017. I am not using .TIF at this time, we just want to create the appropriate registry entry under HKCU\Software\Classes\Tif2PDF which will get removed in the un-install process.
Properties->Publish->Options->File Associations.
extension=.tif2pdf
description=Tif2PDF
progID=Tif2PDF
icon=Resources\Tif2PDF.ico
In the Tif2PDF program startup process, we need to add registry settings when it is installed - only run when it is updated:
if ( System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed
&& ApplicationDeployment.CurrentDeployment.IsFirstRun )
Computer\HKEY_CURRENT_USER\Software\GuardTech\PDFTool\Capabilities\FileAssociations
.tif="Tif2PDF"
.tiff="Tif2PDF"
These two entries tell windows to use the HKCU\Software\Classes\Tif2PDF entry for TIF and TIFF file types.
Tell Windows this is a registered application. This value points to the key created in step 2.
Computer\HKEY_CURRENT_USER\Software\RegisteredApplications
Tif2PDF="Software\Tif2PDF\Capabilities"
At this point, you should see an option in Windows Explorer under "open with" called "ClickOnce Application Deployment Support Library". It will work at this point, but let's add a label and icon.
Create key and values below.
string iconSourcePath == Path.Combine(System.Windows.Forms.Application.StartupPath, #"Resources\Tif2PDF.ico");
Computer\HKEY_CURRENT_USER\Software\Classes\Tif2PDF\Application
ApplicationIcon=iconSourcePath
ApplicationName="Tif2PDF"
You program will need to handle command line arguments a little differently
//Get the normal command lines arguments in case the EXE is called directly
List<string> argList = new List<string>(Environment.GetCommandLineArgs());
argList.RemoveAt(0); //Remove the application.EXE entry
// this is how arguments are passed from windows explorer to clickonce installed apps when files are associated in explorer
if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments?.ActivationData != null )
{
argList.AddRange( AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData);
}
We should try to cleanup these registry settings when we un-install the program by following thedracle's post Custom action on uninstall (clickonce) - in .NET

I just created a test application as Administrator (Windows Forms Application) using Visual Studio 2015 (< 5 minutes)
1) Under Properties/Publish/Options/File Associations added an entry:
Extension: .abcd
Description: test
ProgID: 2
Icon: An icon file
2) Under Properties/Publish I pressed Publish Now and ran Setup
3) Created a text file, renamed it to test.abcd
It is working as expected under Windows 10, so you could create a test application / verify that it's working and see what the differences are compared to your existing application.. 32/64 bit, framework, signing etc.

Related

How do I get my application to run with administrator rights automatically?

I've made a console application that is supposed to update some registry entries so that I can access 32 bit COM components from a 64 bit application. If I have admin rights, it works great, but I can't seem to get the application run with admin rights out of the box.
This is what I've done.
Create a Windows Console Application.
Add my code.
Right click on my project and select Properties.
Navigate to Configuration Properties > Linker > Manifest File > UAC Execution Level and set to requireAdministrator (/level='requireAdministrator').
It took a lot to figure out this because all of the info on the web is for Visual Studio 2010 or earlier which required manually creating an XML manifest file and conflicts with the auto generated one that this creates.
However, this doesn't seem to be enough to get it to run as an admin. It is a real PITA that this information isn't made easily findable. Is there some other step that I am missing? Something like a signing process?
Turns out it is how this mini application is run.
From my main programme, using ShellExecute() or ShellExecuteEx() with the "runas" verb will allow running of this executable with administrator privileges without popping up a UAC dialog.
Running this from the command line however, will result in this mini app being executed in the user's security context, which is what I was doing.

EF7 commands do not work in VS2015 CTP 6

I'm trying to run ef7 migration on fresh asp.net 5 preview project.
Steps I took:
Created fresh project based on template "ASP.NET 5 preview starter web"
Build it
Try command Add-Migration in Package Manager console
Result:
The term 'Add-Migration' is not recognized as the name of a cmdlet,
function, script file, or operable program.
I also try this command:
Install-Package EntityFramework.Commands -Pre
I think for VS 2015 project is redundant, it executed but still Add-Migration was not recognized.
Thanks in advance for clues...
NuGet commands don't work with ASP.NET 5 projects. You'll need to use the ASP.NET 5 command-line versions of the commands. (E.g. k ef migration add) We have an issue aspnet/DNX#952 open to unblock this scenario, but it hasn't seen much activity.
To learn more about the ASP.NET Commands, see my post EF7 Migrations: ASP.NET Commands.
Ok, I know this is an old question and it has already been technically answered. That is, if you want to open command prompt and do it. The root cause of this problem is that the PowerShell module is not initializing. There is a simple fix though. You just need to initialize the module. Go to your solution explorer. Go to References >> .NETCoreApp,Version=v1.0 then scroll down until you find Microsoft.EntityFrameworkCore.Tools right click and show the properties. Take note of the path it should be something like
C:\Users\YourUserName\.nuget\packages\Microsoft.EntityFrameworkCore.Tools\1.0.0-preview2-final
Once you have that go to the path location in file explorer. You should see another folder called tools. Inside that folder you will see a .ps1 file called init.ps1. This is the module that we need to initialize. So go back to Visual Studio, I am using VS 2015 pro and Win 10 pro, open the package manager console. Type in the following
cd
"C:\Users\YourUserName\.nuget\packages\Microsoft.EntityFrameworkCore.Tools\1.0.0-preview2-final\tools"
and press enter. Then to initialize a module in PowerShell you just need to type
. .\init.ps1
or I believe you can just do the entire path and get the same results so that way would be
C:\Users\YourUserName\.nuget\packages\Microsoft.EntityFrameworkCore.Tools\1.0.0-preview2-final\tools\init.ps1
Unfortunately you would have to do this every time that error pops up, but its not that bad if you just save the path in a .txt file or comment it somewhere in your project that is easy to find.

deploy an Application page of Sharepoint 2010 to another production server

How to deploy an Application page of Sharepoint 2010 to another production server.
I've created an Application page of Sharepoint 2010 inside the mapped layout folder. Everything works nicely now in Visual Studio 2010.
I can debug it after pressing F5, I can retract it and deploy it with Visual Studio 2010.
But when it comes to deploying it to another production server, I have tons of questions.
Basically I don't know how to deploy it to another production server. My first thought was just copy the pages to the Layout folder of IIS and register the referenced dlls. But after I studied a little bit of deployment, I feel my thought is ugly.
I tried "right clicking" on the project name and "package". The Visual Studio generates a "MyProjectName.wsp" in the bin folder. I used the central administration to upload this wsp file. But when I activate it, it raised an error saying "This solution contains invalid markup or elements that cannot be deployed as part of a sandboxed solution. Solution manifest for solution 'af2f9404-3b39-4f90-87f5-31e14b2f9a9a' failed validation, file manifest.xml, line 6, character 4: The element 'Solution' in namespace 'http://schemas.microsoft.com/sharepoint/' has invalid child element 'TemplateFiles' in namespace 'http://schemas.microsoft.com/sharepoint/'. List of possible elements expected: 'FeatureManifests, ActivationDependencies' in namespace 'http://schemas.microsoft.com/sharepoint/'." It seems that my application is not a sandbox, but I can't change it to a sandbox. Because when I do change it, the Visual Studio tells me "The deployment type "TemplateFile" of file "ApplicationPage1.aspx" in Project Item "Layouts" is not compatible with a Package in a Sandboxed Solution.
The Project Item "Layouts" cannot be deployed through a Package in a Sandboxed Solution.
Package validation failed."
Besides, even if I can successfully activate the .wsp file, I am not sure if the application page can be added to the Layout folder. Because I don't know how the .wsp file locate and find my application page? It doesn't have the page in it. Can anyone explain a bit on it?
Thanks for your answers.
1) It's strongly recommended that you use powershell to run your test and production deployments: http://dotnet.sys-con.com/node/1208275
2) Try changing your SharePoint solution to a farm solution and repackaging your wsp.
3) By right clicking on your project in visual studio and adding the mapped Layouts folder the solution packaging handles placing any application pages/user controls that you have in the appropriate directory inside your wsp.

Setup project creates extra keys

I have a setup project, its been working nicely for atleast a couple of years. I have recently added a new project to the mix, a winform. I took me a great deal of googling and research to make it work - many thanks to the loads of articles I found during my "adventure".
This new project enables me to right click a file in Explorer and add it to my system. I can install the project fine, files are being added/copied to their rightfull place. Code is fine, does precisely what I told it to.
For some reason the Registry editor and Windows Registration DB does not agree on keys.
Registry editor states I should have HKCR\*\shell\Add to system\command and a string key saying
Name: (Default)
Value: "[TARGETDIR]mySystemAddFileForm "%1"
Sofar so good, yes Windows reg db also believes the path to be right. Yes there is a "but".
For some reason Windows reg db believes there should be a 2nd string key saying
Name: (Default)
Value: null
The Windows takes precedence and messes up my logic (design, code, idea).
If I manually clean this up, I can right click the files just fine and add them to the system. Just to be clear. Yes, Explorer does have a right click option that says "Add to system" and yes after I edit regedit manually it does work when I click it.
Before I changed it to the Registry editor, I had the key generation in the CustomSetupActions but I couldn't make that handle if the user decided to edit the installation folder. From default [programfiles] (c:\Program Files\ .. ) to whatever the user decided at install point.
By Registry editor I mean the one in the Setup project, View/Registry.
How can I tell Windows to stay the f* of my finely tuned code and let me decide what reg keys are created when and where.
Edited: (Standard) to (Default). Windows may translate the (Default) to the local language. Leave it at Default.
Windows Installer can install default values and usually they are not overridden automatically by Windows.
To install a default value with a Visual Studio setup project, make sure that the Name field is empty: http://msdn.microsoft.com/en-us/library/windows/desktop/aa371168(v=vs.85).aspx
This is usually enough. If the value is not as expected after install, try creating a verbose installation log to see what happens during install. Most likely the registry entry is skipped or written somewhere else.

Setup Project - Allow multiple installation of the same Windows Service

I have a question regarding to Setup Projects in .Net (c# language, Framework 4.0):
I made a setup project for a Windows Service, on the installation wizard, the user must input the name of the Windows Service as it would be installed. The setup program also creates a shortcut to the Uninstall program in case the user wants to remove that Windows Service.
The question is: how to let the user run the same setup program several times specifing different service name?
This behaviour could be required because the windows service is a socket consumer that connects to a server and retrieves data; to take advantage of the server capabilities the user could install the same windows service multiple times pointing to a different port on the server, to perform the data retrieving task much faster. The service is the same, the user just modify the port on the configuration file of the service, so that's why it's not logical to create a new version of the installer each time.
Any clue or suggestion would be appreciated, thanks in advance.
This can be done by using an multiple instances installation. The general approach is:
create a transform for each instance you want available to the user
use a custom EXE bootstrapper which applies a new transform to your MSI package each time a new instance is installed
The transform should change at least the PackageCode, ProductCode and UpgradeCode.
This is not supported by Visual Studio setup projects. So either you do it manually or use a commercial setup authoring tool which supports multiple instances.

Resources