?
Solved

Problem with namespaces in my T4 templates

Posted on 2011-02-16
2
Medium Priority
?
943 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

771 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