Search code examples
.netunity-container.net-4.5.net-4.5.2

Unity DIC missing System.Runtime reference


I've a plain new .NET 4.5 class library project.

To this project I add the current Unity NuGet package and add the dependency attribute to one property.

Then I got the following compile error:

Error 9 The type 'System.Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

But there is the correct DLL in the Facades directory:

%program files%\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\Facades\System.Runtime.dll

By adding the Reference manually the error disappears.

But for me that smells.

Also the assembly doesn't appear to be in the GAC.

When I build a custom attribute and annotate a class with it, I don't get this error. So it should be related to Unity DIC?

Does someone know what's the reason behind this? And is there a better way to resolve this?


Solution

  • It seems like this is an error when 4.5.2 comes only whith visual studio

    reinstalling the .net 4.5.2 sdk helped