Why am I getting 'System.IDisposable' is defined in an assembly that is not referenced??


I have a WCF .NET 4.5 project I am trying to build. I have a nuget reference to UNITY.WCF (Along with the associated unity references). The references are set to copy local true.

Now everytime I build I get the following error:

  • WcfServiceFactory.cs(41, 33): error CS0012: The type 'System.IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

This is baffling to me. I even updated the web.config adding the following (based on other sluething)

    <compilation debug="true" targetFramework="4.5">
        <add assembly="System.Runtime, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

This code builds fine locally and on a TFS build server. But I can't get this to work on the TeamCity server.. Has anyone run into something like this before?

This is very annoying.
1 comment
Comment actions Permalink

Well.. that was just masking my problem.

I peeled away the WCF project from the solution and just built the library projects. Upon doing this successfully I noticed a warning message:

warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

So that made me do a search for installing a SDK targeting pack which lead me to a SO article here: http://stackoverflow.com/questions/17220615/where-can-i-download-the-net-4-5-multitargeting-pack-for-my-build-server

The suggestion I tried was this:

You don't need to install any SDK. Just copy the following folder from your development machine into the same folder to your TFS build machine:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5

And guess what? That fixed my issue. Ugh.. Thanks for listening.


Please sign in to leave a comment.