In a T4 template the executing assembly is not yours but one from the T4 engine.

To access types from your assemblies, you have to perform the following steps:

  1. Add a reference to your assembly to the template. Put that at the top of it:

    <#@ assembly name="$(SolutionDir)<Project>\bin\Debug\<Project>.dll" #>
    
  2. Import the namespace of your assembly. Put that somewhere below the previous line:

    <#@ import namespace="<Project>.<Namespace>" #>
    
  3. To access the types in this assembly, pick one of them and get the assembly from it:

    var assembly = typeof(<Type in assembly>).Assembly;
    var types = assembly.GetTypes()
                        .Where(t => String.Equals(
                            t.Namespace,
                            "RepoLib.Rts.Web.Plugins.Profiler.Models",
                            StringComparison.Ordinal))
                        .ToArray();

相关文章:

  • 2022-01-12
  • 2022-02-21
  • 2021-05-28
  • 2021-07-12
  • 2021-07-24
  • 2021-12-25
  • 2021-07-11
猜你喜欢
  • 2021-12-26
  • 2022-12-23
  • 2021-06-09
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案