I have researched google and SO and can not find answer.
I have looked at following post with out any success.
Use class inside a T4 template
In my T4 template, I am trying to use AddControls Method defined in my Custom class ResourceManager but I am getting the following error.
Compiling transformation: The type or namespace name 'WebApplication1' could not be found (are you missing a using directive or an assembly reference?)
Please help me.
namespace WebApplication1
{
public static class ResourceManager
{
public static void AddControls(List<string> controlList)
{
controlList.Add("Label1");
controlList.Add("Button1");
}
}
}
My T4 Template code looks as follows:
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ output extension=".txt" #>
<#@ assembly name="$(TargetPath)" #>
<#@ import namespace="WebApplication1" #>
<#@ import namespace="System.Collections.Generic" #>
<#
List<String> controlList = new List<String>();
ResourceManager.AddControls(controlList);
foreach (string str in controlList)
{
string propName= str;
#>
My control is <#= propName #>
<#
}
#>
Build the project that contains namespace WebApplication1
and try saving the template again.
That worked for me using your code.
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