我想用autofac在我dotnet core 3.1的项目,但我无法写后运行项目ConfigureContainer内部startup.cs文件。
public void ConfigureContainer(ContainerBuilder builder)
{
var databaseConnectionString = Configuration.GetConnectionString("Database");
builder.RegisterModule(new MediatorModule());
builder.RegisterModule(new ApplicationModule(databaseConnectionString));
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
System.InvalidCastException:无法将
“Microsoft.Extensions.DependencyInjection.ServiceCollection”类型的对象转换为“Autofac.ContainerBuilder”类型。在 Microsoft.Extensions.Hosting.Internal.ConfigureContainerAdapter`1.ConfigureContainer(HostBuilderContext hostContext, Object containerBuilder) 在 Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() 在 Microsoft.Extensions.Hosting.HostBuilder.Build() 在 Program.Main( String[] args) 在 C:\src\Program.cs:line 39
我有一个能够运行NodeJS代码的客户端应用程序.我试图获取客户端Windows用户名(客户端始终在Windows机器上运行)并将Windows用户名传递给服务器端.
如何使用Node.Js获取当前的Windows用户名?
我试图找到类似于WindowsIdentity.GetCurrent()的内容.在C#中为node.js 命名,或在CMD中使用whoamI命令.
我正在尝试使用命令提示符从 Windows 凭据管理器添加和检索凭据。
要添加新的凭据,我有如下命令,它运行得很好:
cmdkey /add:testTarget /user:testUser /pass:testPassword
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试检索之前使用 CMD 添加的凭据 (testTraget) 时,我无法使用以下命令获取密码:
cmdkey /list:testTarget
Run Code Online (Sandbox Code Playgroud)
该命令仅返回目标(testTarget)、类型(域密码)和用户名(testUser)
如何找回 testUser 密码?
我知道在 Mac OS 中使用 Bash 和钥匙串是可能的。
在 Ubuntu 服务器中,我无法使用 PM2 在集群模式下运行 node.js 应用程序。
我使用的命令是:
PM2启动server.js --name Server -i max
当我列出 PM2 进程时,我可以看到服务器处于错误状态。我尝试查看 PM2 生成的日志文件,但它是空的。
不过,我可以使用以下命令在没有集群模式的情况下运行相同的 server.js:
PM2启动server.js --name Server
Using GitLab Runner I have on Linux, I am trying to connect to a Windows Server and run some basic commands there such as git pull.
Does GitLab runner provide any capabilities for accessing windows server?
What other options are there to get such requirement done?
我有一个Docker映像,它是一个node.js应用程序。该应用程序从本地运行的Redis检索一些配置值。因此,我试图在Docker映像内的同一容器内安装和运行Redis。
如何扩展Docker文件并在其中配置Redis?
到目前为止,Dockerfile如下:
从节点:碳
WORKDIR / app
COPY package.json / app
运行npm安装
复制。/ app
展览3011
CMD节点/app/src/server.js
将我的.NetCore 2.2应用程序升级到Net Core 3.1. 我现在面临startup.cs与UseSpaStaticFiles()方法相关的文件中的问题。
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app
.UseCors("default")
.UseStaticFiles()
.UseSpaStaticFiles(); // this line is giving me error.
.....
}
Run Code Online (Sandbox Code Playgroud)
错误说:
错误 CS1061“IApplicationBuilder”不包含“UseSpaStaticFiles”的定义,并且找不到接受“IApplicationBuilder”类型的第一个参数的可访问扩展方法“UseSpaStaticFiles”(您是否缺少 using 指令或程序集引用?)
为了解决这个问题,我尝试Microsoft.AspNetCore.SpaServices从Nuget安装软件包,但也没有帮助。
我已将 WEB API dotnet core 2.2 项目升级到 3.1。
在Startup.CS文件中,我有以下方法:
public static IServiceCollection RegisterMvc(this IServiceCollection services, IConfiguration configuration, IWebHostEnvironment environment)
{
try
{
services
.AddMvc(options =>
{
options.Filters.Add(typeof(ValidationActionFilter));
})
.AddControllersAsServices()
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
})
.AddFluentValidation(fv =>
{
fv.ImplicitlyValidateChildProperties = true;
fv.RegisterValidatorsFromAssemblyContaining<MyValidationClass>();
});
}
catch (ReflectionTypeLoadException ex)
{
foreach (Exception inner in ex.LoaderExceptions)
{
Console.WriteLine(inner.Message);
}
throw ex;
}
return services;
}
Run Code Online (Sandbox Code Playgroud)
后来我RegisterMvc()在里面用这个方法ConfigureServices()做依赖注入。
升级到新的 dotnet 核心后,我收到以下错误,我对它想说什么或如何解决它一无所知:
System.Reflection.ReflectionTypeLoadException: 'Unable to load …Run Code Online (Sandbox Code Playgroud) 我想通过为 Terraform 提供 Azure ARM 模板来使用 Terraform 配置 Azure AD 域服务,这是因为 Terrafrom 不支持在本机配置 Azure AD 域服务。
我已经导出了 ARM 模板及其参数,其中一个参数被称为"notificationSettings"一种类型Object,如下所示:
"notificationSettings": {
"value": {
"notifyGlobalAdmins": "Enabled",
"notifyDcAdmins": "Enabled",
"additionalRecipients": []
}
}
Run Code Online (Sandbox Code Playgroud)
其他参数都是strings,我可以毫无问题地传递它们,例如:
"apiVersion" = "2017-06-01"
Run Code Online (Sandbox Code Playgroud)
我曾尝试将此对象传递给如下参数:
"notificationSettings" = [{
"notifyGlobalAdmins" = "Enabled"
"notifyDcAdmins" ="Enabled"
"additionalRecipients" = []
}]
Run Code Online (Sandbox Code Playgroud)
但是,当我执行时terrafrom apply,terrafrom 抱怨说:
属性“参数”的值不合适:元素“notificationSettings”:需要字符串。
如何将 Object 的参数类型传递给template body?
我还尝试使用parameters_body如下选项将整个 ARM json 参数作为文件提供给 terrafrom :
parameters_body = "${file("${path.module}/temp/params.json")}"
Run Code Online (Sandbox Code Playgroud)
但是,在执行 terrafrom 脚本时出现以下错误: …
我的 MVC 应用程序中有一个HTTP PUT Web API 方法,该方法从客户端接收文件并将其放入服务器存储。
由于文件大小可能很大,我不会将文件流式传输到内存中以避免内存越界异常,因此我使用MultipartFormDataStreamProvider将其加载到临时文件夹中,并稍后将其移动到最终目的地。
除了不能上传大于 2097148 KB (2.097GB) 的文件之外,一切都运行良好。一旦我提供的文件大于该值,它就会开始在 Temp 文件夹中传输该文件,然后在文件大小达到 2097148 KB 时停止。
我的 web.config 文件中有以下属性:
最大请求长度=“5097151”,
requestLengthDiskThreshold =“50971”,
maxAllowedContentLength =“4242880000”。
另外,在 IIS 中,我已将允许的最大内容长度(字节)设置为 4242880000 KB。
还有其他地方可能会导致这种情况发生吗?
c# ×4
.net-core ×3
asp.net-core ×2
node.js ×2
asp.net-mvc ×1
autofac ×1
cmd ×1
command-line ×1
docker ×1
dockerfile ×1
gitlab ×1
gitlab-ci ×1
iis ×1
pm2 ×1
redis ×1
terraform ×1
upload ×1
windows ×1