coreclr

.NET Core launch.json 简介

僤鯓⒐⒋嵵緔 提交于 2020-05-04 07:19:27
1.环境 Windows,.NET Core 2.0,VS Code dotnet> dotnet new console -o myApp 2.launch.json配置文件 { // Use IntelliSense to find out which attributes exist for C# debugging // Use hover for the description of the existing attributes // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md " version " : " 0.2.0 " , " configurations " : [ { " name " : " .NET Core Launch (console) " , " type " : " coreclr " , " request " : " launch " , " preLaunchTask " : " build " , // If you have changed target frameworks, make sure to update the program path. "

IIS调试ASP.NET Core项目

戏子无情 提交于 2020-05-04 04:42:55
IIS调试ASP.NET Core项目 新建一个ASP.NET Core Web项目,选择API模板或随便一个模板都行 新建一个名为localhost的发布(没试过远程主机,或许也可以),主要设置如下: 连接页 ​ 发布方法:Web部署 ​ 服务器:localhost ​ 站点名称:Default Web Site/{任意合法名称} 设置页 ​ 配置:Debug ​ 目标框架:与项目所用框架一致 (当前选的netcoreapp2.2) ​ 部署模式:框架依赖 ​ 目标运行时:可移植 执行发布,会在IIS中自动创建站点和应用程序池,检查创建的应用程序池是否为:无托管代码 + 集成 浏览该网站,确保能正常打开 在Visual Studio中选择"调试\附加到进程..."菜单,在弹出的对话框中选择相应的进程 可以输入关键字"w3wp"来过滤出IIS进程,ASP.NET Core网站进程在类型列的值为"托管(CoreCLR)",还可以通过用户名列进一步分辨。 如果没有见到相关进程,可以尝试按一按[刷新]按钮。 附加成功后,在相应的方法内部加断点,然后通过浏览器访问该方法,断点将会命中。 还有一种一步到位的调试方法,打开项目属性对话框,选择"调试"页,新建一个配置(例如名为IIS) 启动:IIS 参数:默认没有 √启动浏览器:可指定启动时浏览的URL,不指定则浏览默认页面 环境变量

【转】Aspnet Core为什么支持跨平台

拥有回忆 提交于 2020-04-10 09:09:02
1.框架决定--因为代码运行需要环境,有了能够运行在 Windows和Linux下面的 CLR. 2.netCore有了个 kestrel(具体的解释去查询下).跨平台的适用于ASP.NET Core的WEB服务器。角色类似 IIS,他不是IIS, 简单的说 kestrel的性能高,功能少,在Linux下性能更高,不支持反向代理。 先来看一下.NET Framework和Core的大体结构 NET Framework本身是个"跨Windows"的平台, 而在这个基础上, 又支持C#和VB等语言进行 "跨语言", 这些语言都遵守CLS, 编译成CIL执行. 从我们多层架构设计的角度来看, 只换最底层, 还是很可行的. .NET Core 重做了一个CoreCLR的运行时,以及一个叫做CoreFX的BCL. 这里要说一下, ASP.NET Core 完全作为 NuGet 包的一部分提供。 这样一来,可以将应用优化为只包含必需 NuGet 包, 使应用更加灵活、模块化的同时提高性能. .NET Core通过实现.NET Standard与 .NET Framework做兼容. 至于跨平台, 因为90%的CoreFX代码都是与平台无关的 https://www.cnblogs.com/huaan011/p/12204883.html https://blog.csdn.net

.net core 3 yields different floating point results from version 2.2

旧街凉风 提交于 2020-03-16 07:28:46
问题 Here is a sample piece of code with outputs from .net core 2.2 and 3.1. It shows different computational results for a basic floating point expression a^b. In this example we calculate 1.9 to the power of 3. Previous .NET frameworks yielded the correct result, but .net core 3.0 and 3.1 yields a different result. Is this an intended change and how can we migrate financial calculation code to the new version with a guarantee that numerical calculations will still yield the same results? (It

How to build IOptions<T> for testing?

大憨熊 提交于 2020-02-24 10:50:20
问题 In ASP.NET Core 2 i have the following class that takes IOptions<T> public class MyOptions { public string Option1 { get; set; } public string Option2 { get; set; } } public class MyService:IMyService { private readonly MyOptions _options; public MyService(IOptions<MyOptions> options) { _options = options.Value; } } appsettings.json { "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Warning" } }, "MyOptions": { "Option1": "option 1 value", "Option2": "option 2 value" } } Then i

How to build IOptions<T> for testing?

。_饼干妹妹 提交于 2020-02-24 10:50:06
问题 In ASP.NET Core 2 i have the following class that takes IOptions<T> public class MyOptions { public string Option1 { get; set; } public string Option2 { get; set; } } public class MyService:IMyService { private readonly MyOptions _options; public MyService(IOptions<MyOptions> options) { _options = options.Value; } } appsettings.json { "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Warning" } }, "MyOptions": { "Option1": "option 1 value", "Option2": "option 2 value" } } Then i

Handling exception in asp.net core?

落爺英雄遲暮 提交于 2020-01-22 10:36:24
问题 I have asp.net core application. The implementation of configure method redirects the user to "Error" page when there is an exception ( in non Development environment) However it only works if the exception occurs inside controller. If exception occurs outside of controller, for example in my custom middleware, then the user does not get redirected to error page. How do i redirect user to "Error" page if there is an exception in the middleware. public void Configure(IApplicationBuilder app,

C# .NET Core How to debug System.IO.FileNotFoundException in System.Private.CoreLib.dll?

若如初见. 提交于 2020-01-21 11:43:08
问题 When I run .NET Core Web API Application on VS 2017, In Output's Debug panel, keep showing me Exception throw: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll However, application runs well without stoping or malfunctioning. I know Exception always means somthing needs to be cared. So, how can I search what File is Not Found when run CoreCLR? ------------- more ------------------- 'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore

MemoryCache.Default not available in .NET Core?

风格不统一 提交于 2020-01-14 07:04:09
问题 I'm porting some code from .NET 4.6 til .NET Core and have run into some problems with MemoryCache. The 4.6 code is using MemoryCache.Default to instantiate the cache, but this doesn't seem to be available in .NET Core. Is there any equivalent to this in .NET Core or should I rather new up my own MemoryCache as a singleton and inject it via IOC? 回答1: Generally you would use the singleton IMemoryCache IServiceProvider ConfigureServices(IServiceCollection services){ ... services.AddMemoryCache(

Sharing logger between different .NET frameworks

最后都变了- 提交于 2020-01-12 08:26:09
问题 I am creating an application framework that can be shared between .Net Core 1.2, .Net Core 2.0 and .NET Framework 4.6+. So I choose the target framework of my project as .NET Standard. In my framework project I have factory class that is used to send a text message or email. On application startup, each application configures the factory with the supported services as singleton instance with DI framework. public class MyFactory : IMyFactory { private ILogger _logger; private IDictionary