Skip to content

Enhance CS0012 documentation with troubleshooting steps for when assemblies appear to be referenced #47632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 29, 2025

The current CS0012 compiler error documentation doesn't address scenarios where the assembly appears to be referenced in the project but the compiler error persists. This enhancement adds a dedicated troubleshooting section to help developers resolve CS0012 errors that occur after NuGet package operations or when references seem to exist but are not properly resolved.

Changes Made

Added a new "When the assembly appears to be referenced" subsection to the CS0012 documentation that provides step-by-step troubleshooting guidance:

  1. Package restoration - Run dotnet restore after package operations
  2. Cache clearing - Clear NuGet package caches and restore
  3. Version conflict detection - Check for binding redirect warnings
  4. Clean rebuild - Remove stale references through clean/build cycle
  5. Package integrity verification - Reinstall packages that may be corrupted

Problem Addressed

This addresses user feedback about encountering CS0012 errors for System.ServiceModel.ClientBase<> after NuGet uninstall/reinstall operations, where the dependency appeared to be present but the compiler couldn't resolve it. The enhanced documentation now provides concrete steps to resolve these common post-package-operation scenarios.

Example Scenario

A developer receives this error after NuGet operations:

The type 'ClientBase<>' is defined in an assembly that is not referenced. 
You must add a reference to assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

With the updated documentation, they now have clear steps to resolve the issue even when the assembly appears to be referenced.

Fixes #28000.


💡 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 in the docs.


Internal previews

📄 File 🔗 Preview link
docs/csharp/language-reference/compiler-messages/assembly-references.md docs/csharp/language-reference/compiler-messages/assembly-references

@Copilot Copilot AI changed the title [WIP] Feedback on CS0012 Enhance CS0012 documentation with troubleshooting steps for when assemblies appear to be referenced Jul 29, 2025
@Copilot Copilot AI requested a review from BillWagner July 29, 2025 21:14
Copilot finished work on behalf of BillWagner July 29, 2025 21:14
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM and is ready for final review.

@BillWagner BillWagner requested a review from tdykstra July 30, 2025 17:38
@BillWagner BillWagner marked this pull request as ready for review July 30, 2025 17:38
@BillWagner BillWagner requested a review from a team as a code owner July 30, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feedback on CS0012
2 participants