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

Merged
merged 3 commits into from
Aug 14, 2025

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 Resolve errors and warnings related to assembly references

…eferenced

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
@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
@BillWagner BillWagner requested a review from adegeo August 6, 2025 18:00
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
@BillWagner BillWagner enabled auto-merge (squash) August 14, 2025 12:29
@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Aug 14, 2025
Copy link
Contributor

PoliCheck Scan Report

The following reports lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 issues. Other issues are also a high priority. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a comment that you post to the PR. The feedback helps reduce false positive instances in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@BillWagner BillWagner merged commit b1f9c7c into main Aug 14, 2025
11 checks passed
@BillWagner BillWagner deleted the copilot/fix-28000 branch August 14, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
csharp-diagnostics/subsvc dotnet-csharp/svc lang-reference/subsvc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feedback on CS0012
3 participants