Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# T4 template engine can't import "System.Xml"

Tags:

t4

I use the method in this MSDN link ("Processing Text Templates by using a Custom Host").

This allows me to use T4 programmatically (template can be available in runtime).

But there is a problem that in the template code I can't use

<#@ Import Namespace="System.Xml" #>

I would get message like :

error CS0234: Compiling transformation: The type or namespace name 'Xml' does not exist in the namespace 'System' (are you missing an assembly reference?)

How do I resolve this ?

like image 577
morgan Avatar asked Aug 31 '25 16:08

morgan


1 Answers

You need to reference the assembly. The import statement is equivalent to the using statement in C#. You can reference the System.Xml assembly by using:

<#@ assembly name="System.Xml" #>
like image 121
Matt Ward Avatar answered Sep 03 '25 19:09

Matt Ward