Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

User projects using Reqnroll.Microsoft.Extensions.DependencyInjection or SolidToken.SpecFlow.DependencyInjection plugins cause FileNotFoundException for Microsoft.Extensions.DependencyInjection.Abstractions when connectors analyze project bindings. The assembly was missing from connector outputs.

Changes

Added Microsoft.Extensions.DependencyInjection.Abstractions v8.0.0 package reference to all connector projects:

  • Reqnroll.VisualStudio.ReqnrollConnector.V1 (net48)
  • Reqnroll.VisualStudio.ReqnrollConnector.Generic (net6.0-net9.0)
  • SpecFlow.VisualStudio.SpecFlowConnector.V1 (net48)
  • SpecFlow.VisualStudio.SpecFlowConnector.V2 (net6.0)
  • SpecFlow.VisualStudio.SpecFlowConnector.V3 (net6.0-net9.0)
  • SpecFlow.VisualStudio.SpecFlowConnector.Generic (net6.0-net9.0)

Technical notes

Using v8.0.0 instead of v6.0.0: Backward compatible with plugins targeting v6.0.0, better alignment with modern .NET versions used by generic connectors, lower conflict risk with VS 2022/2025 components.

Packaging: Assembly automatically included in VSIX via DeploymentAssets.props which copies all connector outputs. No manifest changes required.

Stack trace resolved:

System.IO.FileNotFoundException: Could not load file or assembly 
'Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0'
at Reqnroll.Microsoft.Extensions.DependencyInjection.DependencyInjectionPlugin
   .CustomizeGlobalDependencies(...)
Original prompt
problem_statement: |
  # Fix Assembly Loading Issues for Visual Studio Extension

  ## Problem
  Our Visual Studio extension experiences `FileNotFoundException` for `Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0` when used by end users, but works fine during development.

  **Stack trace:**

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
at Reqnroll.Microsoft.Extensions.DependencyInjection. DependencyInjectionPlugin.CustomizeGlobalDependencies(Object sender, CustomizeGlobalDependenciesEventArgs args)


## Context
- Target framework: .NET Framework 4.8.1
- Supported Visual Studio versions: VS 2022 and VS 2025
- Extension type: Traditional in-process extension
- Issue occurs for many (but not all) end users, never in development

## Investigation and Solution Strategy

### Phase 1: Investigation (do FIRST before implementing)

**Step 1 - Analyze current dependencies:**
- Check which version of `Reqnroll.Microsoft.Extensions. DependencyInjection` is currently referenced
- Check the transitive dependency tree to see which version of `Microsoft.Extensions.DependencyInjection.Abstractions` is actually required
- Determine if Reqnroll supports newer versions (7.x or 8.x) of the DI abstractions package

**Step 2 - Check VSIX contents:**
- Examine `source.extension.vsixmanifest` to see which assemblies are currently packaged
- Check if `Microsoft.Extensions.DependencyInjection.Abstractions. dll` is already included (and which version)
- Document current VSIX asset structure

**Step 3 - Determine root cause:**
- Is the DLL missing entirely from the VSIX? 
- Is it a version mismatch (different version loaded by VS/other extensions)?
- Check if there are existing assembly binding redirects in app. config

### Phase 2: Implement Solution (choose best option based on investigation)

**Option A: Upgrade to compatible version (PREFERRED - try this first)**

IF investigation shows Reqnroll supports `Microsoft.Extensions.DependencyInjection.Abstractions` v7.x or v8.x:

1. Upgrade the package reference to the latest compatible version in . csproj: 
   ```xml
   <PackageReference Include="Microsoft.Extensions. DependencyInjection. Abstractions" Version="8.0.0" />
   ```

2. Add the assembly as an asset in source.extension.vsixmanifest:
   ```xml
   <Asset Type="Microsoft. VisualStudio.Assembly" 
          d:Source="Project" 
          d:ProjectName="%CurrentProject%" 
          Path="|%CurrentProject%|Microsoft.Extensions.DependencyInjection. Abstractions.dll" />
   ```

3. Add code comments explaining why this version was chosen

**Why preferred:** Simplest solution, better forward compatibility, less likely to conflict with VS 2022/2025

**Option B: Bundle exact v6.0 in VSIX (if Reqnroll requires v6.0)**

IF investigation shows Reqnroll only supports v6.0:

1. Explicitly reference v6.0.0 in . csproj:
   ```xml
   <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0">
     <PrivateAssets>none</PrivateAssets>
   </PackageReference>
   ```

2. Add as asset in source.extension.vsixmanifest (same as Option A)

3. Add code comments explaining the v6.0 requirement

**Why this works:** VS loads from extension folder first, no embedding complexity needed

**Option C: Costura.Fody embedding (ONLY if Options A and B fail)**

IF bundling doesn't work due to assembly conflicts:

1. Add NuGet packages to . csproj:
   ```xml
   <PackageReference Include="Costura.Fody" Version="5.7.0" PrivateAssets="all" />
   <PackageReference Include="Fody" Version="6.8.0" PrivateAssets="all" />
   ```

2. Create FodyWeavers.xml:
   ```xml
   <?xml version="1.0" encoding="utf-8"?>
   <Weavers xmlns: xsi="http://www.w3.org/2001/XMLSchema-instance">
     <Costura>
       <IncludeAssemblies>
         Microsoft.Extensions.DependencyInjection.Abstractions
       </IncludeAssemblies>
       <ExcludeAssemblies>
         Microsoft. VisualStudio
         EnvDTE
         System
       </ExcludeAssemblies>
     </Costura>
   </Weavers>
   ```

3. Remove the assembly from VSIX manifest assets (it's now embedded)

4. Add wrapper class if extension exposes DI types publicly to avoid type identity issues

**Why last resort:** Adds build complexity, increases size, harder to debug

## Requirements for Implementation

1. **Add investigation comments**:  Document what you found in Phase 1 (which Reqnroll version, which DI version it needs, what's currently in VSIX)

2. **Add solution comments**:  Clearly explain which option was chosen and why

3. **Add verification instructions**: Add comments explaining how to verify after build: 
   - How to check VSIX c...

</details>



<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

Copilot AI changed the title [WIP] Fix assembly loading issues for Visual Studio extension Add Microsoft.Extensions.DependencyInjection.Abstractions to connector outputs Dec 19, 2025
Copilot AI requested a review from 304NotModified December 19, 2025 19:07
@304NotModified
Copy link
Member

Test fails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants