Struggling to Get Anything to Work

Jul 21, 2010 at 10:44 AM

In my first scenarion I tried to be adventurous and reflect over a class - but it would not recognise the class which resides in the same assembly as my T4 template and scripts. I referenced the file, namespace and assembly - all without any luck.

So I go back to basics and coy oleg's example character for character from this blog post

Now the problem is this:

Error    7    Compiling transformation: The type 'Microsoft.SqlServer.Management.Sdk.Sfc.IDmfFacet' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.SqlServer.Management.Sdk.Sfc, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91'.    c:\Users\nick\Documents\NonProj_Apps\t4 t2\t4 t2\    12    9    t4 t2

So I reference ths missing .dll - and every other .dll in the SQL folder. But the problem still persists.

And now I sit here a broken man, questioning whether to continue with life. After being on the cusp of T4 greatness, I sit surrounded by emptiness and loneliness.

Please help my wounded soul.

Jul 21, 2010 at 10:56 AM

I've tried stripping out all the code and just doing a call to writeline in my template and RenerTransform() in the script. Here's the code


<#@ template language="C#" hostspecific="True" #>
<#@ output extension="txt" #>
<#@ include file="" #>
<#@ include file="" #>
    DeleteProcedureTemplate template = new DeleteProcedureTemplate();


public class DeleteProcedureTemplate : Template

    public override string TransformText()
        return this.GenerationEnvironment.ToString();


Surely this should work?......Well, maybe this is the problem:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3253: The referenced assembly "Microsoft.SqlServer.ScriptTask, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" could not be resolved because it has a dependency on "System.Drawing.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.
  t4 t2 -> C:\Users\nick\Documents\NonProj_Apps\t4 t2\t4 t2\bin\Debug\t4 t2.exe

I'm getting that message when I build. Does your toolbox have a problem with .NET 4.0 or is this message saying something else to me?




Jul 21, 2010 at 11:01 AM

So I'm targetting .NET 3.5 and now I get this....arghhhhhhhhhhh!

 No way to resolve conflict between "EnvDTE, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "EnvDTE, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "EnvDTE, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
  Consider app.config remapping of assembly "EnvDTE, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "7.0.3300.0" [] to Version "" [c:\Program Files\Common Files\Microsoft Shared\MSEnv\PublicAssemblies\EnvDTE.dll] to solve conflict and get rid of warning.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
  t4 t2 -> C:\Users\nick\Documents\NonProj_Apps\t4 t2\t4 t2\bin\Debug\t4 t2.exe


Jul 21, 2010 at 11:29 AM


This error is due to some new dependencies in the SMO implementation in SQL Server R2. This has nothing to do with T4 or the T4 Toolbox. You simply need to add the following assembly directive to the template:

<#@ assembly name="Microsoft.SqlServer.Management.Sdk.Sfc" #>

Referencing assemblies in the underlying Visual Studio project does not resolve T4 errors.


Jul 21, 2010 at 12:19 PM

Thanks Oleg,

My mission to bring peace to the world using the wonders of your T4 Toolbox is back on.

I owe you one.,