更新时间:2021-08-12 20:14:28
这个问题似乎已经被MvcScaffolder包的一个不完整的安装/注册引起的。
下面的程序解决了我,我的问题。
The issue seems to have been caused by an incomplete install/registration of the MvcScaffolder package. The following process resolved my issue for me.
启动Visual Studio并打开项目。 打开包管理器控制台即可。 (这是绝招或信息缺失的环节,导致了解决方案...)
Start Visual Studio and open the project. Open the Package Manager Console. (This was the "trick" or missing piece of information that led to the solution...)
在这里,我看到了造成注册时使用的PowerShell脚本以下错误:
Here I saw the following error caused by the PowerShell script used for registration:
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 <ProjectPath...>\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
当我检查了注册架子工从Package Manager控制台我:
When I checked the registered scaffolders from the Package Manager Console I got:
PM> get-defaultscaffolder
DefaultName ScaffolderName
Action MvcScaffolding.Action
Controller MvcScaffolding.Controller
CustomScaffolder T4Scaffolding.CustomScaffolder
CustomTemplate T4Scaffolding.CustomTemplate
DbContext T4Scaffolding.EFDbContext
Mailer Mailer.Razor
Repository T4Scaffolding.EFRepository
UnitTest MvcScaffolding.ActionUnitTest
View MvcScaffolding.RazorView
Views MvcScaffolding.Views
所以很明显的脚手架被配置为使用MvcScaffolding包,但包了注册错误。
So clearly the scaffolders are configured to use the MvcScaffolding package, but the package had a registration error.
有关该错误的快速搜索提供的这个链接http://mvcscaffolding.$c$cplex.com/discussions/437692它指的是https://visioautomation.$c$cplex.com/discussions/397034这意味着从http://www.microsoft.com/en-us/download/details.aspx?id=34595.提示因为我跑赢的时候我选择了Windows6.1-KB2506143-x64.msu程序文件7-64位。
A quick search for the error provided this link http://mvcscaffolding.codeplex.com/discussions/437692 which refers to https://visioautomation.codeplex.com/discussions/397034 that suggests installing PowerShell 3, which is actually part of the Windows Management Framework 3.0, available from http://www.microsoft.com/en-us/download/details.aspx?id=34595. I picked the Windows6.1-KB2506143-x64.msu file when prompted because I’m running Win 7-64-bit.
安装后重新启动电脑,重新打开Visual Studio和项目,并期待在包管理器控制台。如果错误消失了,那就这样是控制器的问题。
Restart the PC after installation, re-open Visual Studio and the project and look at the Package Manager Console. If the error is gone, then so is the controller problem.