Build Problem With System.Object is defined in an assembly that is not referenced

Visual Studio 2013 build correctly your Asp.Net MVC under .Net Framework 4.5.2 but when you commit to Visual Studio TFS online the Build Server gives you an error about System.Object. The error that can be something about System.Object that is not defined in an assembled.

Here is the full exception.

Entities\Trading\Portefolio.cs (41): The type ‘System.Object’ 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 because Visual Studio on your computer knows to get them by going into a system folders. For example, the folder C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades has a lot of assembly that Visual Studio known on your computer .

To fix this problem you need to open your Web.Config file and add under System.Web a compilation section.

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

An important notion is that the httpRuntime target framework must be the same as the one defined in the compilation. The last thing that might be required is to force msbuild to use the targetframework you want. To do so, open Visual Studio Online or edit within Visual Studio the Build Definition to use the framework 4.5.2 (or the one defined in your web.config). You have to set the framework to the same as the web.config. If you already have argument after /p you just need to append the targetframeworkversion with the framework version desired.


Finally, if you still have problem building with Visual Studio, at the time I am writing this article, the Visual Studio Online team have confirming me that they does not support the latest framework of .Net. This should be solve in few months.

If you like my article, think to buy my annual book, professionally edited by a proofreader. directly from me or on Amazon. I also wrote a TypeScript book called Holistic TypeScript

1 thought on “ Build Problem With System.Object is defined in an assembly that is not referenced

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.