By this time, we all know that .NET Framework 4.8 is the last version of the full Framework branch. This also means that Microsoft will not release new features, efficiencies, or improvements for .NET Framework.
All of this shouldn’t come as a surprise as Microsoft is investing more (if not all) of its resources in .NET Core. This is because .NET Core is the future of development due to the vast feature set and flexibility it provides over .NET Framework.
NCache provides servers for both .NET Framework (4.8) and .NET Core while encouraging its users to use the latter. If you are using any of the server-side features of NCache on a .NET Framework server, then this blog is for you. Otherwise, the migration is seamless, as you just have to install an NCache .NET Core server and start using it.
NCache Details NCache Docs Download NCache
Why Migrate from a .NET Framework Server to a .NET Core Server?
Microsoft considers .NET Core to be the future of its developmental process. That is also why Microsoft is pouring so many resources into it and plans on introducing more features for .NET Core in the future. On the other hand, .NET Framework is slowly becoming outdated and at one point will become completely obsolete. So why wait?
Besides, .NET Core brings so much to the table that .NET Framework doesn’t. The following list of features benefit .NET Core over .NET Framework:
- Cross-platform support: .NET Core code can run on Windows, Linux, and macOS. This means that your NCache .NET Core servers are platform (OS) independent. Also, .NET Core’s command line interpreter (CLI) can be used on all supported platforms.
- Multiple .NET versions side-by-side: Multiple services can be run on the same server (host) with different versions of .NET Core.
- Performance: According to recent metrics, .NET Core has shown better performance in comparison to .NET Framework.
NCache Benchmarks NCache for ASP.NET Core Caching NCache for Data Caching in .NET/.NET Core
How to Deploy Your.NET Framework Code on a .NET Core Server
The best way for you to deploy your existing .NET Framework code on a .NET Core server is to convert it into .NET Standard 2.0 code. This is also why NCache now encourages its users to develop their applications in .NET Standard 2.0 instead of .NET Framework, especially if they are making a new application.
You can adopt one of the following approaches to convert your .NET Framework code into .NET Standard 2.0 code:
- Start from scratch.
- If your project is using the new .csproj format then change the value of the
TargetFramework
tag tonetstandard2.0
- If your project is using the old .csproj format then update it following the new format.
Since the first and the second approaches are pretty straightforward, I will explain the third approach in detail. So, backup your code and let’s get started!
Also, you need to keep in mind that this conversion will not work if your .NET Framework provider refers to a DLL(s) that depends explicitly on .NET Framework. Meaning that DLL(s) doesn’t exist in .NET Standard 2.0. If this is the case then you’ll have to find another workaround for this.
Step 1: Unloading the Project
The first step is to unload your project from Visual Studio by right-clicking on it from the Solution Explorer and selecting Unload Project.
Step 2: Replacing the Content of the Project File
Open the .csproj file in a code editor of your choice and replace its content with the following:
1 2 3 4 5 6 |
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netstandard2.0</TargetFramework> </PropertyGroup> </Project> |
Step 3: Adding Dependencies
In this step, you’ll be adding your dependencies. To add dependencies, you will need to add a ItemGroup
tag right under the PropertyGroup
tag. The dependencies will be enclosed within this ItemGroup
tag as shown below:
1 2 3 4 5 |
<ItemGroup> <Reference Include="NCache.ReadThru.Provider"> <HintPath>path\NCache.ReadThru.Provider.dll</HintPath> </Reference> </ItemGroup> |
To add references to your NuGet packages, you’ll need to add another ItemGroup
tag under the previous one. References to the NuGet packages will be enclosed within this tag as shown below:
1 2 3 |
<ItemGroup> <PackageReference Include="Alachisoft.NCache.SDK" Version="5.2.0" /> </ItemGroup> |
Step 4: Reloading Your Project
After finalizing your changes, reload your project in Visual Studio by right-clicking on it in the Solution Explorer and selecting Reload Project.
Step 5: Removing duplication from AssemblyInfo.cs
Your project won’t run properly unless you remove duplication from the AssemblyInfo.cs file. This file is located under Properties as shown below:
Open this file and delete the duplicate content. It should look something like this:
1 2 3 4 5 6 7 8 9 10 11 |
[assembly: AssemblyTitle("NCache.ReadThru.Provider")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("NCache.ReadThru.Provider")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] |
Step 6: Building and Deploying Your Provider
Once you have completed the steps mentioned above, build your project and re-deploy your compiled provider on an NCache .NET Core Server.
Read Through Caching NCache Docs NCache Benchmarks
Benefits of This Migration
Although the process might prove hectic to some, it has its benefits. By switching to an NCache .NET Core server, you’ll be able to reap all the benefits that come along with using .NET Core. These include but are not limited to:
- Guaranteed future support and updates by Microsoft.
- The luxury to shift the server environment from Windows to Linux without any hiccups.
- Latest technologies and features.
- And many more.
Conclusion
NCache is an extremely fast, efficient, and scalable in-memory distributed cache for .NET Framework/.NET Core, Java, and Node.js. This blog in no way insinuates that NCache will stop providing support for its .NET Framework servers, at least not anytime soon. Instead, NCache just encourages you to switch to .NET Core servers so that you can keep yourselves up to date with the latest technology, updates, and features provided by Microsoft.
The information you’ve shared in this blog is highly remarkable.
Thanks for sharing such quality information.