Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vb.net使用clickonce应用程序打开自定义文件扩展名_Vb.net - Fatal编程技术网

vb.net使用clickonce应用程序打开自定义文件扩展名

vb.net使用clickonce应用程序打开自定义文件扩展名,vb.net,Vb.net,我的程序有两个不同的主要功能。 默认情况下-使用.appref ms(桌面快捷方式)打开程序本身可在正常模式下打开程序 我还创建了一个.TRA扩展。当用我的程序打开.TRA文件时,它应该以辅助模式打开程序。 我可以看到我的程序已经注册了.tra扩展名,并且图标都被更改了。 如果我将扩展名为.TRA的文件拖到调试箱中的.exe文件上,它将按预期在第二种模式下打开。但是,只需双击.TRA文件,它仍将以默认模式打开 代码设置为查看为.TRA扩展传递的所有命令行: For i = 0 To System

我的程序有两个不同的主要功能。 默认情况下-使用.appref ms(桌面快捷方式)打开程序本身可在正常模式下打开程序

我还创建了一个.TRA扩展。当用我的程序打开.TRA文件时,它应该以辅助模式打开程序。 我可以看到我的程序已经注册了.tra扩展名,并且图标都被更改了。 如果我将扩展名为.TRA的文件拖到调试箱中的.exe文件上,它将按预期在第二种模式下打开。但是,只需双击.TRA文件,它仍将以默认模式打开

代码设置为查看为.TRA扩展传递的所有命令行:

For i = 0 To System.Environment.GetCommandLineArgs.Length
            Dim _file = System.Environment.GetCommandLineArgs(i)
            Dim format As String = IO.Path.GetExtension(_file)
            If format = ".TRA" Then
                file = System.Environment.GetCommandLineArgs(i)
                openedwithext = True
                Exit For
            End If
        Next i
我错过了什么? 双击我的.TRA文件是否不像我想象的那样向我的应用程序发送命令行参数? 除此之外,还可以如何执行


提前感谢。

因为.appref ms就像一个快捷方式,它以不同的方式接受命令行参数。 我通过添加System.Deployment命名空间并在.loaded事件上使用以下代码解决了问题

        'Are we launching as a click-once?
        If (IsNetworkDeployed) Then
            Try
                Dim urifile As New Uri(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData(0))
                Dim uristring As String = urifile.ToString
                If uristring.Contains(".TRA") Then
                    file = uristring.Substring(8) 'Substring removes the - file:///
                    openedwithext = True
                End If
            Catch ex As Exception
            End Try
        End If

不过,它正在启动正确的应用程序。但它在打开时并没有将.TRA文件作为参数传递。它只是打开.TRA文件,就像我从.appref msaaack打开文件一样-我在考虑shell扩展名-当超过特定文件类型时,浏览器中会弹出菜单。