Type cannot be found (CS7069) [Answered]
I'm getting an error
Reference to type 'ITypeRegistrar' claims it is defined in 'Spectre.Console', but it could not be found
, despite the fact that I do have a reference to the Spectre.Console package. I have never encountered this error before and I have no idea how to resolve it.10 Replies
My package references are
The error only started occurring after I added the last two packages in the list, so I have no idea if they affected something.
Okay for more context
It also claims that it cannot convert from
SimpleInjectorRegistrar
to ITypeRegistrar
(which is required by the CommandApp
constructor)... but SimpleInjectorRegistrar
implements ITypeRegistrar
.
This makes no senseNot an expert but I have a very strong suspicion: https://github.com/nils-org/Spectre.Console.Registrars.SimpleInjector/blob/develop/src/Spectre.Console.Registrars.SimpleInjector/Spectre.Console.Registrars.SimpleInjector.csproj#L36
You mean
PrivateAssets="all"
?Yes and they are even different versions
0.44
huh
wait what does this mean, the version of Spectre.Console is different from that used by the package? Idk how that would matter
Well my main concern is private assets
What does private assets actually do?
I've seen it before (especially for source generators) but I don't know what it actually does
Ah, it hides that library as a dependency from consuming libs.
Explains why I had to manually install SimpleInjector
Sooo... is there any way to solve this?
I've pasted in the source code for
SimpleInjectorRegistrar
, removed the ref to Spectre.Console.Registrars.SimpleInjector
and it works 😄
The whole package is a single file anyway
Like... this class is the whole package, IDEK why it has to be a separate nuget thing
It didn't even utilize nullables 😅Yeah, the entire point was kinda not having to paste it in the project as it's just a redundant wrapper class, but yeah that works I suppose.
✅ This post has been marked as answered!