views:

114

answers:

1

I'm creating a t4 template that will generate an enum from a number of values in our database. The weird thing is that as soon as I try to create a DataTable in the template code i get the ErrorGeneratingOutput message:

<#@ template language="C#v3.5" debug="True" #>
<#@ output extension="CS" #>
<#@ assembly name="System.Data" #> 
<#@ assembly name="System.Configuration" #>
<#@ import namespace="System.Data" #>
<#@ import namespace="System.Data.SqlClient" #>
<#@ import namespace="System.Data.Common" #> 

public enum Foo
{
<#
     //DataTable table = new System.Data.DataTable();
     #> 
}

When the line where the table is created is commented out there is no problem but if I remove the comment I get an error. I'm pulling my hair on this one, what am I missing?

A: 

When I rebuilt my project the template belongs to I got a more sensible error message pointing out that I was not referencing the System.Xml-assembly:

<#@ assembly name="System.Xml" #>

Patrik Hägne