Solved

Problem with namespaces in my T4 templates

Posted on 2011-02-16
2
941 Views
Last Modified: 2012-05-11
I am having trouble getting the T4 template to compile sine it finds a problem with the namespace.

I add a second import after the working one.  

<#@import namespace="System.Collections.Generic" #>
<#@import namespace="RDDBWebAdmin.Models" #>

The error is:

Compiling transformation: The type or namespace name 'RDDBWebAdmin' could not be found (are you missing a using directive or an assembly reference?)

'RDDBWebAdmin' is the project which contains the T4 template. Yet it can not find it.  Know why?


<#@import namespace="System.Collections.Generic" #> 
<# 
Dictionary<string,Type> properties = new Dictionary<string,Type>(); 
properties.Add("Age",typeof(int)); 
properties.Add("Firstname", typeof(string)); 
properties.Add("Surname", typeof(string)); 
#> 
using System; 

public class <#="MyClass"#>{ 
<# foreach(string name in properties.Keys) { #> 
    public <#=properties[name].Name#> <#=name#>{ 
        get; set; 
    } 
<# } #> 
} 

//// Generated code ///////
using System; 

public class MyClass{ 
      public Int32 Age{ 
            get; set; 
      } 
      public String Firstname{ 
            get; set; 
      } 
      public String Surname{ 
            get; set; 
      } 
}

Open in new window

0
Comment
Question by:newbieweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
chandra_darbha earned 500 total points
ID: 34913995
you need to add assembly reference to the assembly like this before the namespace import -

<#@ assembly name="RDDBWebAdmin.dll" #>

Thanks,
Chandra
0
 

Author Closing Comment

by:newbieweb
ID: 34916436
Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question