[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Problem with namespaces in my T4 templates

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

Independent Software Vendors: 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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

873 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