mvcscaffolding fails with error Could not load file or assembly System.Management.Automation

Mar 22, 2013 at 9:00 PM
Why I get this,
Do I need some kind of reference or package ?
I'm running VS 2012 on a Win7 box:

Check this trace:

Set-DefaultScaffolder : Object reference not set to an instance of an object.
At C:\SmarterCommerceSVN\5x\Development\Trunk\SmartBusiness\packages\T4Scaffold
ing.Core.1.0.0\tools\init.ps1:50 char:30
  • Set-DefaultScaffolder <<<< -Name CustomTemplate -Scaffolder T4Scaffo
    lding.CustomTemplate -SolutionWide -DoNotOverwriteExistingSetting
    • CategoryInfo : NotSpecified: (:) [Set-DefaultScaffolder], NullR
      eferenceException
    • FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet
Set-DefaultScaffolder : Object reference not set to an instance of an object.
At C:\SmarterCommerceSVN\5x\Development\Trunk\SmartBusiness\packages\T4Scaffold
ing.Core.1.0.0\tools\init.ps1:51 char:30
  • Set-DefaultScaffolder <<<< -Name CustomScaffolder -Scaffolder T4Scaf
    folding.CustomScaffolder -SolutionWide -DoNotOverwriteExistingSetting
    • CategoryInfo : NotSpecified: (:) [Set-DefaultScaffolder], NullR
      eferenceException
    • FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet
Set-DefaultScaffolder : Object reference not set to an instance of an object.
At C:\SmarterCommerceSVN\5x\Development\Trunk\SmartBusiness\packages\T4Scaffold
ing.1.0.8\tools\init.ps1:6 char:22
  • Set-DefaultScaffolder <<<< -Name DbContext -Scaffolder T4Scaffolding.EFDbCon
    text -SolutionWide -DoNotOverwriteExistingSetting
    • CategoryInfo : NotSpecified: (:) [Set-DefaultScaffolder], NullR
      eferenceException
    • FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet
Set-DefaultScaffolder : Object reference not set to an instance of an object.
At C:\SmarterCommerceSVN\5x\Development\Trunk\SmartBusiness\packages\T4Scaffold
ing.1.0.8\tools\init.ps1:7 char:22
  • Set-DefaultScaffolder <<<< -Name Repository -Scaffolder T4Scaffolding.EFRepo
    sitory -SolutionWide -DoNotOverwriteExistingSetting
    • CategoryInfo : NotSpecified: (:) [Set-DefaultScaffolder], NullR
      eferenceException
    • FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet
New-Object : Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system
cannot find the file specified.
At C:\SmarterCommerceSVN\5x\Development\Trunk\SmartBusiness\packages\MvcScaffolding.1.0.9\tools\registerWithMvcTooling.ps1:163 char:27
  • $newProvider = New-Object <<<< $powerShellScaffolderProviderType($mvcScaffoldingProvider)
    • CategoryInfo : NotSpecified: (:) [New-Object], FileNotFoundException
    • FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.NewObjectCommand
Set-DefaultScaffolder : Object reference not set to an instance of an object.
At C:\SmarterCommerceSVN\5x\Development\Trunk\SmartBusiness\packages\MvcScaffolding.1.0.9\tools\init.ps1:47 char:22
  • Set-DefaultScaffolder <<<< -Name Controller -Scaffolder MvcScaffolding.Controller -SolutionWide -DoNotOverwriteExistingSetting
    • CategoryInfo : NotSpecified: (:) [Set-DefaultScaffolder], NullReferenceException
    • FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet
Set-DefaultScaffolder : Object reference not set to an instance of an object.
At C:\SmarterCommerceSVN\5x\Development\Trunk\SmartBusiness\packages\MvcScaffolding.1.0.9\tools\init.ps1:48 char:22
  • Set-DefaultScaffolder <<<< -Name Views -Scaffolder MvcScaffolding.Views -SolutionWide -DoNotOverwriteExistingSetting
    • CategoryInfo : NotSpecified: (:) [Set-DefaultScaffolder], NullReferenceException
    • FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet
Set-DefaultScaffolder : Object reference not set to an instance of an object.
At C:\SmarterCommerceSVN\5x\Development\Trunk\SmartBusiness\packages\MvcScaffolding.1.0.9\tools\init.ps1:49 char:22
  • Set-DefaultScaffolder <<<< -Name Action -Scaffolder MvcScaffolding.Action -SolutionWide -DoNotOverwriteExistingSetting
    • CategoryInfo : NotSpecified: (:) [Set-DefaultScaffolder], NullReferenceException
    • FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet
Set-DefaultScaffolder : Object reference not set to an instance of an object.
At C:\SmarterCommerceSVN\5x\Development\Trunk\SmartBusiness\packages\MvcScaffolding.1.0.9\tools\init.ps1:50 char:22
  • Set-DefaultScaffolder <<<< -Name UnitTest -Scaffolder MvcScaffolding.ActionUnitTest -SolutionWide -DoNotOverwriteExistingSetting
    • CategoryInfo : NotSpecified: (:) [Set-DefaultScaffolder], NullReferenceException
    • FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet
Set-DefaultScaffolder : Object reference not set to an instance of an object.
At C:\SmarterCommerceSVN\5x\Development\Trunk\SmartBusiness\packages\MvcScaffolding.1.0.9\tools\init.ps1:54 char:22
  • Set-DefaultScaffolder <<<< -Name View -Scaffolder $viewScaffolder -SolutionWide -DoNotOverwriteExistingSetting
    • CategoryInfo : NotSpecified: (:) [Set-DefaultScaffolder], NullReferenceException
    • FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet
PM> New-Object : Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system
cannot find the file specified.
At C:\SmarterCommerceSVN\5x\Development\Trunk\SmartBusiness\packages\MvcScaffolding.1.0.9\tools\registerWithMvcTooling.ps1:163 char:27
  • $newProvider = New-Object <<<< $powerShellScaffolderProviderType($mvcScaffoldingProvider)
    • CategoryInfo : NotSpecified: (:) [New-Object], FileNotFoundException
    • FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.NewObjectCommand
Apr 12, 2013 at 5:33 PM
+1 am getting same error on win 7 vs2012 ultimate...

cant even add a controller now :-/
Apr 19, 2013 at 12:01 AM
I'm getting this now too. Since there hasn't been any MvcScaffolding updates, it's probably something else that causing it. Just not sure what yet....

If anyone finds a solution, please post.
Apr 23, 2013 at 11:19 PM
Installing powershell 3 fixed this error for me. Same as
https://visioautomation.codeplex.com/discussions/397034