Unable to use my custom class in T4 template.

I have researched Google and SO and cannot find the answer.

I watched the next post without any success.

Use class inside T4 template

In my T4 template, I'm trying to use the AddControls method defined in my custom ResourceManager class, but I get the following error.

Conversion compilation: The type or name of the namespace 'WebApplication1' could not be found (are you missing the using directive or assembly references?)

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 template is 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 #>

<#
    }

#>
+5
source share
1 answer

, WebApplication1, . .

+4

All Articles