问题:

我试图以.NET 4.6为目标,并通过将C#语言版本更改为6来利用最新的C#版本。

但是在编译期间我遇到了这个错误:

错误无效选项’6’表示/ langversion; 必须是ISO-1,ISO-2,3,4,5或默认值

如果我将Web.Config设置中的/langversion:6更新为5,它可以工作,

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701">

但是如何在不使用低语言版本的情况下解决这个问题呢?

我正在使用Visual Studio 2015社区版,我还手动安装了.NET Framework 4.6,以防Visual Studio 2015默认安装它。

该项目是Visual Studio 2015创建的标准ASP.NET MVC模板项目。

I am trying to target .NET 4.6 and also take advantage of the latest C# version by changing the C# language version to 6.However during compilation I got this error:Error Invalid option ‘6’ for /langversion;must be ISO-1, ISO-2, 3, 4, 5 or DefaultIf I update the /langversion:6 in Web.Config setting to 5 it works,But how do I resolve this without resorting to lower language version?I am using Visual Studio 2015 Community Edition, and I have also installed .NET Framework 4.6 manually just in case it was not installed by default by Visual Studio 2015.The project is a standard ASP.NET MVC template project created by Visual Studio 2015.

问题:

我正在使用Web API创建一个Web服务。 我实现了一个简单的类

public class ActivityResult
{
    public String code;
    public int indexValue;
    public int primaryCodeReference;
}

然后我在我的控制器内实现了

[HttpPost]
public HttpResponseMessage Post(ActivityResult ar)
{
    return new HttpResponseMessage(HttpStatusCode.OK);
}

但是当我调用API传递POST文件时json:

{"code":"XXX-542","indexValue":"3","primaryCodeReference":"7"}

我收到以下错误消息:

{
    "Message": "The request entity's media type 'text/plain' is not supported for this resource.",
    "ExceptionMessage": "No MediaTypeFormatter is available to read an object of type 'ActivityResult' from content with media type 'text/plain'.",
    "ExceptionType": "System.Net.Http.UnsupportedMediaTypeException",
    "StackTrace": "   in System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n   in System.Net.Http.HttpContentExtensions.ReadAsAsync(HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n   in System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)"
}

我究竟做错了什么?

I’m creating a web service using Web API.I implemented a simple classAnd then I have implemented inside my controllerBut when I call the API passing in POST the file json:I obtain the following error message:What am I doing wrong?

问题:

我已经构建了一个.net4.5 ASP.NET MVC4 Web应用程序,该应用程序在本地可以正常运行(IIS Express和开发服务器),但是一旦将其部署到我的Web服务器上,它就会引发403错误。 我已经在服务器上安装了.Net 4.5RC,甚至尝试了aspnet_regiis -i ,每个人都建议使用MVC / .Net的早期版本解决问题,但没有帮助。

有任何想法吗?

编辑 :有关情况的更多信息。 该服务器是32位的,我还有其他4个运行良好的MVC3应用程序。 只是我的MVC4应用无法正常工作。

I have build a .net4.5 ASP.NET MVC4 web app which works fine locally (IIS Express & dev server) but once i deploy it to my web server it throws the 403 error.I have installed .Net 4.5RC on the server and even tried the aspnet_regiis -i bit that everyone recommended for their issues with previous versions of MVC/.Net but it did not help.Any ideas?EDIT : More info about the situation.The server is 32bit and I have 4 other MVC3 applications that work fine.It is just my MVC4 app that is not working.

问题:

在自动构建中使用devenv时,我一直收到此错误。 我已经浏览了我能找到的每个网站,并且通常的答案提到了刷新的依赖关系(我认为它修复了它用于手动部署,但不用于自动)并从项目中删除源代码控制编码,这对我没有帮助。

每次构建时都不会发生错误,但每次在不同的部署项目上似乎都是随机的。

有没有人对为什么会出现这个错误以及如何修复它有任何建议?

I have been receiving this error for a while when using devenv on an automatic build.I have gone through every website I can find, and the usual answers mention refreshing dependencies (Which I believe fixes it for manual deployment, but not for automatic) and removing the source control coding from the projects, which hasn’t helped me.The error does not occur every time I build, but it seems random on different deployment projects each time.Does anyone have any advice on why exactly this error occurs and how to go about fixing it?

问题:

我正在使用带有Model First方法的Entity Framework 4。

我开始了该项目,设计了实体并生成了数据库。 一切正常。

然后,我需要回去向模型添加另一个实体。 但是,当我将实体拖到EDMX时,出现以下错误:

在此处输入图片说明

好的! 我只需要将Entity1映射到表即可。但是,嘿! 我使用的是“模型优先”方法,我希望它在生成DDL时为我创建表。

如何解决此错误?

I’m using Entity Framework 4 with the Model First approach.I started the project, designed the entities and generated the database.Everything worked fine.Then I needed to go back and add another entity to my model.However, as I drag an entity to the EDMX I get this error:Alright!I just need to map Entity1 to a table.. But hey!I’m using Model First approach, I expect it to create the table for me when I generate the DDL.How do I work around this error?