Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling transformation: The type 'Object' is defined in an assembly that is not referenced

I'm making some changes in an asp.Net MVC5 webapp, in which I used typelite to create .ts definitions from C# classes (really handy). For some reason now I've got this error when executing the T4:

Compiling transformation: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

and this warning:

Compiling transformation: Assuming assembly reference 'mscorlib, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' used by 'EnvDTE' matches identity 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' of 'mscorlib', you may need to supply runtime policy Mair.Tracking.Web

I guess it's something related to the EnvDTE version used by TypeLite and the reference to mscorlib EnvDTE uses. Should I add a bindingRedirect in the web.config?

I'm using VS2015 with Update2 CTP.

like image 715
qwertoyo Avatar asked Feb 15 '16 14:02

qwertoyo


2 Answers

I can confirm that Portable class libraries in combination with T4 templates cause this problem in Visual Studio 2015 Update 2. I wasn't able to find better solution then retargeting TypeLITE to full .NET framework.

From the version 1.8.0 TypeLITE nuget package contains a copy of the library that targets full .NET framework. If your project targets full .NET framework, the correct TypeLITE assembly is picked up during installation and everything works fine in Visual Studio 2015 Update 2. Unfortunately if your project targets PCL, you are out of luck with Visual Studio 2015 Update 2. I am looking for better solution.

like image 97
Lukas Kabrt Avatar answered Sep 23 '22 02:09

Lukas Kabrt


Thanks to Ian Yates for opening the Connect item.

Microsoft re-released KB3151378 on May 4, 2016. I can confirm that this update addresses the issue when T4 templates are used with EDMX files. Unfortunately I do not use TypeLite, so I am unable to confirm that it addresses the OP's issue, though I would suspect it does.

From the KB page:

Issue 6:

In T4 templates, errors occur when you reference an assembly that's built for a version of the .NET Framework that differs from the desktop (full) framework. For instance, errors occur when you reference portable libraries.

like image 24
SvenAelterman Avatar answered Sep 27 '22 02:09

SvenAelterman