我有一个问题与在IIS 10中注册asp.net有关.
我的环境是安装了Windows 10,IIS 10,VS 2013和VS 2015,.NET 3.5是Windows功能中的一项功能.
我想在iis中使用nettcpbinding,因此,我安装了WCF HTTP激活和WCF非HTTP激活.之后,我需要在IIS中重新注册asp.net.我跑到命令之下
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -i
Run Code Online (Sandbox Code Playgroud)
我得到了以下结果,是否在IIS中正确注册了asp.net?
任何帮助,将不胜感激.
Microsoft(R)ASP.NET RegIIS版本4.0.30319.0管理实用程序,用于在本地计算机上安装和卸载ASP.NET.版权所有(C)Microsoft Corporation.版权所有.开始安装ASP.NET(4.0.30319.0).此版本的操作系统不支持此选项.管理员应该使用"打开/关闭Windows功能"对话框,服务器管理器管理工具或dism.exe命令行工具,使用IIS8安装/卸载ASP.NET 4.5.有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=216771.完成安装ASP.NET(4.0.30319.0).
我在Asp.net Core中使用了EF,但是在下面的代码中出现了以下错误:
public class TodoContext : DbContext
{
public TodoContext(DbContextOptions<TodoContext> options)
: base(options)
{
}
public DbSet<TodoItem> TodoItems { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
错误信息:
Microsoft.EntityFrameworkCore.dll中出现"System.TypeLoadException"类型的异常,但未在用户代码中处理
附加信息:无法从程序集"Microsoft.Extensions.DependencyInjection.Abstractions,Version = 1.1.0.0,Culture = neutral,PublicKeyToken = adb9793829ddae60"加载类型"Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionExtensions".
这是我的Project.json
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.Extensions.Logging.Console": "1.0.0",
//Dependence for MVC
"Microsoft.AspNetCore.Mvc": "1.1.1",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
//Dependence for EF
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.InMemory": "1.0.0-rc2-final"
//Dependence for EF with SQL, this is avalible under VS 2017 …Run Code Online (Sandbox Code Playgroud) 我有一个Asp.net Core方法具有以下定义。
[HttpPost]
public IActionResult Upload(IFormFile file)
{
if (file == null || file.Length == 0)
throw new Exception("file should not be null");
var originalFileName = ContentDispositionHeaderValue
.Parse(file.ContentDisposition)
.FileName
.Trim('"');
file.SaveAs("your_file_full_address");
}
Run Code Online (Sandbox Code Playgroud)
我想为此功能创建XUnit Test,该如何模拟IFormFile?
更新:
控制器:
[HttpPost]
public async Task<ActionResult> Post(IFormFile file)
{
var path = Path.Combine(@"E:\path", file.FileName);
using (var stream = new FileStream(path, FileMode.Create))
{
await file.CopyToAsync(stream);
}
return Ok();
}
Run Code Online (Sandbox Code Playgroud)
Xunit测试
[Fact]
public async void Test1()
{
var file = new Mock<IFormFile>();
var sourceImg = File.OpenRead(@"source …Run Code Online (Sandbox Code Playgroud) 我在运行xunit测试项目时遇到了异常,这些项目在VS 2017 15.3下运行
[2017/12/4 23:08:40错误] [xUnit.net 00:00:00.0033291] xxx.Test:灾难性故障:System.TypeInitializationException:'Xunit.DiaSession'的类型初始值设定项引发异常.---> System.IO.FileNotFoundException:无法加载文件或程序集'System.Reflection.TypeExtensions,Version = 4.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一.该系统找不到指定的文件.在Xunit.DiaSession..cctor()---内部异常堆栈跟踪结束---在Xunit.DiaSession.ctor(String assemblyFileName)的Xunit.DiaSession..ctor(String assemblyFileName)Xunit.XunitFrontController..ctor (AppDomainSupport appDomainSupport,字符串assemblyFileName,字符串configFileName,布尔影拷贝,字符串shadowCopyFolder,ISourceInformationProvider sourceInformationProvider,IMessageSink diagnosticMessageSink)在Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner.RunTestsInAssembly(IRunContext runContext,IFrameworkHandle frameworkHandle,LoggerHelper记录器,IMessageSinkWithTypes reporterMessageHandler,AssemblyRunInfo runInfo)我目前的VS 2017版本是15.4.5.
我已经尝试过以前提供的工作,但没有一个不起作用.我试图将我的VS 2016降级到15.3,但我找不到要安装的15.3软件包.我试图将xunit安装到最新版本.任何帮助,将不胜感激.
更新:
项目类型:xUnit测试项目(.NET Core)
目标:net 461
我使用以下代码进行了测试以更新Product:
var existing = await _productRepository.FirstOrDefaultAsync(c => c.Id == input.Id);
if (existing == null)
throw new UserFriendlyException(L("ProductNotExist"));
var updatedEntity = ObjectMapper.Map<Product>(input);
var entity = await _productRepository.UpdateAsync(updatedEntity);
Run Code Online (Sandbox Code Playgroud)
但这会引发异常:
Mvc.ExceptionHandling.AbpExceptionFilter-无法跟踪实体类型'Product'的实例,因为已经跟踪了另一个具有相同键值的{'Id'}实例。附加现有实体时,请确保仅附加一个具有给定键值的实体实例。
这是由查询引起的existing。有什么解决办法吗?
c# entity-framework change-tracking asp.net-boilerplate aspnetboilerplate
我对 Office 脚本和脚本实验室感到困惑。
两者都可以javascript在Excel中运行,但似乎代码不能在它们中共享。
对于 Office 脚本,一些代码如
function main(workbook: ExcelScript.Workbook) {
// Set fill color to FFC000 for range Sheet1!A2:C2
let selectedSheet = workbook.getActiveWorksheet();
selectedSheet.getRange("A2:C2").getFormat().getFill().setColor("FFC000");
}
Run Code Online (Sandbox Code Playgroud)
对于脚本实验室,代码是
await Excel.run(async (context) => {
let sheet = context.workbook.worksheets.getActiveWorksheet();
sheet.tables.add("B2:E5", true);
await context.sync();
});
Run Code Online (Sandbox Code Playgroud)
的workbook不同之处在于ExcelScript.Workbook和context.workbook
我遵循ASP.NET核心 - 新数据库在VS 2015下使用Asp.net Core中的EF.但是在安装软件包后得到以下错误.
启动项目'src\CoreMVCWebAPI'是Visual Studio 2015的ASP.NET Core或.NET Core项目.此版本的Entity Framework核心包管理器控制台工具不支持这些类型的项目.
在文档中,它说,它需要VS 2017 RC,我想知道它是否在VS 2015下可用,或者是否有任何解决方法我可以在Asp.net Core或Ado.net中使用EF从SQL DataBase中检索数据.
PM> Add-Migration MyFirstMigration
Invalid object passed in, ':' or '}' expected. (339): {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.Extensions.Logging.Console": "1.0.0",
//Dependence for MVC
"Microsoft.AspNetCore.Mvc": "1.1.1",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
//Dependence for EF
"Microsoft.EntityFrameworkCore":"1.1.0",
"Microsoft.EntityFrameworkCore.InMemory": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools":"1.1.0-preview4-final"
//Dependence for EF with SQL, this is avalible under VS 2017 …Run Code Online (Sandbox Code Playgroud) 我已经在TypeScript中定义了一个接口,如下所示:
export interface User {
id?: number;
name?: string;
logoUrl?: File;
emailUserName?: string;
emailPassword?: string;
}
Run Code Online (Sandbox Code Playgroud)
使用User,我将其绑定到Angular html输入。如果我在输入中输入任何内容,则用户对象将包含值,但是,如果我不输入,则名称等属性将是未定义的。如果不输入名称字符串,如何获得名称的空值。更新资料
<div *ngIf="hero">
<h2>{{hero.name}} details!</h2>
<div>
<label>id: </label>{{hero.id}}</div>
<div>
<label>name: </label>
<input [(ngModel)]="hero.name" placeholder="name" />
<input [(ngModel)]="hero.location" placeholder="location" />
</div>
<button (click)="goBack()">Back</button>
</div>
//model
export class Hero {
private _location:string="test";
constructor(){
console.log(this._location);
this.location=this._location;
}
public id: number;
public name: string;
public location:string;
}
goBack(): void {
console.log(this.hero);
// this.hero=new Hero();
// console.log(this.hero);
//this.location.back();
}
}
Run Code Online (Sandbox Code Playgroud)
如果我未在输入中输入任何值,则goBack将输出不带location属性的hero。
我正在尝试cv2.inpaint,如果你自己加水印,然后使用cv2.inpaint,结果就完美了。
但是,如果我使用如下所示的互联网图像:
源图像
结果很糟糕。
这是代码
zhihuimage = cv2.imread('../input/zhihumask/OpenCV_11.jpg')
zhihuwatermask = cv2.imread('../input/zhihumask/OpenCV_22.jpg')
# remove watermark with mark
zhihuwatermask = cv2.cvtColor(zhihuwatermask, cv2.COLOR_BGR2GRAY)
zhihuoutput = cv2.inpaint(zhihuimage, zhihuwatermask,3, flags= cv2.INPAINT_NS)
Run Code Online (Sandbox Code Playgroud) 我正在为DbContext实现一个XUnit测试,似乎DbContext没有正确处理.当我调试第一个测试时,它可以工作,但在第二个测试中,listAds抛出了已经添加的错误.
添加监视后,在第二个测试中,_context为null,但它具有Advertisementsbefore之前的值_context.Advertisements.AddRange(listAds);.
public class AdsServiceTest: IDisposable
{
private readonly DbContextOptions<SensingSiteDbContext> _options;
private readonly SensingSiteDbContext _context;
private readonly AdsService _AdsService;
public AdsServiceTest()
{
//initialize db options
_options = new DbContextOptionsBuilder<SensingSiteDbContext>()
.UseInMemoryDatabase()
.Options;
//get service
_context = new SensingSiteDbContext(_options);
//initialize dbcontext
List<Ads> listAds = new List<Ads>() {
new Ads(){ Id=1,AdsName="Ads1", Deleted=false},
new Ads(){ Id=2,AdsName="Ads2", Deleted=false},
new Ads(){ Id=3,AdsName="Ads3", Deleted=false}
};
//In the second test method, it throw errors, listAds already exist in
_context.Advertisements.AddRange(listAds);
_context.SaveChanges(); …Run Code Online (Sandbox Code Playgroud) 我尝试为Asp.net Core DBContext实施XUnit测试,但出现以下错误。
消息:System.InvalidOperationException:无法跟踪实体类型“ Ads”的实例,因为已经跟踪了具有相同键的该类型的另一个实例。添加新实体时,对于大多数键类型,如果未设置任何键(即,如果为键属性分配了其类型的默认值),则将创建唯一的临时键值。如果您为新实体明确设置键值,请确保它们不与现有实体或为其他新实体生成的临时值冲突。附加现有实体时,请确保仅将一个具有给定键值的实体实例附加到上下文。
这是我当前的代码:
public class AdsServiceTest
{
private readonly DbContextOptions<SensingSiteDbContext> _options;
private readonly SensingSiteDbContext _context;
private readonly AdsService _AdsService;
public AdsServiceTest()
{
//initialize db options
_options = new DbContextOptionsBuilder<SensingSiteDbContext>()
.UseInMemoryDatabase()
.Options;
//get service
_context = new SensingSiteDbContext(_options);
//initialize dbcontext
List<Ads> listAds = new List<Ads>() {
new Ads(){ Id=1,AdsName="Ads1", Deleted=false},
new Ads(){ Id=2,AdsName="Ads1", Deleted=false},
new Ads(){ Id=3,AdsName="Ads1", Deleted=false}
};
_context.Advertisements.AddRange(listAds);
//context.Advertisements
BaseLib.SSDbContext<Ads, AdsService> ssDbContent = new BaseLib.SSDbContext<Ads, AdsService>(_context);
_AdsService = ssDbContent.GetService((x, y) => new AdsService(x, y));
}
[Theory] …Run Code Online (Sandbox Code Playgroud) xunit ×4
asp.net-core ×3
c# ×3
typescript ×2
angular ×1
asp.net ×1
excel ×1
iis ×1
javascript ×1
moq ×1
opencv ×1
python ×1
scriptlab ×1
unit-testing ×1