You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在查看文件时复用Visual Studio实例?WPF应用打开.feature文件异常

Fixing WPF App Opening .feature Files in VS 2015 Instead of 2017

Hey there, let's tackle this issue you're facing with your WPF app opening .feature files in VS 2015 instead of 2017. Here are a few solid solutions depending on what you need:

1. Update System Default File Association (Simplest Approach)

The most straightforward fix is to set VS 2017 as the default app for .feature files system-wide:

  • Right-click any .feature file on your machine
  • Select Open with > Choose another app
  • Check the box that says "Always use this app to open .feature files"
  • Browse to your VS 2017 executable (typical path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe — adjust "Community" to "Professional" or "Enterprise" if you have that version)
  • Confirm your selection, and moving forward Process.Start(path) will use VS 2017 by default

2. Force VS 2017 Opening in Code (Bypass System Associations)

If you don't want to mess with system defaults, or need guaranteed control over which VS version opens the file, modify your code to directly call VS 2017's executable:

// Update this path to match your VS 2017 installation
var vs2017ExePath = @"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe";
var featureFileFullPath = "YourFullFeatureFilePath.feature";

// Launch VS 2017 with the target file
Process.Start(new ProcessStartInfo(vs2017ExePath, $"\"{featureFileFullPath}\""));
  • Note: Double-check the path to devenv.exe — if you're on a 64-bit system and installed VS to the 64-bit directory, it might be under C:\Program Files instead of C:\Program Files (x86).
  • This method ensures your app always uses VS 2017, regardless of system-level file associations.

3. Reset File Association Cache via Command Line

Sometimes Windows caches file association settings, which can cause unexpected behavior. Here's how to reset it manually:

  1. Open Command Prompt as Administrator
  2. Run assoc .feature to check the registered file type (e.g., it might return .feature=SpecFlowFeatureFile)
  3. Run ftype SpecFlowFeatureFile to see the current associated program path — if it points to VS 2015, update it with:
    ftype SpecFlowFeatureFile="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe" "%1"
    
  4. Restart your WPF app and test again

If you noticed inconsistent behavior when repeating the feature, this cache reset should help stabilize things. If the issue persists, the code-based approach (solution 2) is your safest bet.

内容的提问来源于stack exchange,提问作者C Robinson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:41:26