Windows 10无法将文件关联到clickonce应用程序 [英] Windows 10 cannot associate file to clickonce application

查看:141
本文介绍了Windows 10无法将文件关联到clickonce应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个clickonce应用程序,该应用程序在Windows 7上可以正常工作。
在Windows 10计算机上安装该应用程序时,似乎无法将我们应用程序的特定文件与clickonce应用程序正确关联。

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.

如果我在文件上单击鼠标右键,然后选择打开方式,则可以在 ClickOnce应用程序部署支持库列表中看到。但是,如果选择此选项,则会收到一条消息,提示此应用程序无法在您的PC上执行。如果我决定直接选择clickonce应用程序(C:CUsers\xxx\AppData\Local\Apps ...)的.exe文件,它将无法正常工作(版本和更新检测)。

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.

编辑:
我已在另一台Windows 10计算机上安装了该应用程序,并且一切正常(包括在安装时自动指定文件关联以及在手动指定时自动关联文件)。因此,我认为问题并非对所有Windows 10机器都是通用的。

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.

推荐答案

我能够重现montueron的问题。打开日志记录后( https://msdn.microsoft.com/zh-CN /library/dd996997.aspx )并设置日志记录位置( https ://msdn.microsoft.com/zh-cn/library/ms404265.aspx ),我能够确定文件关联已被跳过:。tiff的文件关联已被跳过,因为另一个应用程序已被删除。

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.

这是我在Windows 10上解决问题的方法。我的目标是将ClickOnce程序 Tif2PDF与.TIF和.TIFF相关联图像文件。

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.


  1. 在Visual Studio 2017的ClickOnce Publish设置中创建唯一的文件关联。我在不使用.TIF这次,我们只想在HKCU\Software\Classes\Tif2PDF下创建适当的注册表项,即可在卸载过程中将其删除。

  1. 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


  • 在Tif2PDF程序启动过程中,我们需要在安装注册表时添加注册表设置-仅在更新时运行:

  • 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"
    


  • 这两个条目告诉Windows将HKCU\Software\Classes\Tif2PDF条目用于TIF和TIFF文件类型。

    These two entries tell windows to use the HKCU\Software\Classes\Tif2PDF entry for TIF and TIFF file types.


    1. 告诉Windows这是已注册的应用程序。此值指向在步骤2中创建的密钥。

    1. 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"
    


    此时,您应该在Windows资源管理器的打开方式下看到一个名为 ClickOnce应用程序部署支持库的选项。它将在此时工作,但让我们添加标签和图标。

    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.


    1. 在下面创建键和值。

    1. 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);
    }
    


  • 在卸载时,我们应尝试清理这些注册表设置遵循thedracle的帖子在.NET中的自定义卸载操作(clickonce)-

  • 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

    这篇关于Windows 10无法将文件关联到clickonce应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆