error: "No compiler for language C#" - c#

An ASP.NET/C# project which I created in 2003 has been running on a university server for over 10 years now but I was just informed that the server crashed and they are trying to set everything up again.
They are getting the following error.
I see that at the bottom it seems that they have installed Mono on a Debian machine. Could it be that they installed Mono but forgot to install the C# compiler, or does this message imply something else is wrong?
What could be the cause and solution to this error?

According to the BuildManager code in Mono:
if (configSection == null)
config = WebConfigurationManager.GetWebApplicationSection ("system.web/compilation") as CompilationSection;
else
config = configSection;
...
if (throwOnMissing)
throw new HttpException (String.Concat ("No compiler for language '", language, "'."));
It's apparently not finding the compilation section for C# in the configuration. Have you checked the machine.config or web.config? e.g.
<system.web>
<compilation defaultLanguage="C#">
<compilers>
You should have a .NET compiler configuration here.
</compilers>
</compilation>
</system.web>
Check out this page for more information.

it could be also an decode error because he can identify '\C#\' try to use dos2unix rekursivly over your directory

Related

Mono: runtime error: v4.0.30319

I have a big problem with Mono; constantly receiving this error message.
WARNING: The runtime version Supported by This application is unavailable. Using default runtime: v4.0.30319
I have reinstalled the server three times already, but new installs unfortunately always have the same problem.
OS: Debian 7 mini
Mono: full instaled (mono-complet up to date)
PROCON: 1.4.0.6
Link: PROCON usage on Debian 7
If the application starts normally and you only want to suppress the warning, there are two options:
Configuration file
Add the configuration file to the directory where the binary is located, with the name <binary-name>.config, e.g. for application.exe use application.exe.config.
The contents of the file should be as following. Of course, the comment is optional.
<?xml version="1.0" encoding="utf-8"?>
<!-- Add this file to the legacy .NET application folder to prevent:
WARNING: The runtime version supported by this application is unavailable. -->
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
Sources
http://do-the-right-things.blogspot.cz/2017/05/the-way-to-suppress-monos-warning.html
https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/#application-configuration-files
Command line
Specify the runtime manually when launching the application.
mono --runtime=v4.0 application.exe
Sources
https://linux.die.net/man/1/mono
Mono on MacOSX - "The runtime version supported by this application is unavailable." v4.5
If you use a dissembler to check the assemblies you should see which CLR version they were built against. My guess is that they were built against 2.0.
Mono 4 removes the old 2.0 CLR and 4.0 CLR (in fact 4.5 profile) becomes the default and the only. So this is simply a warning, not an error.

Set a different language for ASP.NET MVC errors

I have an ASP.NET MVC application configured for Portuguese, on Visual Studio 2015. While debugging this application, I've set <customErrors mode="Off" />, but all errors are shown in Portuguese, and I want to see them in English.
I tried to set this in Web.config:
<globalization uiCulture="en-US" culture="en-US" enableClientBasedCulture="true" />
In Global.asax I tried:
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
and
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
I also uninstalled the Nuget package Microsoft.AspNet.Mvc.pt-br, no success.
This question is similar, but I need a solution that doesn't involve changing the machine's configuration or installed components, as that's not allowed in my workplace.
How can I make all error messages show in a specific language (in this case, English)?
Today when I tried this again, to my surprise the messages were in English (almost, see below). I tried to reproduce the error I had yesterday, but I couldn't.
Perhaps it is just a matter of restarting (VS or the PC). I also kept working on the project at night on a different PC, but not on anything related with this issue, so I can't say it made a difference. All I have set up in Web.config is:
<globalization uiCulture="en-US" culture="en-US" enableClientBasedCulture="true" />
But still not everything was in English. While trying to reproduce the error, I forced a library load error, I used a DLL that requires Ninject to be installed. The error message was (emphasis mine on the translated part):
Server Error in '/' Application.
Could not load file or assembly 'Ninject, Version=3.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7' or one of its dependencies. O sistema não pode encontrar o arquivo especificado.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
That part was supposed to be: The system cannot find the file specified.
In that case, I don't think there is much that can be done programmatically only.
Uninstall the .net framework in the portugese version and reinstall the english version, that should do the trick.

CloudConfigurationManager.GetSetting returning null

Following instructions here I have:
var connectionString = CloudConfigurationManager.GetSetting("StorageConnectionString");
But connectionString is null, here is my app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
<add name="StorageConnectionString"
connectionString="DefaultEndpointsProtocol=https;AccountName=storage;AccountKey=key" />
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Had the same problem. Instead of using a connection string, use the configuration->appSettings->add key like this...
<configuration>
<appSettings>
<add key="StorageConnectionString" value="[ConnectionStringHere]" />
</appSettings>
</configuration>
As per documentation in MSDN http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.cloudconfigurationmanager.aspx
Only configuration settings within the appSettings tag can be read by CloudConfigurationManager. If your configuration settings are within a different tag, calling GetSetting will return Null.
Well this works, even if the comment doesn't fit, because I do have a ref to CloudConfigManager:
If you are creating an application with no reference to Microsoft.WindowsAzure.CloudConfigurationManager, and your connection string is located in the web.config or app.config as show above, then you can use ConfigurationManager to retrieve the connection string. You will need to add a reference to System.Configuration.dll to your project and add another namespace declaration for it:
using System.Configuration;
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
I had the same problem. I had updated the project to use Azure SDK 2.0. I updated NuGet packages for my web and worker roles, but the Azure project in Visual Studio was still on the old version.
To fix this, Right-Click on your Azure project and select Properties. Under the Application tab, you'll see a button to Update your Azure SDK.
Make sure all your references are in synch. There's the 2012-06 library and 2012-10 Set them to Copy Local = true and verify SDK version. I dealt with the exact same thing, drove me nuts.
This happened to me when I upgraded the Azure SDK to version 2.2.
To fix it I changed the packages.config to use a newer version of the Azure ConfigurationManager.
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.1.0" targetFramework="net45" />
Based on my understanding, I'd like to point out that CloudConfigurationManager.GetSetting will look into web.config if you're running out of a cloud service. It will look into cscfg if you're inside a cloud service.
Please refer this
link.
Following this tutorial:
You can get configuration settings like this:
RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString")
I got this after upgrading Azure SDK from 2.0 to 2.2. I was able to fix by:
Right-Clicking Azure project and selecting Properties. Update Azure SDK as per the Application tab. (Thanks to rattrick's answer).
Right click to Manage NuGet Packages. On the left click Updates and update WindowsAzure.ConfigurationManager.
I had the same problem (two times).
Even after restarting Visual Studio and after restarting the Azure emulator the CloudConfigurationManager.GetSetting("SettingName") returns null.
I was sure that it has worked before and I had the latest SDK.
So the solutions was restarting my PC and after that CloudConfigurationManager.GetSetting("SettingName") returns the right value.
I got the same issue this am after revisiting my Azure solution (Web + Worker role) to update it for Azure 2.5. Reviewing the help for CloudConfigurationManager.GetSetting, if its running under a cloud platform (Azure) it reads from the ServiceConfiguration.csfg, if running as a .net web app, reads from app or web.config.
So my fix was to simply change the start up project back to the Azure cloud project, not the Web project.
I was getting null because it was hosted in the wrong platform and reading from the .config files with no settings.
(Doh!)
It is an old thread but I wanted to share my solution if issue is not resolved by above mentioned methods then make sure that Azure Storage Emulator is running when you run the application; at least for me this happened. For me I had to create a class to handle emulator issue as mentioned here...
http://blog.simontimms.com/2013/08/28/configuration-settings-in-an-azure-worker-role/
class ConfigurationProvider
{
private static string GetStorageConnectionString(string name)
{
try
{
return RoleEnvironment.GetConfigurationSettingValue(name);
}
catch (SEHException)
{
return System.Configuration.ConfigurationManager.ConnectionStrings[name].ConnectionString;
}
}
public static string StorageConnectionString()
{
return GetStorageConnectionString("StorageConnectionString");
}
public static string DefaultConnection()
{
return GetStorageConnectionString("DefaultConnection");
}
}
I had quite similar problems. I updated from Azure SDK 2.0 to 2.2 - during this process I used the NuGet Manager to update the Microsoft.WindowsAzure.Storage to the latest. The PackageManager automatically took Microsoft.WindowsAzure.Configuration to 1.8.0.0. I was not able to get this running (it was for .Net 2.0!?). After I manually set all References to
Microsoft.WindowsAzure.Storage 2.1.0.0
Microsoft.WindowsAzure.Configuration 2.0.0.0
everything worked.
I think this is because of the way CloudConfigurationManager.GetSetting loads the assembly and calls the funktions (via reflection).
Same here after upgrading Azure SDK from 2.2 to 2.3.:
Right-Click the Azure project select Properties. In the Application tab click "Upgrade..." (Thanks to rattrick's answer).
Then there was one more error to resolve:
Trying to run the Azure Project in the Compute Emulator threw an exception:
System.Configuration.ConfigurationErrorsException was unhandled
Message: An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in Microsoft.WindowsAzure.ServiceRuntime.dll
Additional information: konnte nicht erstellt werden.
In the "Error List" Window of VS2013 there was the following Warning:
Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets 1635
I let VS resolve this warning and everything worked fine.
This worked for me...
using System.Configuration;
...
var connectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;
I had the same problem. None of the advices worked for me, but the "issue" was straightforward. One simple has to understand how this class works.
It does not go into your app.config / web.config or wherever you store your application settings. CloudConfigurationManager works with ServiceConfiguration.*.cscfg and ServiceConfiguration.csdef. The .csdef must contain a definition of the setting, but not its value under the ConfigurationSettings section. The settings themselves sit in .cscfg files (under the same section but including the value; I suppose the reason for the double definition is to make sure both the cloud and the local configurations have the same settings).
You can set these either by right-clicking your role in Visual Studio and selecting Properties -> Settings (in case of StorageConnectionString, simply pick "Your subscription", if your storage account is connected to the cloud service), or by editing them manually. If you mess up the settings, you'll get an exclamation mark icon.
Simple as that.
Was getting a null value with when passing a literal string as well after installing Azure SDK 2.6 (was working before).
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureStorage"].ConnectionString);
Replaced the literal string and it worked fine.
string connectionStr = "AzureStorage";
var connectionstring = ConfigurationManager.ConnectionStrings[connectionStr].ConnectionString;
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionstring);

Error using 'var' after upgrading to Visual Studio 2010

We just recently upgraded from VS2008 to VS2010.
Our project compiles fine; but when we go to run the Web Application, we get the following error when opening Default.aspx:
Server Error in '/' Application.
Compilation Error Description: An
error occurred during the compilation
of a resource required to service this
request. Please review the following
specific error details and modify your
source code appropriately.
Compiler Error Message: CS0246: The
type or namespace name 'var' could not
be found (are you missing a using
directive or an assembly reference?)
Opening up the page, and mousing over the 'var' declaration, VS2010 correctly recognizes that it's type is a RegEx.
I'm thinking something funky might have happened in either our web.config or machine.config during the upgrade.
Anybody else run into this problem before? Any help would be greatly appreciated, hopefully it can save me some time diving into these files.
EDIT:
Here's the relevent section of code that's blowing up:
Line 10: protected void valSearchFreeText_ServerValidate(object source, ServerValidateEventArgs args)
Line 11: {
Line 12: var url = new Regex(#"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?", RegexOptions.IgnoreCase);
Line 13: var html = new Regex(#"[<,>]", RegexOptions.IgnoreCase);
Line 14: args.IsValid = !html.IsMatch(args.Value) && !url.IsMatch(args.Value);
I don't believe that .NET 4.0 is the cause; we only upgraded from VS2008 to VS2010; we did not migrate from .NET 3.5 to .NET 4.0
I will double check on the ASP.NET Development Server vs. IIS and post back in a few minutes with the results from that. It's definitely being thrown from the Development Server.
Edit 2
This is being thrown from both the Development Server, and IIS.
System.Xml.Linq is also included in the assemblies section of our web.config:
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Check your web.config file for the configuration/system.codedom/compilers/compiler node. There should be a providerOption child node that determines the compiler version to be used. It ought to look like <providerOption name="CompilerVersion" value="v3.5"/>. It sounds like yours says 2.0 instead of 3.5.
Is the associated application pool in IIS set to use the .Net 4 framework?
Ensure that the target framework is set to 3.5 or higher
Also, double check that you have a good web.config file in the Application root folder (copy the recommended web.config and rename it.)

Not able to load MicrosoftAjax.debug.js

I have an ASP.NET 3.5 web application which works perfectly fine on my local machine and when I deploy it on my Windows 2008 server. I am getting the following javascript error:
Message: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
Line: 4723
Char: 21
Code: 0
URI: http://localhost/ScriptResource.axd?d=e1Gld4LGHLsC4rWqevEI8zAMJKoVcCEVHBjdJIxcQLO9of6t7nNopbI1YyxJTv1QbaxN_lTSoz5Ly-VjBRHp08Mf3xxg5V9i5Z0AiXIkZRY1&t=6af1de90
I have a utility which can decrypt the URI and tell exactly what file is missing and it tunrns out that the file is ZSystem.Web.Extensions,3.5.0.0,,31bf3856ad364e35|MicrosoftAjax.debug.js|. Why am I not able to load this js file? Any help?
Possible options:
You've not installed .NET Framework SP1 on your server, so it can't find the 3.5 assemblies to generate the MsAjax file.
You've deployed your web.config file with <compilation debug="true"> while IIS has been configured to compile it in release mode.
I have run into a similar problem before when the development and production machines are set for two different time zones. When ASP.NET AJAX tries to load a script resource from an assembly, the last modified date/time of the assembly is validated. If the local time of the production server is "earlier" than the last modified date/time of the assembly, then an ArgumentOutOfRange exception is generated by ASP.NET AJAX when processing the request.
Really difficult to debug since the problem eventually resolves itself.
I suppose this might be possible with a System assembly if Copy-Local is set to true.
I was using some third party web services and the problem was with the following xml tag in the web.config:
<extendedProtectionPolicy policyEnforcement="Never" />
Once I removed this tag the error went away

Categories

Resources