Aspnet_compiler looking for jsharp code provider in c # mvc2 application

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

aspnet_compiler.exe -v / -p \ 

This 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 do not have J # in my solution. I downloaded the J # 2.0 Second Edition redistributable package, but that didn't help.

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

What am I missing that causes this error?

I read a lot of other posts saying that you need to install the redistributable, add the link to web.config, etc., but they did not help.

Any ideas?

+4
source share
5 answers

It happened today, and I found a solution of its kind.

I am 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 occurred in my .cshtml views. For any view I opened, the first line of @using was underlined with an 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. A security error has occurred. (Exception from HRESULT: 0x8013150A)

There were also strange errors on the page, such as ambiguous links between two assemblies of the same name (for example, allegedly a conflict between "System.Web.Helpers" and "System.Web.Helpers").

Reason: I ran the website under a user account that did not have sufficient permissions. The account had the IIS_IUSRS role, but apparently there is some other role or access to it, this work or it may require access to a specific folder that it could not reach.

Unfortunately, I do not know what it is, and I do not care about the idea of โ€‹โ€‹spending hours to understand this after I have already spent too much time trying to understand how this happened in the first place.

But providing this user with the Administrators role resolves the error .

I understand that this is not an ideal solution, but I hope that at least some people come unstuck. If someone determines exactly what permissions are needed to prevent this error, please comment below and perhaps we can narrow it down.

+3
source

@Adrian. I had this problem today, and I fixed it almost immediately, she tried to compile J # in a C # project, a strange error. But the problem was that I copied the .java file to the project folder and there was a problem. As soon as I deleted it, it all compiled again perfectly.

+1
source

@Kyralessa: I had the same error. Adding the Administrators role to the user under whom the website ran the โ€œfixedโ€ problem, but, as you said, this is not an ideal solution.

So, I was busy with IIS settings and in the "Basic Settings" section of the website I switched to "Application user (pass-through authentication)" and the problem disappeared. The application pool is still running under the same (non-administrative) user, so there are no security issues.

+1
source

Try installing one of the following packages:

32-bit: http://www.microsoft.com/download/en/details.aspx?id=18084

64-bit: http://www.microsoft.com/download/en/confirmation.aspx?id=15468

It made me go past an error when none of the other solutions would work.

0
source

I had the same error when I set the MvcBuildViews property in csproj to true. After much research and testing / errors, I found out that the problem is that our site had .java files in the structure of the site. These java files were not part of the solution, they just lost the files. The Aspnetcompiler task is executed from the root of the project, so it finds all kinds of problems, such as duplicate web.configs and * .java files.

To handle this, I created the following target in the MVC project file that 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: Since this adds more assembly time, you can add to the condition from above to perform this check only during creation of release styles:

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

Source: https://habr.com/ru/post/1339671/


All Articles