locked
Host.ResolveParameterValue() throws ArgumentNullException (VS2010) RRS feed

  • Question

  • I am using VS 2010 SP1 (10.0.40219.1 SP1Rel).

    The MSDN page here: http://msdn.microsoft.com/en-us/library/gg586944.aspx under the section "Obtaining arguments from TextTemplate.exe"

    And the MSDN page here: http://msdn.microsoft.com/en-us/library/bb126245.aspx under the section detailing the "-a" parameter

    Both indicate that Host.ResolveParameterValue(string, string, string) can be called like:

    Host.ResolveParameterValue("","","argName")

    However, running withing VS2010 (by saving changes to a .tt file) or by running command line (C:\...\TextTemplating\10.0\TextTransform.exe) throws the error:

    RunningTransformation: System.ArgumentNullException: Value cannot be null.
    Parameter name: directiveId
    Server stack trace:
      at Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolveParameterValue(String directiveId, String processorName, String parameterName)

    Is this a bug, or the expected behavior? Thanks for any help!



    • Edited by rally25rs Monday, April 11, 2011 2:19 PM fixed links
    Monday, April 11, 2011 2:18 PM

Answers

  • Nevermind, I figured out my issue.  The exception only occurs when run within VisualStudio, which I can handle with a simple try/catch around the call to Host.ResolveParameterValue.

    I thought TextTransform.exe was also throwing the error because I was calling it from a pre-build task, so the error was showing up in the "errors" window in VS after a build, but the error was just there from the previous attempt to save the .tt file, not from the pre-build task that ran TextTransform.exe.

    • Marked as answer by Victor_Chen Tuesday, April 12, 2011 2:56 AM
    Monday, April 11, 2011 2:32 PM

All replies

  • Nevermind, I figured out my issue.  The exception only occurs when run within VisualStudio, which I can handle with a simple try/catch around the call to Host.ResolveParameterValue.

    I thought TextTransform.exe was also throwing the error because I was calling it from a pre-build task, so the error was showing up in the "errors" window in VS after a build, but the error was just there from the previous attempt to save the .tt file, not from the pre-build task that ran TextTransform.exe.

    • Marked as answer by Victor_Chen Tuesday, April 12, 2011 2:56 AM
    Monday, April 11, 2011 2:32 PM
  • I'm glad to know it is resolved.
    Ziwei Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, April 12, 2011 2:56 AM
  • I am triggering a T4 template from a batch file.

    Batch file:

    "%CommonProgramFiles%\Microsoft Shared\TextTemplating\10.0\texttransform.exe" -a !!envKey!PROD -out !file_name! %%d

    In the T4 template I have

    this.Host.ResolveParameterValue(null, null, "envKey");

    It contains an empty string. I am not able to figure out why?

    Appreciate your help.

    Sunday, July 28, 2013 9:17 PM