无法将字符串 'Log4netFactory' 转换为类型
Could not convert string 'Log4netFactory' to a type
我最近在我的项目中使用 NuGet 控制台中的这行代码更新了 ABP 包:
ForEach($project in get-project -all) {
ForEach($package in Get-Package -ProjectName $project.ProjectName | ?{ $_.Id -like 'Abp*'}) {
Update-Package -ProjectName $project.ProjectName -Id $package.Id;} }
但是当我启动项目时,我遇到了这个错误:
An exception of type 'Castle.MicroKernel.SubSystems.Conversion.ConverterException' occurred in Castle.Windsor.dll but was not handled in user code Additional information: Could not convert string 'Castle.Services.Logging.Log4netIntegration.Log4netFactory,Castle.Services.Logging.Log4netIntegration,Version=4.0.0.0, Culture=neutral,PublicKeyToken=407dd0808d44fbdc' to a type.
出现在Application_Start
这一行代码中:
AbpBootstrapper.IocManager.IocContainer.AddFacility<LoggingFacility>(
f => f.UseLog4Net().WithConfig("log4net.config")
);
我该如何解决这个问题?
您可以使用Abp.Castle.Log4Net 包。见 document
创建该函数并从错误行调用它
LogConfig("log4net.config");
private void LogConfig(string configFileName)
{
var log4NetConfig = System.IO.Path.Combine(HostingEnvironment.ApplicationPhysicalPath, configFileName);
if (System.IO.File.Exists(log4NetConfig))
AbpBootstrapper.IocManager.IocContainer.AddFacility<LoggingFacility>(
f => f.UseAbpLog4Net().WithConfig(log4NetConfig)
);
}
查看此答案https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2611#issuecomment-337471760
我最近在我的项目中使用 NuGet 控制台中的这行代码更新了 ABP 包:
ForEach($project in get-project -all) {
ForEach($package in Get-Package -ProjectName $project.ProjectName | ?{ $_.Id -like 'Abp*'}) {
Update-Package -ProjectName $project.ProjectName -Id $package.Id;} }
但是当我启动项目时,我遇到了这个错误:
An exception of type 'Castle.MicroKernel.SubSystems.Conversion.ConverterException' occurred in Castle.Windsor.dll but was not handled in user code Additional information: Could not convert string 'Castle.Services.Logging.Log4netIntegration.Log4netFactory,Castle.Services.Logging.Log4netIntegration,Version=4.0.0.0, Culture=neutral,PublicKeyToken=407dd0808d44fbdc' to a type.
出现在Application_Start
这一行代码中:
AbpBootstrapper.IocManager.IocContainer.AddFacility<LoggingFacility>(
f => f.UseLog4Net().WithConfig("log4net.config")
);
我该如何解决这个问题?
您可以使用Abp.Castle.Log4Net 包。见 document
创建该函数并从错误行调用它
LogConfig("log4net.config");
private void LogConfig(string configFileName)
{
var log4NetConfig = System.IO.Path.Combine(HostingEnvironment.ApplicationPhysicalPath, configFileName);
if (System.IO.File.Exists(log4NetConfig))
AbpBootstrapper.IocManager.IocContainer.AddFacility<LoggingFacility>(
f => f.UseAbpLog4Net().WithConfig(log4NetConfig)
);
}
查看此答案https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2611#issuecomment-337471760