Situation: The project will build and run fine locally. Once the same code runs on TeamCity server it fails with the error:
The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=22.214.171.124
I tried every suggestion I could find for and none of them worked. I finally dropped the existing reference in the Project references to System.Runtime, then I add a reference to the local file C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Runtime.dll. This works for me.
The only reason this works is because that exact same file path exits on the the server.
What didn’t work for me:
- Making changes the assemblies section of the web.config file
- Adding the System.Runtime nuget package
- Referencing C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\???\Facades\System.Runtime.dll, where the same ??? framework didn’t exist on the TeamCity server.
I don’t really like this solution because it requires that as a developer that I know what files exist on the server, but this works for now and on this build server.
If you have this issue get with the person that runs your TC server and see if they can help you identify where the System.Runtime dll exists on the build server, then reference the file in the same location on your developer machine.
If this solution doesn’t work for other devs I think we could include the System.Runtime.dll in a folder in or project, and reference it there. That way it will travel with the code. It would be nice if the nuget package loaded it properly.