郑州专业的网站建设,郑州网站建设方案服务,江西省建设工程协会网站查询,文创产品设计创意在迁移.net core的过程中#xff0c;第一步就是要把.net framework 工程的目标框架改为.net core2.0#xff0c;但是官网却没有提供转换工具#xff0c;需要我们自己动手完成了。.net framework 工程迁移为.net core工程大体上有两种方案#xff1a; 1.创建一个.net core的…在迁移.net core的过程中第一步就是要把.net framework 工程的目标框架改为.net core2.0但是官网却没有提供转换工具需要我们自己动手完成了。.net framework 工程迁移为.net core工程大体上有两种方案 1.创建一个.net core的工程然后把所有的文件挪过去。这是比较笨的一种办法如果工程比较小还好弄。如果有几百工程那就哭了。 2.通过编辑.csproj文件强制把工程迁移到.net core下。 今天给大家分享的就是如何通过修改.csproj文件的方式把.net framework 工程迁移到.net core下。 步骤一通过VS2017打开.net framework 解决方案卸载指定的项目后打开.csproj文件。 步骤二移除两个 import引用 步骤三移除 Release、Debug编译的配置信息 步骤四修改 Project节点属性
Project ToolsVersion15.0 xmlnshttp://schemas.microsoft.com/developer/msbuild/2003 替换为
Project SdkMicrosoft.NET.Sdk 步骤五移除TargetFrameworkVersion信息增加信息:TargetFrameworknetcoreapp2.0/TargetFramework 步骤六重新加载项目 步骤七在已经加载的 .net core项目上继续编辑csproj文件。 步骤八移除文件列表信息。 步骤九移除AssemblyInfo.cs文件。 步骤十移除.net framework工程中隐藏的文件。因为.net core 工程不支持排除文件所以在完成上述迁移后原来隐藏的文件会自动添加到工程中对这些垃圾文件请识别后手工删除即可。 步骤十一重新添加nuget包引用。.net framework 对nuget包的引用信息是存储到packages.config中的。此文件已经在.net core中移除。请根据packages.config信息在项目中重新添加nuget引用。引用信息将会自动添加到csproj文件中。 步骤十二编译工程。说一下很多.net framework的API在.net core中已经没有了正在迁移前请看一下下面的.net core的资料。 1. 不支持序列化和xml操作 *需要Install-Package System.Xml.XmlDocument , Install-Package System.Runtime.Serialization.Formatters -Pre, Install-Package System.Xml.XmlSerializer * XmlDocument * XmlIgnore * Serializable * XmlNode * BinaryFormatter * SoapFormatter * InflaterInputStream * DataContractSerializer Install-Package System.Runtime.Serialization.Xml * DataContractJsonSerializerInstall-Package System.Runtime.Serialization.Json
2. 部分反射需要改造 you need to reference the following: * System.Reflection * System.Reflection.Primitives * System.Reflection.Extensions * System.Reflection.TypeExtensions * If you need IL generation then add System.Reflection.Emit andSystem.Reflection.Emit.ILGeneration * 比如Type.GetProperties()要改为Type.GetTypeInfo().GetProperties() * 不支持Assembly.GetExecutingAssembly() https://forums.asp.net/t/2001385.aspx
3. Tasks and Threading and async/await are available, but you will have to reference the following: * System.Threading.Thread * System.Threading.Tasks
4. Sockets are available but you need to reference the following: * System.Net.Sockets. * System.Net.Security if you want SslStream. * Also, socket.Close() is now socket.Dispose()
5. RemotingIts used for cross-AppDomain communication, which is no longer supported. Also, Remoting requires runtime support, which is expensive to maintain.
6. Async is supported (see above point) but the older IAsyncResult-based async is not supported. You will have to disable those sections using #if tags or upgrade to async/await.
7. Serialization by converting data to and from Binary is unsupported, but XML, and JSON serialization is. (see System.Runtime.Serialization.Xml and System.Runtime.Serialization.Json)
8. Crypto is available but many classes are renamed and refactored, for eg. new SHA1CryptoServiceProvider() is now SHA256.Create().
9. StackTrace is available but you need the extra System.Diagnostics.StackTrace, so if its not essential you may want to remove from your code rather than add an additional dependency
10. XAML is unsupported but if you are targeting UWP you will have to use the Windows RT XAML APIs.
11. 不支持部分对象 * ArrayList * Hashtable * HybridDictionary * BindingList * ThreadInstall-Package System.Threading.Thread * ProcessInstall-Package System.Diagnostics.Process * HttpContext * AppDomain * DataSet / DataTable / DBNull。DataTable and DataSet is not available in the System.Data namespace but other features like the provider model and SQL client are available.
12. 注册表无法访问 * RegistryKey
13. 不支持相关配置对象 * ConfigurationManager * WebConfigurationManager * ConfigurationSection
14. 不支持绘图 * System.Drawing * System.Drawing.Size
15. 无法使用相关Web对象 *System.Web.HttpUtility.HtmlDecode
16. 很多Stream没有了Close()方法直接替换为Dispose()
17. DateTime.Now.ToShortDateString() 替换为 DateTime.Now.ToString(yyyy-MM-dd)
18. 不支持部分Attribute * DescriptionAttribute
19. WebResponse/WebRequest对象有变化 * 不支持httpWebResponse.ContentEncoding无法识别是否响应加了GZip也或许能自动识别 * 不支持httpWebRequest.Referer / .UserAgent 无法设置请求浏览器和来源地址
20. Some key missing components: (source) * System.AppDomain - App Domains * System.Drawing.Image - Graphics, Bitmap Images * System.DirectoryServices - LDAP, Active Directory * System.Transactions - ambient transactions, distributed transactions * System.Xml.Xsl - XSLT * System.Xml.Schema - XSD * System.Net.Mail - Sending Email * System.Runtime.Remoting - Remoting, RPC * System.Runtime.Serialization.Xml - Binary Serialization * System.IO.Ports - Serial Port * System.Workflow - Windows Workflow Foundation
相关文章
.NET应用迁移到.NET Core一.NET应用迁移到.NET Core二风险评估.NET应用迁移到.NET Core三从商业角度看移植过程.NET应用迁移到.NET Core--调查案例迁移传统.net 应用到.net core [视频]应用工具 .NET Portability Analyzer 分析迁移dotnet core.net core 2.0学习笔记一开发运行环境搭建.net core 2.0学习笔记二Hello World 进阶度量.net framework 迁移到.net core的工作量
原文地址 http://www.cnblogs.com/vveiliang/p/7409825.html .NET社区新闻深度好文微信中搜索dotNET跨平台或扫描二维码关注