Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > T4 and DotNet 3.5
 

T4 and DotNet 3.5

Can any one tell me if I can use .net 3.5 in T4 inside my guidance???

I'm trying to just call a partial method. Here is a sample:

<#@ template language="C#v3.5" debug="True" #>
<#@ property processor="PropertyProcessor" name="ClassName" #>
<#@ property processor="PropertyProcessor" name="TargetNamespace" #>
<#@ property processor="PropertyProcessor" name="Hello" #>
<#@ assembly name="F:\DotNet\Factory\GuidancePackage1\PartialMethods\bin\Debug\PartialMethods.dll" #>
<#@ Assembly Name="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" #>
<#@ import namespace="PartialMethods" #>
<#@ assembly name="System.dll" #>

using System;
using System.Text;

namespace <#= TargetNamespace #>
{
class <#= ClassName #>
{
static void Main(string[] args)
{
Console.WriteLine("<#= Hello #>");
Console.WriteLine("<#= "Write Day".ConcatenaDiaHora() #>");
Console.ReadLine();
}
}
}


here is the error

Microsoft.Practices.RecipeFramework.ActionExecutionException: An exception occurred during the binding of reference or execution of recipe AddMainClass. Error was: Action GenerateMainClass failed to execute:
Exception of type 'Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TemplateException' was thrown..
You can remove the reference to this recipe through the Guidance Package Manager. ---> An invalid language 'C#v3.5' was specified in the 'template' directive. The language must be either "C#" or "VB". The default value of "C#" will be used.
----------------------------------------------------------------------------------------------------
Compiling transformation: Metadata file 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' could not be found
----------------------------------------------------------------------------------------------------

--- End of inner exception stack trace ---
at Microsoft.Practices.RecipeFramework.Recipe.UndoExecutedActionsAndRethrow(Exception ex)
at Microsoft.Practices.RecipeFramework.Recipe.ExecuteActions(IDictionaryService readOnlyArguments, IDictionaryService arguments, ITypeResolutionService resolution)
at Microsoft.Practices.RecipeFramework.Recipe.Execute(Boolean allowSuspend)
at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(String recipe, IAssetReference reference, IDictionary arguments)
at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(IAssetReference reference)
at Microsoft.Practices.RecipeFramework.RecipeReference.OnExecute()
at Microsoft.Practices.RecipeFramework.VisualStudio.VsBoundReference.OnExecute()
at Microsoft.Practices.RecipeFramework.AssetReference.Execute()
at Microsoft.Practices.RecipeFramework.VisualStudio.RecipeMenuCommand.OnExec()
at Microsoft.Practices.RecipeFramework.VisualStudio.AssetMenuCommand.Invoke()


why can't I use C#v3.5 in T4 in my guidance???
Can any one tell how can i do it and a sample please....
Pedro Rainho  Thursday, September 11, 2008 10:32 AM
Hi Pedro,

this is a known issue of GAX and most probably will be fixed in a hotfix that should be available soon (we're working on it right now)
in the meantime what you can do is add the following redirects in you devenv.exe.config

<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.TextTemplating" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.TextTemplating.VSHost" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>


(it just applies for Vs2008)
those redirects fix the issue.

Regarding the template that you've posted remember that you should use just the assembly name or a path so when you put
<#@ Assembly Name="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" #>
should be
<#@ Assembly Name="System.Core.dll" #>

hope it helps
jose.


Jose Escrich - weblogs.asp.net/jescrich
  • Proposed As Answer byJose Escrich Wednesday, September 17, 2008 9:52 PM
  •  
Jose Escrich  Thursday, September 11, 2008 8:35 PM
Jose,
Is there there any information you can give us on the status of the hotfix you mentioned in the above post? I tried adding he redirects to my devenv.exe.config file, but it didn't help any. Could that be because I was using the guidance package in a VS instance that was running in the experimental hive?
Mike Holczer  Friday, May 22, 2009 5:12 PM

You can use google to search for other answers

Custom Search

More Threads

• Programatically moving Projects within a Solution
• Could I add repeating code with this technology in my solution in C#.net?
• Command Bar to Bound recipe
• Microsoft.VisualStudio.TextTemplating 8.2
• Best practice for Testing
• URGENT: Project and Item Templates issue!
• Register Guidance Package Problem
• Problem Loading Package
• Custom Directory Structure through GAT
• Trouble Installing Mobile Client Software Factory in Vista x64 Ultimate and Win2k3 Server Standard x64...