aspnet_compiler 在 C# mvc2 应用程序上寻找 jsharp 代码提供程序
我正在 Windows 7 64 位上的 Visual Studio 2010 中编译 MVC2 应用程序。我正在运行以下命令作为构建后事件命令:
aspnet_compiler.exe -v / -p \
它会导致以下错误:-
The CodeDom provider type "Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" could not be located
我的解决方案中没有 J#。我已经下载了 J# 2.0 可再发行包第二版,但这没有帮助。
有趣的是,我在全新的 MVC2 解决方案中运行了这个并得到了同样的错误!所以这和我的申请没有任何关系。
我错过了什么导致这个错误?
我读过许多其他帖子,说您需要安装可再发行组件,在 web.config 等中添加引用,但它们没有帮助。
有什么想法吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我今天也遇到这样的情况,后来找到了解决办法。
我正在使用 VS 2010 和 ASP.NET MVC 3 站点,使用 Razor,在 IIS(不是 IIS Express 或 Cassini)中运行。
就我而言,此错误出现在我的 .cshtml 视图中。对于我打开的任何视图,第一行
@using
都带有下划线,并显示错误:整个页面还存在奇怪的错误,例如两个同名程序集之间的引用不明确(例如,“System.Web.Helpers”和“System.Web.Helpers”之间据称存在冲突)。
原因:我在没有足够权限的用户帐户下运行该网站。该帐户具有 IIS_IUSRS 角色,但显然需要其他角色或访问权限才能完成此操作,或者它可能需要访问它无法访问的特定文件夹。
不幸的是,我不知道它是什么,而且我对浪费时间来弄清楚它的想法并不感到兴奋,因为我已经花了太多时间试图弄清楚这是如何发生的。
但为该用户授予管理员角色可以解决该错误。
我意识到这不是一个理想的解决方案,但我希望至少它能让一些人摆脱困境。如果有人确切地弄清楚防止此错误所需的权限,请在下面发表评论,也许我们可以缩小范围。
I had this happen today, and found a solution of sorts.
I'm using VS 2010 and an ASP.NET MVC 3 site, using Razor, running in IIS (not IIS Express or Cassini).
In my case this error cropped up in my .cshtml views. For any view I opened, the first
@using
line was underscored with the error:There were also bizarre errors throughout the page, such as ambiguous references between two assemblies with the same name (e.g. a supposedly conflict between "System.Web.Helpers" and "System.Web.Helpers").
The cause: I was running the web site under a user account that didn't have sufficient permissions. The account had the IIS_IUSRS role, but apparently there's some other role or access it needs to make this work, or it may need access to a particular folder it couldn't get to.
Unfortunately, I don't know what it is, and I'm not excited about the idea of wasting hours to figure it out after I already spent way too much time trying to figure out how this happened in the first place.
But giving that user the Administrators role resolved the error.
I realize this isn't an ideal solution, but I hope at least it gets some people unstuck. If anyone figures out exactly what permissions are necessary to prevent this error, comment below and perhaps we can narrow it down.
@Adrian - 我今天遇到了这个问题,几乎立即修复了它,它试图在 C# 项目中编译 J#,出现奇怪的错误。但问题是我将 .java 文件复制到我的项目文件夹中,然后出现了问题。一旦我删除了它,一切都再次编译得很好。
@Adrian - I had this problem today and fixed it nearly straight away, it was trying to compile J# in a C# project, weird error. But the problem was I copied a .java file into my project folder and the issue occured. Once I removed that, it all compiled again fine.
@Kyralessa:我遇到了完全相同的错误。将管理员角色添加到网站运行的用户“修复”了问题,但正如您所说,这不是一个理想的解决方案。
因此,我摆弄了 IIS 设置,在网站的基本设置下,我切换到“应用程序用户(直通身份验证)”,问题就消失了。应用程序池仍然在同一(非管理员)用户下运行,因此不存在安全问题。
@Kyralessa : I was having the exact same error. Adding the Administrators role to the user under which the website was running "fixed" the problem but as you said it is not an ideal solution.
So I was fiddling around with IIS settings and under the Basic settings of the website I switched to "Application user (pass-through authentication)" and the problem disappeared. The app pool still runs under the same (non-admin) user so there is no security issue.
尝试安装以下软件包之一:
32 位:http://www .microsoft.com/download/en/details.aspx?id=18084
64 位:http://www.microsoft.com/download/en/confirmation.aspx?id=15468
当其他解决方案都不起作用时,这让我克服了错误。
Try installing one of the packages below:
32-bit: http://www.microsoft.com/download/en/details.aspx?id=18084
64-bit: http://www.microsoft.com/download/en/confirmation.aspx?id=15468
This got me past the error when none of the other solutions would work.
当我将 csproj 中的 MvcBuildViews 属性设置为 true 时,我遇到了同样的错误。经过大量研究和试验/错误,我了解到问题是因为我们的网站在网站结构中有 .java 文件。这些 java 文件不是解决方案的一部分,只是松散的文件。 Aspnetcompiler 任务从项目根目录运行,因此它会发现各种问题,例如重复的 web.configs 和 *.java 文件。
为了解决这个问题,我在尝试调试的 MVC 项目文件中创建了以下目标:
希望这可以节省我花 3 个小时来弄清楚的时间...
更新:
因为这确实会增加构建时间,所以您可以选择添加到顶部的条件,以便仅在发布样式构建期间执行此检查:
I was having this same error when I set MvcBuildViews property in the csproj to true. After much research and trial/error, I learned that the problem was because our site had .java files in the site's structure. These java files were not a part of the solution, simply loose files. The Aspnetcompiler task runs from the project root, so it finds all kinds of issues like duplicate web.configs and *.java files.
To deal with this, I created the following target in the MVC project file I was trying to debug:
Hope this saves someone the 3 hours it took me to figure out...
Update:
Because this does add more time to the build, you may choose to add to the condition at the top to only perform this check during Release style builds: