我正在尝试创建一个 asp.net 核心项目(.net 核心 2.2)并且我选择个人用户帐户作为身份验证。问题是我需要添加域名、应用程序 ID 和注册或登录策略。我不想为此使用 Azure。我怎么能跳过它?
我刚开始从Unity迁移到Autofac,我在尝试注册实例时遇到了问题.
public static void Register(ContainerBuilder containerBuilder,
CancellationToken shutDownCancellationToken)
{
containerBuilder.RegisterType<CancellationToken>();
containerBuilder.RegisterInstance(shutDownCancellationToken);
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
类型'
CancellationToken'必须是引用类型才能T在泛型类型或方法中使用它作为参数'RegistrationExtensions.RegisterInstance<T>(ContainerBuilder, T)'
任何人都知道如何注册已经创建的结构实例?
我最近升级到VS2017并使用TeamCity进行构建.我有一个需要使用TeamCity构建的新项目.我尝试从以下链接https://www.visualstudio.com/downloads/在CI服务器上安装MS Build,它说已经成功安装了它.尝试构建项目时重新启动CI服务器,但仍无法找到新的Build工具.
我检查了C:\ Program Files(x86)\ MSBuild\15.0 \但我没看到MSBuild.exe
我在网上搜索了一个使用 rowTrackBy 的 Primeng 数据表示例。文档不完整,没有说太多。有没有人可以帮忙?
我使用 VS2017 创建了一个空的 asp.net 核心应用程序。我唯一改变的是"sslPort":launchSettings.json 文件中的 属性。当我点击运行 IIS Express chrome 时,打开 urlhttps://localhost:9995/并给出This site can't be reached The connection was reset.错误
我的launchSettings.json如下
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:39566",
"sslPort": 9995
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"JccWeb2": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我在带有粘性标题的角度材料表上分叉了示例,并添加了更多数据。我看到标题不粘。在这里堆叠闪电战
任何人都知道标题如何保持粘性?
angular-material angular-material2 angular angular-material-table material-table
我想在整数排序列表中找到小于给定数字到指定数字的最高值。
我有以下代码
List<int> list = new List<int> { 2, 5, 7, 10 };
int number = 9;
Run Code Online (Sandbox Code Playgroud)
在上面的例子中,预期结果是 7。我知道
int closestSmaller = list.Aggregate((x,y) => Math.Abs(x-number) < Math.Abs(y-number) ? x : y);
Run Code Online (Sandbox Code Playgroud)
但它返回 10。我的列表有数十万个数字。以上只是一个示例。
我在 EF Core 7 中使用 .NET 7 有以下代码:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.AddInterceptors(new IgnoreTrackingInterceptor());
}
public class IgnoreTrackingInterceptor : IMaterializationInterceptor
{
public object InitializedInstance(MaterializationInterceptionData materializationData, object instance)
{
if (instance is ISomeEntity someEntity)
materializationData.Context.Entry(someEntity).State = EntityState.Detached;
return instance;
}
}
Run Code Online (Sandbox Code Playgroud)
使用该应用程序一段时间后,它会抛出ManyServiceProvidersCreatedWarning异常。
An error was generated for warning 'Microsoft.EntityFrameworkCore.Infrastructure.ManyServiceProvidersCreatedWarning': More than twenty 'IServiceProvider' instances have been created for internal use by Entity Framework. This is commonly caused by injection of a new singleton service instance into …Run Code Online (Sandbox Code Playgroud) 我想问下面的代码是否是线程安全的:考虑Save1和Save2将同时执行.datacontext的线程安全性有问题吗?
public class Test1()
{
private void Save1()
{
using(TestLinqToSQL obj = new TestLinqToSQL())
{
obj.SaveRecord(new Client (){Id = 1, Name = "John Doe");
}
}
private void Save2()
{
using(TestLinqToSQL obj = new TestLinqToSQL())
{
obj.SaveRecord(new Client (){Id = 2, Name = "Mike Tyson");
}
}
}
public class TestLinqToSQL : IDisposable
{
public void SaveRecord(Client newClient)
{
using(ClientDatacontext cont = new ClientDatacontext())
{
cont.InsertRecord(newClient);
}
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢
当尝试使用ng build -prod构建时,我收到以下错误
ERROR in Cannot determine the module for class ManagersService in C:/Test/src/app/shared/common/managers/managers.service.ts! Add ManagersService to the NgModule to fix it.
Run Code Online (Sandbox Code Playgroud)
我有AppModule,AppCommonModule和CustomModuleA.ManagersService位于AppCommonModule中.CustomModuleA有一个使用AppCommonModule的ManagersComponent(此组件使用ManagersService)的路由.AppCommonModule是在AppModule和CustomModuleA中导入的
我已将该服务添加到AppCommonModule提供程序.我不明白我在这里缺少什么.
注意:使用ng服务时,这就像魅力一样.没错.
这是属于AppCommonModule的ManagersComponent
@Component({
templateUrl: './managers.component.html',
providers: [ManagersService]
})
export class ManagersComponent extends AppComponentBase {
@ViewChild('createOrEditManagerModal') createOrEditManagerModal: CreateOrEditManagerModalComponent;
constructor(public managersService: ManagersService) {
}
Run Code Online (Sandbox Code Playgroud)
这是AppCommonModule
@NgModule({
imports: [
FormsModule,
ReactiveFormsModule
],
declarations: [
ManagersComponent
],
providers: [
ManagersService,
],
exports: [
ManagersComponent,
]
})
Run Code Online (Sandbox Code Playgroud)
这是CustomModuleA
@NgModule({
imports: [
CommonModule,
FormsModule,
HttpModule,
ModalModule,
TabsModule,
TooltipModule,
AppCommonModule,
],
declarations: [ …Run Code Online (Sandbox Code Playgroud) c# ×5
.net ×3
angular ×3
.net-core ×2
asp.net-core ×2
asp.net ×1
autofac ×1
datacontext ×1
identity ×1
linq-to-sql ×1
msbuild ×1
primeng ×1
teamcity ×1