Try   HackMD

.NET Framework 4.7.2 から .NET Core 6.0 への移行 2021-08-12

Microsoft.VisualBasic

以下のコードはWindowsでのみ実行可能

Strings.StrConv(strConv, VbStrConv.Hiragana, VisualBasicUtil.LocaleId_Japanese)

以下に変更

using CSharp.Japanese.Kanaxs; KanaEx.ToHiragana(strConv);

Thread.SetApartmentState

Windowsアプリでは使用したいので、以下のように変更。

Thread thread = new Thread(() => act()); thread.TrySetApartmentState(ApartmentState.STA);

この対応で問題ないか、後日検証する。

System.Deployment.Application

以下の処理は利用できないので、プリプロセッサで分岐。
※ClickOnceは利用しなくなるはずなので、この処理は不要。

#if !NET using System.Deployment.Application; if (ApplicationDeployment.IsNetworkDeployed) { // 現在のバージョンを取得。 ApplicationDeployment deploy = ApplicationDeployment.CurrentDeployment; strDeploymentVersion = deploy.CurrentVersion.ToString(); } #endif

Microsoft.JScript

Microsoft.JScript.JScriptCodeProviderは利用できなくなるので、ClearScriptに移行。

microsoft/ClearScript
https://github.com/microsoft/ClearScript

System.Management.ManagementObjectSearcher

System.Management.ManagementObjectSearcherは、Windowsでのみ利用可能。

log4net

App.configに記述していた設定を、log4net.config に変更。

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]

に変更。

"log4net.config"の部分は、.NET framework時代のApp.configを使用しても動作する。ただし、該当ファイルのプロパティを、新しい場合はコピーするに変更すること。

System.Runtime.InteropServices

Windowsでのみ利用可能。

System.Diagnostics

Windowsでのみ利用可能。

Thread.GetDomain().DefineDynamicAssembly()

#if NET var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName { Name = name }, AssemblyBuilderAccess.Run); //NOTE: to save, use RunAndSave #else var assemblyBuilder = Thread.GetDomain().DefineDynamicAssembly(new AssemblyName { Name = name }, AssemblyBuilderAccess.Run); //NOTE: to save, use RunAndSave #endif

System.IO.Ports

Windowsでのみ利用可能。

Windowsのみで実行される前提のプロジェクトは、csprojの設定を変更し、AssemblyInfo.csに属性を追加する。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net6.0</TargetFramework> <DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports> <AssemblyName>XXXXXXXX</AssemblyName> <RootNamespace>XXXXXXXX</RootNamespace> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> <SignAssembly>true</SignAssembly> <AssemblyOriginatorKeyFile>XXXXXXXX.snk</AssemblyOriginatorKeyFile> </PropertyGroup>

<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net6.0-windows</TargetFramework> <DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports> <UseWindowsForms>true</UseWindowsForms> <UseWPF>true</UseWPF> <AssemblyName>XXXXXXXX</AssemblyName> <RootNamespace>XXXXXXXX</RootNamespace> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> <SignAssembly>true</SignAssembly> <AssemblyOriginatorKeyFile>XXXXXXXX.snk</AssemblyOriginatorKeyFile> </PropertyGroup>

<GenerateAssemblyInfo>false</GenerateAssemblyInfo>と設定している場合は、以下の属性を追加する。

#if WINDOWS [assembly: System.Runtime.Versioning.TargetPlatform("Windows7.0")] [assembly: System.Runtime.Versioning.SupportedOSPlatform("Windows7.0")] #endif

Sgry.Azuki

Azuki テキストエディタエンジン
https://azuki.osdn.jp/

Azuki
https://ja.osdn.net/projects/azuki/

以下のモジュールが.net coreで動作するかも

kkato233/azuki
https://github.com/kkato233/azuki

System.Windows.Forms.DataGrid

.NET Core 3.0 および 3.1 における Windows フォームでの破壊的変更
https://docs.microsoft.com/ja-jp/dotnet/core/compatibility/winforms

DataGrid クラス
https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.forms.datagrid?view=netframework-4.8
このクラスは .NET Core 3.1 以降のバージョンでは利用できません。 コントロールを DataGridView 置き換えて、コントロールを拡張する代わりに、コントロールを使用し DataGrid ます。

.NET Coreでは利用できない。DataGridViewを使えとのこと。

System.Windows.Forms.ContextMenu

ContextMenu クラス
https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.forms.contextmenu?view=netframework-4.8

ContextMenuStripに変更する。

Microsoft.VisualBasic.PowerPacks.DataRepeater

.NET Coreでは利用できない、代替コントロールもなし。

Visual Basic Power Packs Controls
https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/cc488277(v=vs.120)
http://go.microsoft.com/fwlink/?linkid=321343

Encoding クラスを使用する前にプロバイダを登録する

#if NET Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); #endif

.NET Coreで使用しないライブラリはプロジェクトから除外する

不要なライブラリがプロジェクトにあると、Visual Studioが自動的に読み込んでしまうことがある為、注意!!

LoadingRing.LoadingSolidRing

オリジナル

hirekoke/LoadingRing
https://github.com/hirekoke/LoadingRing

.NET Core 対応版がforkされているので利用させてもらう

Kisogawa/LoadingRing
https://github.com/Kisogawa/LoadingRing

Microsoft.SDK.Expression.Blend(※特に、System.Windows.Interactivity.dll

Microsoft.Xaml.Behaviors.Wpfに変更する。

Prism.dll

Prism.Coreに変更する。

MaterialDesign

  • MaterialDesignColors.dll
  • MaterialDesignThemes.Wpf.dll

MaterialDesignThemesMaterialDesignColorsの .NET Core 対応版を利用する。

DataSet、Resources、Settings の .Designer.cs が 自動的にネスト(nest)されない。

*.csproj に以下のように設定を追加する。

<ItemGroup> <Compile Update="Properties\Resources.Designer.cs"> <DependentUpon>Resources.resx</DependentUpon> </Compile> <Compile Update="Properties\Settings.Designer.cs"> <DependentUpon>Settings.settings</DependentUpon> </Compile> <Compile Update="test\DataSet1.Designer.cs"> <DependentUpon>DataSet1.xsd</DependentUpon> </Compile> </ItemGroup>

ThoughtWorks.QRCode.Codec

オリジナル

Open Source QRCode Library
https://www.codeproject.com/Articles/20574/Open-Source-QRCode-Library

aaronogan/QR.NET
https://github.com/aaronogan/QR.NET

.NET Core 対応版

gokeiyou/ThoughtWorks.QRCode.Core
https://github.com/gokeiyou/ThoughtWorks.QRCode.Core

上記のモジュールを使用するか、独自で.NET Core対応版を作成する。

Crystal Reports, developer version for Microsoft Visual Studio

Crystal Reports, Developer for Visual Studio Downloads
http://nkurilog.blogspot.com/2017/12/crystal-reports-developer-version-for.html

Downloads for SAP Crystal Reports, SAP Crystal Presentation Design and SAP Crystal Dashboard Design
https://origin.softwaredownloads.sap.com/public/site/index.html

.NET Core の対応予定はない

How to call/reference Crystal Reports from .Net Core
https://stackoverflow.com/questions/62057447/how-to-call-reference-crystal-reports-from-net-core

Crystal Reports for Visual Studio and .NET Core 5. Any plans?
https://www.google.com/search?q=Crystal+report+.net+core&oq=Crystal+report+.net+core&aqs=edge..69i57j0i13j0i30j0i13i30l3j0i30j0i8i13i30j0i8i30.6598j0j4&sourceid=chrome&ie=UTF-8

Is it possible to display Crystal Report in ASP.Net Core Application
https://forums.asp.net/t/2148543.aspx?Is+it+possible+to+display+Crystal+Report+in+ASP+Net+Core+Application

Crystal Reports in ASP .NET Core 2.0
https://answers.sap.com/questions/318288/crystal-reports-in-asp-net-core-20.html

現時点では、Cryastal Reportsを使い続ける場合、何らかの対応を独自に行う必要がある。

2023-03-01 追記
Crystal Reports Runnerなるリポジトリを発見。
https://github.com/gerardo-lijs/CrystalReportsRunner

Microsoft.ReportViewer、Microsoft.SqlServer.Types

公式な .NET Core 対応はアナウンスされていない

Asp.Net Core Reporting (SSRS) #1528
https://github.com/dotnet/aspnetcore/issues/1528

非公式な、.NET Core 対応版

ilich/MvcReportViewer
https://github.com/ilich/MvcReportViewer

lkosson/reportviewercore
https://github.com/lkosson/reportviewercore
「Reporting Services is a free Microsoft product. While decompiling and modifying it for compatibility reasons is legal in my local jurisdiction, redistributing modified version most likely is not. Use at your own risk.」

lkosson/reportviewercoreのソースを確認したところ、逆アセンブルして色々と調整している模様。「私の地元では合法です」とのこと。
日本語リソース関連の対応が行われていないようだ。

dotMorten/Microsoft.SqlServer.Types
https://github.com/dotMorten/Microsoft.SqlServer.Types
Install the package dotMorten.Microsoft.SqlServer.Types from NuGet.

Resources.resx、Resources.Designer.cs

System.Resources.Extensionsパッケージが必要

WCF関連

.NET Core ではWCF関連機能の内、クライアント側機能のみ利用可能。

WCF Windows Communication Foundation Client Libraries
https://github.com/dotnet/wcf

System.Runtime.Serialization.IDataContractSurrogate

.NET Core に見当たらない。

System.ServiceModel.ServiceContractAttribute

System.ServiceModel.Httpパッケージを利用。

System.ServiceModel.ServiceBehaviorAttribute

.NET Core に見当たらない。

System.ServiceModel.Channels.SecurityBindingElement

System.ServiceModel.Securityパッケージを利用。

System.Web.Services.Protocols.SoapException

.NET Core に見当たらない。

System.ServiceModel.Dispatcher.IErrorHandler

wcf/src/System.Private.ServiceModel/src/System/ServiceModel/Dispatcher/IErrorHandler.cs
https://github.com/dotnet/wcf/blob/main/src/System.Private.ServiceModel/src/System/ServiceModel/Dispatcher/IErrorHandler.cs#L10

System.Private.ServiceModelパッケージとして提供されているようだが、参照する事が出来ずにコンパイルが通らない。。。

System.ServiceModel.Primitivesパッケージが使用されている??このパッケージにはIErrorHandlerが存在しない。。

WCFの代替プロジェクト

CoreWCF/CoreWCF
https://github.com/CoreWCF/CoreWCF

GrapeCity.ActiveReports

Windowsアプリケーションの .NET Core には対応していない模様。

.NET Coreアプリケーションで ActiveReports を使用できますか?
https://www.grapecity.co.jp/developer/activereports/release/14

ActiveReports for .NET は、バージョン14.0Jで .NET Core に対応しました。

ASP.NET Coreアプリケーションでの使用をサポートしています。
.NET Core デスクトップアプリ(Windowsフォーム/WPF)での使用はサポートしていません。

LumenWorks.Framework.IO

A Fast CSV Reader
http://www.codeproject.com/Articles/9258/A-Fast-CSV-Reader

ソースコードが公開されているので、.NET Core でビルドしてライブラリを独自に作成する。

System.Collections.Generic.SynchronizedCollection

System.ServiceModel.Primitivesパッケージのインストールが必要。

Org.BouncyCastle BouncyCastle.dll

オリジナル版では .NET Core 版を提供していない??

BouncyCastle
The Legion of the Bouncy Castle
https://www.bouncycastle.org/csharp/

Portable.BouncyCastleはオリジナル??

Portable.BouncyCastle
https://www.nuget.org/packages/Portable.BouncyCastle/1.8.10?_src=template

代替プロジェクト

chrishaly/bc-csharp
https://github.com/chrishaly/bc-csharp

BouncyCastle.NetCore
https://www.nuget.org/packages/BouncyCastle.NetCore/

Microsoft.VisualStudio.QualityTools.UnitTestFramework

MSTestV1 から MSTestV2 へのアップグレード
https://docs.microsoft.com/ja-jp/visualstudio/test/mstest-update-to-mstestv2

csproj

<ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> <PackageReference Include="MSTest.TestAdapter" Version="2.2.7" /> <PackageReference Include="MSTest.TestFramework" Version="2.2.7" /> </ItemGroup>

追加の参考資料

NET Framewarkから NET 6への移行でやった細かいこと(C++CLIもあるよ)
https://youtu.be/1wcfGyDx6Xk

tags: .NET Core .NET Framework .NET Framework 4.7.2