I have a *.tt file (two, actually, but they are acting similarly, so I'll just talk about one).
I have them set just like another project, where they work fine. Their properties are set the same, such as:
CustomTool = TetxtTemplatingFilePreprocessor
When I select "Run Custom Tool", a corresponding *.cs file is created:
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version: 10.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
But the project won't compile, because this code in the auto-generated file (FormTemplate.cs):
FormTemplate formTemplate = new FormTemplate(POST, this);
output.Write(formTemplate.TransformText());
...won't compile. The err is, "'QuizModule.QuizModuleWebPart.Templates.FormTemplate' does not contain a definition for 'TransformText' and no extension method 'TransformText' accepting a first argument of type 'QuizModule.QuizModuleWebPart.Templates.FormTemplate' could be found"
How can it generate the code, and then not be able to find a method it references? Actually, it did generate the method, and it is right there in FormTemplate.cs:
#line 1
"C:\Projects\QuizModule_Test\QuizModule_Test\QuizModuleWebPart\Templates\FormTem
plate.tt"
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "10.0.0.0")]
public partial class FormTemplate : FormTemplateBase
{
{
public virtual string TransformText()
{
Why would it be that it cannot see its own method?
This turned out to be one of those "my bads" that produces seemingly in[s]ane err msgs. What happened was, some of my namespaces were wrong - the code had been copied over verbatim from another project, and the namespaces had not been updated. Once those were rectified, the project compiled just fine.
CAUSE
This turned out to be one of those "my bads" that produces seemingly in[s]ane err msgs.
SOLUTION
What happened was, some of my namespaces were wrong - the code had been copied over verbatim from another project, and the namespaces had not been updated. Once those were rectified, the project compiled just fine.