Solved

Problem with namespaces in my T4 templates

Posted on 2011-02-16
2
902 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
2 Comments
 
LVL 3

Accepted Solution

by:
chandra_darbha earned 500 total points
Comment Utility
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
Comment Utility
Thanks.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now