我有一个使用DataAnnotations的模型.就像是
public class Appointment {
[Required(ErrorMessage="Please enter your name")]
public string Name { get; set; }
[Required(ErrorMessage="Please enter your appointment date?")]
[DataType(DataType.Date, ErrorMessage="Appointment date is not a date")]
public DateTime AppointmentDate { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
"Required"属性遵循ErrorMessage中的值; 也就是说,如果我没有输入值,我会收到"请输入"消息.但是,如果我在DateTime字段中输入一个字符串,我收到标准系统错误消息"值'blah'对AppointmentDate无效".
我通过ASP.NET MVC代码调试,似乎在FormatException的情况下,它没有从propertyMetadata中选择正确的显示名称.不管怎样,或者我遗漏了一些明显的东西:/
有人遇到过这个问题吗?是我,还是只是beta(我使用的是ASP.NET MVC 2 Beta)?
我有一个新的ASP.NET Core 1 RC2应用程序.(Visual Studio,IIS Express).它在同一个数据库中具有身份验证和数据(至少目前为止):
services.AddDbContext<MyDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddDbContext<ApplicationIdentityContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
Run Code Online (Sandbox Code Playgroud)
我可以看到Identity部分工作(如果我"注册",则在AspNetUsers表中创建一条记录).但是,任何通过MyDbContext获取数据的尝试都会引发错误
An exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll and wasn't handled before a managed/native boundary
Additional information: Could not load file or assembly 'System.Security.Cryptography.Algorithms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Run Code Online (Sandbox Code Playgroud)
对于System.Security.Cryptography.AlgorithmsNuget,我可以选择4.1.0-rc2和4.0.0-beta.两者都抛出相同的错误
从其他一些地方我发现了安装建议System.Net.Security,Microsoft.NETCore.Platforms但它也无济于事
这个问题的灵感来自这个很好的例子。我有 ASP.NET Core MVC 应用程序,我正在为控制器编写单元测试。其中一个方法返回JsonResult匿名类型的集合。我可以访问集合的每个元素。我还可以像这样在每个元素中断言值:
Dictionary<int, string> expectedValues = new Dictionary<int, string> {
{ 1, "Welcome Tester"},
{ 2, "Namaste Tester"},
{ 3, "Privet Tester"},
{ 4, "Labdien Tester"}
};
foreach (dynamic value in jsonCollection) {
dynamic json = new DynamicObjectResultValue(value);
Assert.Equal(expectedValues[json.Id], json.Greeting);
}
Run Code Online (Sandbox Code Playgroud)
但是有没有办法对整个集合做出断言?例如,Assert.Equal(4, jsonCollection.Count())或Assert.Contains(2, jsonCollection[Id])(这显然是伪代码)。
我正在使用新的Async CTP位,我无法使用服务器端或命令行程序(并且所有示例都是WPF或Silverlight).例如,一些简单的代码,如:
class Program {
static void Main() {
Program p = new Program();
var s = p.Ten2SevenAsync();
Console.WriteLine(s);
}
private async Task<int> Ten2SevenAsync() {
await TaskEx.Delay(10000);
return 7;
}
}
Run Code Online (Sandbox Code Playgroud)
立即返回并打印System.Threading.Tasks.Task1 [System.Int32]`而不是等待10秒并返回7(正如我所料).必须是我遗失的明显事物.
我到处都读到VS2015显示目录中的所有文件.但是,bower.json除非我点击"显示所有文件"图标,否则我看不到.由于之前没有选项"包含在/从项目中排除",我不明白这是如何控制的.其他服务文件(package.json,project.json等)确实会显示,但不会显示bower.json.
我如何包含bower.json在解决方案资源管理器中?
我正在使用 vuetify 进行一个项目。我正在使用“npm run serve”命令来构建和运行一个实时服务器。它运行良好,直到我的项目突然停止构建。每次我尝试运行命令“npm run serve”时,它都会构建并挂起 98%,而不会引发错误。
我试过 npm 安装。npm build 这些都不能解决问题
在我的终端中,我运行此命令,结果如下:
npm run serve
rep-vuetify@0.1.0 serve /Users/Desktop/rg21-vuetify/rep-vuetify vue-cli-service serve
INFO Starting development server...
98% after emitting CopyPlugin
Run Code Online (Sandbox Code Playgroud)
IT 挂起 98% 并且在此之后不做任何事情,如果有人可以帮助我,请在这一步上停留整整一周。
我到处读到你应该使用的OData v3,你应该使用substringof()v4 contains().我从NuGet安装了版本为5.5.1的 Microsoft.AspNet.WebApi.OData .
奇怪的是,contains()不起作用.我收到以下错误:
{"message":"URI中指定的查询无效.找到名为'contains'的未知函数.这也可能是导航属性上的键查找,这是不允许的." ...}
相反,substringof()工作正常.它应该是那样的吗?
我们有一个中等大小的 Angular 应用程序。FWIW,Angular4 构建生成了大小为 4MB 的 app.js。我们不使用 Angular-CLI。当我们刚开始时,它不可用;然后看起来我们不需要它。构建时间 ( npm start) 花费了大约 2 分钟。
现在我们升级到 Angular 5。同样的构建需要一个多小时,并且在某些机器上报告Out of memory。我在任务管理器中注意到分配的npm内存在崩溃之前确实增加了大约 2GB。不确定命令行会话是否有 2GB 限制,或者它的物理内存不足(您只能进行这么多小时的实验:)
无论如何,有没有办法查看导致 npm 缓慢的原因?
平台:Windows 10,npm 5.5.1
更新:配置文件:
包.json
{
"name": "myapp",
"version": "0.0.1",
"description": "my awesome application",
"scripts": {
"start": "webpack-dev-server --inline --debug --progress --port 10071",
"test": "karma start",
"build": "rimraf dist && webpack -p --config ./config/webpack.prod.js --progress --profile --bail"
},
"dependencies": {
"@angular/animations": "^5.0.1",
"@angular/cdk": "^5.0.0-rc0",
"@angular/common": "^5.0.1", …Run Code Online (Sandbox Code Playgroud) 我将 Visual Studio Community 升级到最终版本,但它停止工作。具体来说,我可以生成一个新项目,但是当我尝试加载它时,它给了我一个错误
关键项目“SdkTest”加载失败| [MSB4236] 找不到指定的 SDK“Microsoft.NET.Sdk.Web”。...\SdkTest.csproj
尽管构建和运行工作正常
我在 VS2022 上运行了“修复”,它现在似乎可以在 Visual Studio . 但是,dotnet --info不显示任何SDK;仅运行时;和/dotnet build或dotnet new给出错误:
C:\Code>dotnet new console -o myapp
Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
* You intended to execute a .NET program:
The application 'new' does not exist.
* You intended to execute a .NET SDK …Run Code Online (Sandbox Code Playgroud) 我有两个.NET不相关的项目。一个是模型(v。2.2),另一个是Web应用程序(v。3.0.0-preview7)。我没有Preview5的问题,但是现在我无法对2.2项目运行迁移。
C:\>dotnet ef --help
System.MissingMethodException: Method not found: 'System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.IO.Stream, System.Text.Json.JsonReaderOptions)'.
at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute()
at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0()
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Method not found: 'System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.IO.Stream, System.Text.Json.JsonReaderOptions)'.
Run Code Online (Sandbox Code Playgroud)
就像我说的,使用Preview5我没有任何问题。它在5到7之间变化了吗,我需要进行一些相应的更改?我没有在发行说明中看到任何内容。还是仅仅是一个错误,我只需要等到下一个预览?
我在dotnet build或上没有任何错误dotnet run。仅在dotnet ef命令上
c# ×3
.net-core ×2
npm ×2
angular ×1
angular5 ×1
asp.net ×1
asp.net-core ×1
asp.net-mvc ×1
async-await ×1
async-ctp ×1
asynchronous ×1
json ×1
msbuild ×1
odata ×1
typescript ×1
unit-testing ×1
vuetify.js ×1
xunit.net ×1