leonkou / netpro Goto Github PK
View Code? Open in Web Editor NEW🌈An enhanced version with clean architecture of asp.netcore,efficiently manage startup,Support for netcore3.1/6.0
Home Page: http://dagou.site/blog/NetPro
License: MIT License
🌈An enhanced version with clean architecture of asp.netcore,efficiently manage startup,Support for netcore3.1/6.0
Home Page: http://dagou.site/blog/NetPro
License: MIT License
目前使用多语言库时,直接指定key取对应文本,当key不存在时,会返回一个computedKey
,即带有语言后缀的key,原因见:
建议调整传入Localization.SqlLocalizer
的选项,使其在没有对应key的时候直接返回key,当项目需要支持多语言时,则手动增加各种语言对应的信息
完整错误信息:
Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: IDasContextAccessor Lifetime: Singleton ImplementationType: Das.Common.DasContextAccessor': Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting to activate 'Das.Common.DasContextAccessor'.)
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting to activate 'Das.Common.DasContextAccessor
原因分析:
经调试后发现是项目中 NetPro.Web.Api中 RoutingStartup 执行报错导致 RoutingStartup 未能正确执行完毕,从而引起IHttpContextAccessor未被注入,最终导致这个问题的出现。在将 library中NetPro.Web.Api项目的RoutingStartup 源码拷贝下来执行调试后查看错误信息发现是这段代码报错了
mvcBuilder.AddFluentValidation(configuration =>
{
string assemblySkipLoadingPattern = "^NetPro.*|^Com.Ctrip*|^Figgle|^Serilog.*|^netstandard|^OpenTracing.Contrib.NetCor|^App.Metrics.AspNetCore|^SkyAPM|^Swashbuckle|^System|^mscorlib|^Microsoft|^AjaxControlToolkit|^Antlr3|^Autofac|^AutoMapper|^Castle|^ComponentArt|^CppCodeProvider|^DotNetOpenAuth|^EntityFramework|^EPPlus|^FluentValidation|^ImageResizer|^itextsharp|^log4net|^MaxMind|^MbUnit|^MiniProfiler|^Mono.Math|^MvcContrib|^Newtonsoft|^NHibernate|^nunit|^Org.Mentalis|^PerlRegex|^QuickGraph|^Recaptcha|^Remotion|^RestSharp|^Rhino|^Telerik|^Iesi|^TestDriven|^TestFu|^UserAgentStringLibrary|^VJSharpCodeProvider|^WebActivator|^WebDev|^WebGrease";
var assembliesResult = new List<Assembly>();
foreach (var item in assemblies)
{
if (!Regex.IsMatch(item.FullName, assemblySkipLoadingPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled) && Regex.IsMatch(item.FullName, ".*", RegexOptions.IgnoreCase | RegexOptions.Compiled))
{
if (!item.IsDynamic)
assembliesResult.Add(item);
}
}
configuration.RegisterValidatorsFromAssemblies(assembliesResult);
//implicit/automatic validation of child properties 复合对象是否验证
configuration.ImplicitlyValidateChildProperties = true;
});
原因是NetPro本身有一个版本的SQLLite程序集,我在使用时又引入了SQLLite的其他版本程序集,而这里的正则表达式又没有排除搜索这两个,所以导致在注册的时候出现冲突
解决办法:
在配置文件中添加
"TypeFinderOption": { "CustomDllPattern": "^XXX.Api*" }
此配置表示仅搜索正则匹配到的程序集,此时只有一个版本的SQLLite,不再报错,问题解决。
比现在的雪花算法更好。
链接:https://github.com/yitter/IdGenerator
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.