aspnet_compiler 在 C# mvc2 应用程序上寻找 jsharp 代码提供程序

发布于 10-17 11:25 字数 566 浏览 6 评论 0 原文

我正在 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 等中添加引用,但它们没有帮助。

有什么想法吗?

I am compiling an MVC2 application in Visual Studio 2010 on Windows 7 64-bit. I am running the following as a post-build event command:

aspnet_compiler.exe -v / -p \

It results in the following error:-

The CodeDom provider type "Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" could not be located

I have no J# in my solution. I've downloaded the J# 2.0 redistributable package Second Edition, but that didn't help.

The funny thing is, I ran this in a BRAND NEW MVC2 solution and got the same error! So it has nothing to do with my application.

What am I missing that's causing this error?

I have read many other posts that say you need to install the redistributable, add a reference in web.config etc. but they didn't help.

Any ideas??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

一个人的旅程 2024-10-24 11:25:56

我今天也遇到这样的情况,后来找到了解决办法。

我正在使用 VS 2010 和 ASP.NET MVC 3 站点,使用 Razor,在 IIS(不是 IIS Express 或 Cassini)中运行。

就我而言,此错误出现在我的 .cshtml 视图中。对于我打开的任何视图,第一行 @using 都带有下划线,并显示错误:

C:\PathToMyCode\PathToMyViews\Index.cshtml:ASP.NET 运行时错误:无法加载文件或程序集“VJSharpCodeProvider,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一。发生与安全相关的错误。 (HRESULT 异常:0x8013150A)

整个页面还存在奇怪的错误,例如两个同名程序集之间的引用不明确(例如,“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:

C:\PathToMyCode\PathToMyViews\Index.cshtml: ASP.NET runtime error: Could not load file or assembly 'VJSharpCodeProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. An error relating to security occurred. (Exception from HRESULT: 0x8013150A)

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.

永不分离 2024-10-24 11:25:56

@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.

剪不断理还乱 2024-10-24 11:25:56

@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.

離殇 2024-10-24 11:25:56

尝试安装以下软件包之一:

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.

梨涡少年 2024-10-24 11:25:56

当我将 csproj 中的 MvcBuildViews 属性设置为 true 时,我遇到了同样的错误。经过大量研究和试验/错误,我了解到问题是因为我们的网站在网站结构中有 .java 文件。这些 java 文件不是解决方案的一部分,只是松散的文件。 Aspnetcompiler 任务从项目根目录运行,因此它会发现各种问题,例如重复的 web.configs 和 *.java 文件。

为了解决这个问题,我在尝试调试的 MVC 项目文件中创建了以下目标:

<Target Name="MvcBuildViews" AfterTargets="Build" Condition="'$(MvcBuildViews)'=='true'">
   <!-- This task performs compilation of the CSHTML files in the web structure 
   and will generate compiler errors if there are issues in the views, such as missing
   resource strings, broken class locations, etc.
   Due to an issue with the AspNetCompiler task identifing .java files as candidates for
   compilation, we will temporarily rename all of the java files in the project to .xyz
   so they are skipped by aspnet compiler. Then we rename them back. 
   Extra web.configs also cause an error, so those are temporarily moved. -->
   <CreateItem Include="$(ProjectDir)**\*.java">
      <Output TaskParameter="Include" ItemName="JavaFolderA"/>
   </CreateItem>
   <CreateItem Include="$(ProjectDir)obj\**\web.config">
      <Output TaskParameter="Include" ItemName="ExtraWebConfigsA"/>
   </CreateItem>    
   <Move SourceFiles="@(JavaFolderA)" DestinationFiles="@(JavaFolderA->'$(ProjectDir)%(RecursiveDir)%(FileName).xyz')"/>
   <Move SourceFiles="@(ExtraWebConfigsA)" DestinationFiles="@(ExtraWebConfigsA->'$(ProjectDir)%(RecursiveDir)%(FileName).ccc')"/>

   <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />

   <CreateItem Include="$(ProjectDir)**\*.xyz">
      <Output TaskParameter="Include" ItemName="JavaFolderB"/>
   </CreateItem>
   <CreateItem Include="$(ProjectDir)obj\**\web.ccc">
      <Output TaskParameter="Include" ItemName="ExtraWebConfigsB"/>
   </CreateItem>
   <Move SourceFiles="@(JavaFolderB)" DestinationFiles="@(JavaFolderB->'$(ProjectDir)%(RecursiveDir)%(FileName).java')"/>
   <Move SourceFiles="@(ExtraWebConfigsB)" DestinationFiles="@(ExtraWebConfigsB->'$(ProjectDir)%(RecursiveDir)%(FileName).config')"/>
</Target>

希望这可以节省我花 3 个小时来弄清楚的时间...

更新:
因为这确实会增加构建时间,所以您可以选择添加到顶部的条件,以便仅在发布样式构建期间执行此检查:

<Target Name="MvcBuildViews" AfterTargets="Build" Condition="'$(MvcBuildViews)'=='true' AND '$(Configuration)' == 'Release'">

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:

<Target Name="MvcBuildViews" AfterTargets="Build" Condition="'$(MvcBuildViews)'=='true'">
   <!-- This task performs compilation of the CSHTML files in the web structure 
   and will generate compiler errors if there are issues in the views, such as missing
   resource strings, broken class locations, etc.
   Due to an issue with the AspNetCompiler task identifing .java files as candidates for
   compilation, we will temporarily rename all of the java files in the project to .xyz
   so they are skipped by aspnet compiler. Then we rename them back. 
   Extra web.configs also cause an error, so those are temporarily moved. -->
   <CreateItem Include="$(ProjectDir)**\*.java">
      <Output TaskParameter="Include" ItemName="JavaFolderA"/>
   </CreateItem>
   <CreateItem Include="$(ProjectDir)obj\**\web.config">
      <Output TaskParameter="Include" ItemName="ExtraWebConfigsA"/>
   </CreateItem>    
   <Move SourceFiles="@(JavaFolderA)" DestinationFiles="@(JavaFolderA->'$(ProjectDir)%(RecursiveDir)%(FileName).xyz')"/>
   <Move SourceFiles="@(ExtraWebConfigsA)" DestinationFiles="@(ExtraWebConfigsA->'$(ProjectDir)%(RecursiveDir)%(FileName).ccc')"/>

   <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />

   <CreateItem Include="$(ProjectDir)**\*.xyz">
      <Output TaskParameter="Include" ItemName="JavaFolderB"/>
   </CreateItem>
   <CreateItem Include="$(ProjectDir)obj\**\web.ccc">
      <Output TaskParameter="Include" ItemName="ExtraWebConfigsB"/>
   </CreateItem>
   <Move SourceFiles="@(JavaFolderB)" DestinationFiles="@(JavaFolderB->'$(ProjectDir)%(RecursiveDir)%(FileName).java')"/>
   <Move SourceFiles="@(ExtraWebConfigsB)" DestinationFiles="@(ExtraWebConfigsB->'$(ProjectDir)%(RecursiveDir)%(FileName).config')"/>
</Target>

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:

<Target Name="MvcBuildViews" AfterTargets="Build" Condition="'$(MvcBuildViews)'=='true' AND '$(Configuration)' == 'Release'">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文