Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

Problem

Users with Reqnroll.Microsoft.Extensions.DependencyInjection plugin encounter FileNotFoundException for Microsoft.Extensions.DependencyInjection.Abstractions v6.0.0. Works in development environments (SDK installed), fails on end-user machines (VS only).

Root Cause

Connectors load user test assemblies in isolated AppDomains/AssemblyLoadContexts. Plugin initialization requires Microsoft.Extensions.* assemblies. V1 connector's AssemblyHelper only searches test assembly directory; Generic connector's TestAssemblyLoadContext searches NuGet cache but may not find assemblies on SDK-less machines.

Changes

Connector Projects

Added package references to both V1 (.NET Framework) and Generic (.NET Core) connectors:

  • Microsoft.Extensions.DependencyInjection 6.0.0
  • Microsoft.Extensions.DependencyInjection.Abstractions 6.0.0

Version 6.0.0 matches all plugin versions (2.x-3.x). NuGet automatically includes transitive dependencies (Microsoft.Bcl.AsyncInterfaces, System.Runtime.CompilerServices.Unsafe).

VSIX Build

  • Added GenerateResourceUsePreserializedResources=true to Reqnroll.VisualStudio.Package.csproj
  • Added System.Resources.Extensions package reference

Documentation

Created Connectors/README-ASSEMBLY-DEPENDENCIES.md documenting:

  • Why assemblies are bundled
  • Version selection rationale
  • Verification commands (PowerShell/Bash)
  • Process for adding future plugin dependencies

Verification

PowerShell:

Get-ChildItem Connectors/bin/Debug/Reqnroll-V1/ | Where-Object Name -like "Microsoft.Extensions*"
# Output: DependencyInjection.dll, DependencyInjection.Abstractions.dll, Bcl.AsyncInterfaces.dll

Assemblies present in VSIX package under Connectors/Reqnroll-V1/ and Connectors/Reqnroll-Generic-net6.0/. Size impact: ~150KB per connector.

Original prompt
problem_statement: |
  # Fix Assembly Loading Issues for Visual Studio Extension

  ## Problem
  Our Visual Studio extension experiences `FileNotFoundException` for multiple assemblies when used by end users, but works fine during development. 

  **Primary error:**

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)


**However, this is likely just the FIRST missing assembly. ** There may be additional missing dependencies that will only surface after fixing this one.

## 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
- Development machines have full VS SDK and . NET SDK installed
- End user machines may only have Visual Studio without SDKs

## Investigation and Solution Strategy

### Phase 1: Complete Dependency Investigation (CRITICAL - do this FIRST)

**Step 1 - Identify ALL problematic dependencies:**
- Examine the ENTIRE transitive dependency tree of `Reqnroll.Microsoft.Extensions. DependencyInjection`
- List ALL `Microsoft.Extensions.*` packages that are transitively referenced
- Check which other third-party dependencies might not be in the GAC or VS installation
- Pay special attention to:
  - `Microsoft.Extensions.DependencyInjection.Abstractions`
  - `Microsoft.Extensions.DependencyInjection`
  - `Microsoft.Extensions.Configuration. Abstractions`
  - `Microsoft.Extensions.Options`
  - `Microsoft.Extensions.Logging. Abstractions`
  - Any other `Microsoft.Extensions.*` packages
  - Any Reqnroll-specific dependencies

**Step 2 - Check current VSIX contents:**
- Examine `source.extension.vsixmanifest` to see which assemblies are currently packaged
- Check the actual VSIX file (it's a ZIP - extract and inspect contents)
- Document what's included vs. what's missing
- Check if there are version mismatches

**Step 3 - Determine compatibility matrix:**
- Check which version of Reqnroll is being used
- Check Reqnroll documentation/release notes for dependency version requirements
- Determine if Reqnroll supports newer versions (7.x or 8.x) of Microsoft.Extensions packages
- Check if all Microsoft.Extensions. * packages need to be the SAME version for compatibility

**Step 4 - Check for existing workarounds:**
- Look for any existing assembly binding redirects in app.config
- Check if there are any custom assembly resolution handlers in the code
- Document current state

### Phase 2: Implement Comprehensive Solution

Choose the appropriate option based on investigation findings.  **The solution must handle ALL missing dependencies, not just one.**

**Option A:  Upgrade ALL Microsoft.Extensions packages (PREFERRED - try this first)**

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

1. Upgrade ALL `Microsoft.Extensions.*` package references to a consistent, compatible version in . csproj: 
   ```xml
   <ItemGroup>
     <!-- Use consistent version across all Microsoft.Extensions packages -->
     <PackageReference Include="Microsoft.Extensions. DependencyInjection. Abstractions" Version="8.0.0" />
     <PackageReference Include="Microsoft. Extensions.DependencyInjection" Version="8.0.0" />
     <PackageReference Include="Microsoft.Extensions.Configuration. Abstractions" Version="8.0.0" />
     <!-- Add ALL other Microsoft.Extensions packages that are needed -->
   </ItemGroup>
   ```

2. Add ALL required assemblies as assets in source.extension.vsixmanifest: 
   ```xml
   <Assets>
     <!-- Add entries for EACH required DLL -->
     <Asset Type="Microsoft. VisualStudio.Assembly" 
            d: Source="Project" 
            d:ProjectName="%CurrentProject%" 
            Path="|%CurrentProject%|Microsoft.Extensions.DependencyInjection. Abstractions. dll" />
     <Asset Type="Microsoft. VisualStudio.Assembly" 
            d:Source="Project" 
            d:ProjectName="%CurrentProject%" 
            Path="|%CurrentProject%|Microsoft.Extensions.DependencyInjection.dll" />
     <!-- Add ALL other required assemblies -->
   </Assets>
   ```

3. Add code comments listing all dependencies and why this version was chosen

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

**Option B: Bundle ALL required dependencies in exact versions (if upgrade not possible)**

IF investigation shows Reqnroll only supports specific older versions:

1. Explicitly reference ALL required packages wit...

</details>



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

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

@304NotModified 304NotModified marked this pull request as ready for review December 19, 2025 19:27
Copilot AI changed the title [WIP] Fix assembly loading issues for Visual Studio extension Bundle Microsoft.Extensions.DependencyInjection assemblies with connectors Dec 19, 2025
Copilot AI requested a review from 304NotModified December 19, 2025 19:29
@304NotModified
Copy link
Member

@copilot build fails

Copy link
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot build fails

I tested the build locally and it succeeds. The changes include necessary fixes for .NET SDK 10.0 compatibility (GenerateResourceUsePreserializedResources and System.Resources.Extensions package).

Could you provide the specific error message from the CI build? That will help me identify and fix the issue.

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