billyang / surgingdemo Goto Github PK
View Code? Open in Web Editor NEWsurging 使用入门示例。完成一个基本业务的增删改查示例,并运用Surging强大的分布式缓存功能
Home Page: https://github.com/dotnetcore/surging
License: MIT License
surging 使用入门示例。完成一个基本业务的增删改查示例,并运用Surging强大的分布式缓存功能
Home Page: https://github.com/dotnetcore/surging
License: MIT License
运行Bill.Demo.Services.Server时,在ServiceHostBuilderExtensions.UseLog4net报错:
Value cannot be null.
Parameter name: config
at Microsoft.Extensions.Options.ConfigurationChangeTokenSource1..ctor(String name, IConfiguration config) at Microsoft.Extensions.Logging.LoggingBuilderExtensions.AddConfiguration(ILoggingBuilder builder, IConfiguration configuration) at Surging.Core.Log4net.ServiceHostBuilderExtensions.<>c.<UseLog4net>b__0_0(ILoggingBuilder logger) in D:\microservice\surging\src\Surging.Core\Surging.Core.Log4net\ServiceHostBuilderExtensions.cs:line 15 at Microsoft.Extensions.DependencyInjection.LoggingServiceCollectionExtensions.AddLogging(IServiceCollection services, Action
1 configure)
at Surging.Core.ServiceHosting.Internal.Implementation.ServiceHostBuilder.Build() in D:\microservice\surging\src\Surging.Core\Surging.Core.ServiceHosting\Internal\Implementation\ServiceHostBuilder.cs:line 34
at Bill.Demo.Services.Server.Program.Main(String[] args) in D:\microservice\SurgingDemo\src\Bill.Demo.Solutions\Bill.Demo.Services.Server\Program.cs:line 24
我发现这个问题是在host.Build()的时候调用了
})
.UseStartup()
.Build();
using (host.Run())
{
Console.WriteLine($"服务端启动成功,{DateTime.Now}。");
}
但是这个Configuration是在host.Run()初始化的。
而host.Run()在Build()后执行,所以报了个null的错误。
作者方便解答下这个该怎么解决吗?
具体信息:
应用程序启动异常: System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.Configuration.IConfigurationBuilder' while attempting to activate 'Bill.Demo.Services.Server.Startup'.
at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Surging.Core.ServiceHosting.Internal.Implementation.StartupLoader.LoadMethods(IServiceProvider hostingServiceProvider, Type startupType, String environmentName)
at Surging.Core.ServiceHosting.ServiceHostBuilderExtensions.<>c__DisplayClass0_0.b__1(IServiceProvider sp)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.b__0(ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Surging.Core.ServiceHosting.Internal.Implementation.ServiceHost.EnsureStartup()
at Surging.Core.ServiceHosting.Internal.Implementation.ServiceHost.EnsureApplicationServices()
at Surging.Core.ServiceHosting.Internal.Implementation.ServiceHost.BuildApplication()
Unhandled Exception: System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.Configuration.IConfigurationBuilder' while attempting to activate 'Bill.Demo.Services.Server.Startup'.
at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Surging.Core.ServiceHosting.Internal.Implementation.StartupLoader.LoadMethods(IServiceProvider hostingServiceProvider, Type startupType, String environmentName)
at Surging.Core.ServiceHosting.ServiceHostBuilderExtensions.<>c__DisplayClass0_0.b__1(IServiceProvider sp)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.b__0(ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Surging.Core.ServiceHosting.Internal.Implementation.ServiceHost.EnsureStartup()
at Surging.Core.ServiceHosting.Internal.Implementation.ServiceHost.EnsureApplicationServices()
at Surging.Core.ServiceHosting.Internal.Implementation.ServiceHost.BuildApplication()
at Surging.Core.ServiceHosting.Internal.Implementation.ServiceHostBuilder.Build()
at Bill.Demo.Services.Server.Program.Main(String[] args) in f:\code template\SurgingDemo\src\Bill.Demo.Solutions\Bill.Demo.Services.Server\Program.cs:line 23
surging用的V1.0,运行服务有代理找不到的bug,还有demo里的修改\新增\删除事件会执行两次..请问有码友知道怎么回事吗?
之前能dotnet run 正常运行
今天无修改,dotnet run 报了以下错误
Program.cs(19,21): error CS0017: 程序定义了多个入口点。使用 /main (指定包含入口点的类型)进行编译。 [f:\dotnet\SurgingDemo\src\Bill.Demo.Solutions\Bill.Demo.Services.Server\Bill.Demo.Services.Server.csproj]
有遇到过吗
Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: config at Microsoft.Extensions.Options.ConfigurationChangeTokenSource
1..ctor(String name, IConfiguration config)
at Microsoft.Extensions.Logging.LoggingBuilderExtensions.AddConfiguration(ILoggingBuilder builder, IConfiguration configuration)`
调试的时候,发现是UseLog4net("Configs/log4net.config")报出来的。
跟进去,发现是CPlatform.AppConfig中的Configuration为null,导致CPlatform.AppConfig.GetSection("Logging")为null。
请问,这个问题是如何解决的呢?
我是使用了最新版本的Surging.
这个demo跑不起来的,请看这里https://github.com/zhuzhao/SurgingDemoUpdate
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.