I have a Windows Store Application that use a portable class library with a T4 template. When I run the transformation it fails with the following error:
Compiling transformation: The type 'System.Object' 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'.
I tried to add reference to the System.Runtime library manually, but I got message "The component is already automatically referenced by the build system"
The same library works in a Silverlight project as well as in a Windows Phone project.
Does anybody have an idea where is the problem?
I am new in developing Windows Store applications, so it might be some trivial error, but I am unable to find any solution.
You could resolve this CS0012 by compiling with /reference:cs0012b. dll;cs0012a. dll , or in Visual Studio by using the Add Reference Dialog Box to add a reference to cs0012a. dll in addition to cs0012b.
In order to share an assembly with other applications, it must be placed in the global assembly cache (GAC).
The type 'SpatialReference' is defined in an assembly that is not referenced. You must add a reference to assembly 'Esri. ArcGISRuntime, Version=10.2. 7.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86'.
Reference assemblies are usually distributed with the Software Development Kit (SDK) of a particular platform or library. Using a reference assembly enables developers to build programs that target a specific library version without having the full implementation assembly for that version.
Summary:
To solve this exact issue, simply add the following to the top of the T4 template:
<#@ assembly name="System.Runtime" #>
Long answer:
T4 templates are a compile-time concept, and therefore runs in the context & framework of the build stack (ie .NET Framework 4.5), not in the context of the host project, so modifying the Store project to add the reference to System.Runtime is not going to help.
Instead, what you should be doing is telling T4 about the reference via the template itself. This is normally handled automatically for tools that use MSBuild, however, T4 basically calls the compilers directly and therefore needs to manually be told about each portable reference assembly.
As you start to write real code in the portable library, you will quickly find that you need to add a lot more references; basically, every assembly under %PROGRAMFILES(x86)%\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\Facades. If you do this in a lot of templates, I'd recommend creating a single include template that contains an assembly directive for every file in the above folder.
In my case (Xamarin Studio), the solution was to do a clean build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With