Reputation: 4076
output type of 'Class Library', and a target framework of '.NET Framework 4'.
According to everything I've read, I should have it available, but all I'm seeing in the System.Runtime namespace is the following:
CompilerServices
ConstrainedExecution
ExceptionServices
Hosting
InteropServices
Remoting
Serialization
Versioning
Any ideas?
Upvotes: 36
Views: 33144
Reputation: 3775
For me the System.Runtime.Caching NuGet package is what I needed little bit o this and all was well
dotnet add package System.Runtime.Caching --version 5.0.0
Upvotes: 3
Reputation: 1502825
You just need to add a reference to the System.Runtime.Caching
assembly.
System.Runtime.Caching.dll
. It's not part of the default set of references in a class library, but you should be able to add it with no problems.
Upvotes: 68
Reputation: 4617
To complement Jon Skeets answer, (for those who run into this problem), if you still get red squiggly lines under Caching
after having added reference to System.Runtime.Caching
assembly, just restart the Visual Studio, after having saved the solution, and you should be good to go.
Having added the reference, saved the solution and ( if need may be ) restarted Visual Studio, you should be able to use the types
within this namespace
. In order to get my solution to work, I had to do this very way.
While trying to recreate the problem, and solving this way, it seems that we need to set Copy Local
to True
in System.Runtime.Caching
> Properties
and then restart Visual Studio for getting it to work. At least, for my case, the problem didn't seem to solve without this. ;)
Upvotes: 18
Reputation: 7666
Reference System.Runtime.Caching.dll
. This is another one of those rather obtuse gotchas in the .NET framework right now where there will be very similar namespaces in some things, but the actual classes you want will be referenced in different assembles. As an example, CacheItem is in this alternate DLL, whereas ApplicationActivator (in System.Runtime.Hosting) is in mscorlib.
Upvotes: 5