Skip to content

Commit 8005b0c

Browse files
CopilotBillWagner
andcommitted
Add troubleshooting section for CS0012 when assemblies appear to be referenced
Co-authored-by: BillWagner <[email protected]>
1 parent 2967f95 commit 8005b0c

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+
1. **Restore packages**: Run `dotnet restore` to ensure all package references are properly resolved, especially after installing or uninstalling NuGet packages.
97+
98+
1. **Clear package caches**: Clear the NuGet package cache and restore:
99+
100+
```console
101+
dotnet nuget locals all --clear
102+
dotnet restore
103+
```
104+
105+
1. **Check for version conflicts**: Verify that all referenced assemblies use compatible versions. Look for binding redirect warnings in the build output.
106+
107+
1. **Clean and rebuild**: Clean the solution and rebuild to ensure no stale references remain:
108+
109+
```console
110+
dotnet clean
111+
dotnet build
112+
```
113+
114+
1. **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)