SchUseStrongCrypto 設定允許 .NET 使用 TLS 1.1 和 TLS 1.2。 SystemDefaultTlsVersions 設定允許 .NET 使用 OS 設定。
.NET 3.5 TLS 1.2 踩雷記-黑暗執行緒
https://blog.darkthread.net/blog/net35-tls12-issue/
2021年9月14日 星期二
net framework 3.5程式使用TLS 1.2連線
2021年8月28日 星期六
SQL Server 2012 Native Client - QFE才支援TLS 1.2
某次SQL Server伺服器作業系統關閉TLS 1.0和1.1之後,AP程式連DB有問題,後來發現是要安裝新版的SQL Server 2012 Native Client - QFE。原本是安裝舊版的11.0.2100.60(在2012年發佈的)。安裝後需要重新啟動伺服器。
下載Microsoft® SQL Server® 2012 Native Client - QFE (支援TLS 1.2)
https://www.microsoft.com/en-us/download/details.aspx?id=50402
Version:
11.0.7001.0
Date Published:
1/19/2018
升級成新版可以在AP伺服器建立一個 .udl檔案測試和資料庫連線,可參考以下網址
https://success.trendmicro.com/solution/1118930-using-tlsv1-1-or-tlsv1-2-for-communication-between-mssql-server-and-officescan
KB3135244 - TLS 1.2 support for Microsoft SQL Server(必看!)
https://support.microsoft.com/en-us/topic/kb3135244-tls-1-2-support-for-microsoft-sql-server-e4472ef8-90a9-13c1-e4d8-44aad198cdbe
sqlncli.msi安裝程式資訊(QFE版,支援TLS1.2)
System.Runtime.InteropServices.COMException (0x8004100F): Logon failed.
Details: [Database Vendor Code: 10054 ]
Logon failed.
Details: [Database Vendor Code: 10054 ]
Error in File C:\Windows\TEMP\XXXXX.rpt:
Unable to connect: incorrect log on parameters.
Details: [Database Vendor Code: 10054 ]
at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.SetTableLocation(ISCRTable CurTable, ISCRTable NewTable)
at CrystalDecisions.CrystalReports.Engine.Table.set_Location(String value)
如果有用到ODBC Driver 11 for SQL Server(msodbcsql.msi)也需要新版才支援TLS1.2
<最新版已經出到17)
https://docs.microsoft.com/zh-tw/sharepoint/security-for-sharepoint-server/enable-tls-1-1-and-tls-1-2-support-in-sharepoint-server-2016
1.1 - 安裝 ODBC Driver 11 for SQL Server 的 TLS 1.2 支援更新
ODBC Driver 11 for SQL Server (適用於 SQL Server 的 ODBC 驅動程式 11) 預設不支援 TLS 1.1 或 TLS 1.2。您必須安裝 ODBC Driver 11 for SQL Server 的 TLS 1.2 支援更新。
- 若要安裝 ODBC Driver 11 for SQL Server 的 TLS 1.2 支援更新,請參閱<Microsoft® ODBC Driver 11 for SQL Server® - Windows>。
The PowerShell Script currently supports the following:
Check if SQL Server Native Client can support TLS 1.2
Check if Microsoft ODBC Driver for SQL Server can support TLS 1.2 This script is restricted to work on x64 and x86 platforms
在AP伺服器上檢測SQL Server資料庫驅動程式是否支援TLS 1.2?
Different generations of OLE DB Drivers
There are three distinct generations of Microsoft OLE DB providers for SQL Server.
1. Microsoft OLE DB Provider for SQL Server (SQLOLEDB)
The Microsoft OLE DB Provider for SQL Server (SQLOLEDB) still ships as part of Windows Data Access Components. It is not maintained anymore and it is not recommended to use this driver for new development.
2. SQL Server Native Client (SNAC)
Starting in SQL Server 2005 (9.x), the SQL Server Native Client (SNAC) includes an OLE DB provider interface (SQLNCLI) and is the OLE DB provider that shipped with SQL Server 2005 (9.x) through SQL Server 2012 (11.x).
It was announced as deprecated in 2011 and it is not recommended to use this driver for new development. For more information about the SNAC lifecycle and available downloads, refer to SNAC lifecycle explained.
3. Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL)
OLE DB was undeprecated and released in 2018.
The new OLE DB provider is called the Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL). The new provider will be updated with the most recent server features going forward.
Note
To use the new Microsoft OLE DB Driver for SQL Server in existing applications, you should plan to convert your connection strings from SQLOLEDB or SQLNCLI, to MSOLEDBSQL.
KB 4486153:Windows 10和 Windows Server 2019的.NET Framework 4.8
簡介
本文介紹了 Windows 10、版本 1709、Windows 10、版本 1803、Windows Server、版本 1803、Windows 10、版本 1809 和 Windows Server、版本 1809 和 Windows Server 2019 上的 Microsoft .NET Framework 4.8 的更新。
請注意: 從 2020 年 1 月 14 日開始,.NET Framework 4.8 已使用最新的服務更新重新整理。 除了 服務修正程式,2019 年 8 月 13 日發行的 Windows Update 中 , .NET Framework 4.8 產品中沒有任何變更。 如果您已下載並 安裝 8 月發行的更新,則不需要安裝此更新, 否則,請安裝此更新以收到最新的產品位元。
安裝此套件時,將根據您的作業系統安装以下套件或更新:
-
在 Windows 7 SP1 和 Windows Server 2008 R2 SP1 中,Microsoft.NET Framework 4.8.1 (KB4503548) 在「控制台」下的「程式和功能」中列為已安裝產品。
-
在 Windows Server 2012 中,Microsoft Windows 的更新 (KB4486081) 位於控制台下的「已安裝更新」中。 在 Windows 8.1 或 Windows Server 2012 R2 中,Microsoft Windows 的更新 (KB4486105) 位於控制台的「已安装更新」當中。
-
在 Windows 8.1 或 Windows Server 2012 R2 中,Microsoft Windows 的更新 (KB4486105) 位於控制台的「已安装更新」當中。
-
在 Windows 10 周年更新(版本 1607)、Windows 10 建立者更新 (版本 1703) 和 Windows Sever 2016 中,它在控制台下的「已安裝更新」中被列為 Microsoft Windows 更新 (KB4486129)。
-
在 Windows 10 秋季建立者的更新版本 1709、Windows 2018 年 4 月 10 日更新 (版本 1803)、Windows 2018 2018 更新 (版本 1809) 和 Windows Server 2019 中,它在控制台的「已安裝更新」下被列為「微軟 Windows 更新 」(KB4486153)。
2020年6月22日 星期一
2020年6月21日 星期日
製作Visual Studio 2019專業版離線安裝檔
事先到https://docs.microsoft.com/zh-tw/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019下載vs_professional.exe
離線安裝檔包含.NET web和.NET desktop development和Office development(繁中和英文):
請事先在D磁碟機建立vs2019pro資料夾
使用命令提示字元執行以下指令
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --add Microsoft.VisualStudio.Workload.Office --includeOptional --lang en-US zh-TW
參考資料:
https://docs.microsoft.com/zh-tw/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019
https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/install/create-an-offline-installation-of-visual-studio.md
For .NET web and .NET desktop development, run:
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --includeOptional --lang en-US zh-TW
To create a complete local layout with all features (this will take a long time—we have lots of features!), run:
vs_professional.exe --layout D:\vs2019pro --lang en-US zh-TW
For .NET desktop and Office development, run:
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.Office --includeOptional --lang en-US zh-TW
2020年6月13日 星期六
BinaryFormatter()搭配SerializationBinder類別驗證許可還原序列化的類別
https://topic.alibabacloud.com/tc/a/-net-c--pilot-type-in-deserialization-using-serializationbinder_1_31_32345296.html
p.27
https://owasp.org/www-community/vulnerabilities/Deserialization_of_untrusted_data
2020年6月7日 星期日
2020年6月4日 星期四
NET Core 2.1開始Identity UI被包進Razor Class Library
2020年6月3日 星期三
error CS0234: 命名空間 'Microsoft.AspNetCore.Identity' 中沒有類型或命名空間名稱 'UI' (是否遺漏了組件參考?)
https://www.nuget.org/packages/Microsoft.AspNetCore.Identity.UI
所以要把專案升級到.NET Core 3.1以上
obj\Debug\netcoreapp3.0\SkillTreeRazorPageBlogSample.AssemblyInfo.cs(14,42): error CS0234: 命名空間 'Microsoft.AspNetCore.Identity' 中沒有類型或命名空間名稱 'UI' (是否遺漏了組件參考?) [D:\temptest\SkillTreeRazorPageBlogSample.csproj]
0 個警告
1 個錯誤
經過時間 00:00:03.72
RunTime 00:00:14.95
2020年6月1日 星期一
TagMode.StartTagAndEndTag
TagMode.StartTagAndEndTag in the tag helper:<website-information info="webContext" >
</website-information>
https://whosnailaspnetcoredocs.readthedocs.io/ko/latest/mvc/views/tag-helpers/authoring.html[HtmlTargetElement("email", TagStructure = TagStructure.WithoutEndTag)] public class EmailVoidTagHelper : TagHelper { private const string EmailDomain = "contoso.com"; // Code removed for brevity
https://www.cnblogs.com/dotNETCoreSG/p/aspnetcore-4_3_6_2-tag-helpers-authoring.html
2020年5月31日 星期日
AddDefaultIdentity已在 ASP.NET Core 2.1 中引進
AddDefaultIdentity已在 ASP.NET Core 2.1 中引進。 呼叫AddDefaultIdentity類似于呼叫下列內容:AddIdentity、AddDefaultUI、AddDefaultTokenProviders
原始碼
https://github.com/aspnet/Identity/blob/c7276ce2f76312ddd7fccad6e399da96b9f6fae1/src/UI/IdentityServiceCollectionUIExtensions.cs#L49
ref:
https://docs.microsoft.com/zh-tw/aspnet/core/security/authorization/secure-data?view=aspnetcore-3.1
2020年5月23日 星期六
libphonenumber-csharp
檢查電話號碼格式是否正確
還會顯示分類:FIXED_LINE、MOBILE、VOIP(070門號)、TOLL_FREE(080門號)
DEMO:
https://libphonenumber.appspot.com
Java原版:
https://github.com/google/libphonenumber
ref:
https://www.twilio.com/blog/validating-phone-numbers-effectively-with-c-and-the-net-frameworks
https://medium.com/frochu/libphonenumber-example-app-f60680faa599
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor' while attempting to activate
Startup.cs的ConfigureServices(IServiceCollection services)加入以下這一行
//TagsHelper使用
services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();
錯誤訊息:
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor' while attempting to activate
2020年2月9日 星期日
C#和Java的泛型差異
雖然很舊的文章,但是很詳細的比較了C#和Java泛型的差異
最近在看Essential C# 6這本書,第11章(C# 7是在第12章)有提到Java和C#泛型機制的不同。搜尋了一些資料,小弟我大致整理如下,歡迎先進補充指正,謝謝
JDK 5加入泛型,為了避免修改JVM規格影響向下相容,是在編譯器實作泛型(不是在JVM實作),另外Java的泛型不支援Primitive Type(等同C#的Value Type)
Java採用Code Sharing實作,對每一個泛型類或泛型方法只會生成一份object code(byte code),Java compiler透過type erasure實作,也導致無法在runtime時期取得泛型類或泛型方法的實際型別
C#和C++ Template採用Code Specialization實作,對每一個泛型類或泛型方法都會產生一份object code
C# 2.0加入泛型,.NET是在CLI(common language implementation)加入泛型支援,性能較好,且可以在runtime時期取得泛型類或泛型方法的實際型別資訊
參考資料:
Java魔法堂:解讀基於Type Erasure的泛型
https://www.cnblogs.com/fsjohnhuang/p/4288614.html
聊聊Java泛型類型擦除及Flink類型暗示(type hint)機制
https://www.jianshu.com/p/cfb8c1386f69
Type Erasure
https://docs.oracle.com/javase/tutorial/java/generics/erasure.html
https://stackoverflow.com/questions/355060/c-sharp-vs-java-generics
https://stackoverflow.com/questions/31693/what-are-the-differences-between-generics-in-c-sharp-and-java-and-templates-i
C# vs Java : Generics
http://toddgerspacher.blogspot.com/2017/07/c-vs-java-generics.html
Generics in Java
https://en.wikipedia.org/wiki/Generics_in_Java#Problems_with_type_erasure
Generics in the Run Time (C# Programming Guide)
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/generics-in-the-run-time
.NET Column: Introducing Generics in the CLR
https://docs.microsoft.com/en-us/archive/msdn-magazine/2003/september/net-column-introducing-generics-in-the-clr
Finally, the research group at Microsoft has modified a version of the shared source common language implementation (CLI), code-named "Rotor," to include generics support.
https://dotnetfiddle.net/MEK7FM



