Skip to content

Commit b1f9c7c

Browse files
CopilotBillWagnergewarren
authored
Enhance CS0012 documentation with troubleshooting steps for when assemblies appear to be referenced (#47632)
* Initial plan * Add troubleshooting section for CS0012 when assemblies appear to be referenced Co-authored-by: BillWagner <[email protected]> * Apply suggestions from code review Co-authored-by: Genevieve Warren <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: BillWagner <[email protected]> Co-authored-by: Bill Wagner <[email protected]> Co-authored-by: Genevieve Warren <[email protected]>
1 parent e712bd0 commit b1f9c7c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/csharp/language-reference/compiler-messages/assembly-references.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,35 @@ These compiler errors indicate one of these problems in your code:
8989
- You used the [global scope operator, (`::`)](../operators/namespace-alias-qualifier.md) when the type isn't in the global namespace.
9090
- You're accessing an extension member and either the namespace isn't specified in a `using` directive, or you're not referencing the assembly that contains the extension.
9191

92+
### When the assembly appears to be referenced
93+
94+
If the assembly appears to be referenced in your project but you still receive CS0012, try these troubleshooting steps:
95+
96+
- Restore packages: Run `dotnet restore` to ensure all package references are properly resolved, especially after installing or uninstalling NuGet packages.
97+
98+
- Clear the NuGet package cache and restore:
99+
100+
```console
101+
dotnet nuget locals all --clear
102+
dotnet restore
103+
```
104+
105+
- Check for version conflicts: Verify that all referenced assemblies use compatible versions. Look for binding redirect warnings in the build output.
106+
107+
- Clean the solution and rebuild to ensure no stale references remain:
108+
109+
```console
110+
dotnet clean
111+
dotnet build
112+
```
113+
114+
- Verify package integrity: If the error occurred after package operations, ensure the package was installed correctly by removing and reinstalling it:
115+
116+
```console
117+
dotnet remove package [PackageName]
118+
dotnet add package [PackageName]
119+
```
120+
92121
## Type forwarding
93122

94123
- **CS1068**: *The type name could not be found in the global namespace. This type has been forwarded to another assembly. Consider adding a reference to that assembly.*

0 commit comments

Comments
 (0)