Can I use CSL 5.5 in NET6.0 #2639
Replies: 3 comments 1 reply
-
CSLA 5 doesn't target .NET 6.0, but it does target .NET Standard 2.0, and so should work fine in .NET 6. The UI helper packages (like Csla.Windows.Forms, Csla.Wpf, etc.) may or may not work, as they might actually need to target net6 to work. Server-side Blazor absolutely will not work. The complete embrace of DI in CSLA 6 is what makes SSB work properly. Other than bug fixes, I personally don't plan to put any further effort into CSLA 5. However, if someone were willing to put in the work to (without introducing breaking changes) add .NET 6 support, it would be possible to create a version 5.6.0 and I'd publish it. That still wouldn't get SSB working, but might get all the other UI frameworks working. |
Beta Was this translation helpful? Give feedback.
-
Another option is to use CSLA 6 in a way that minimizes the impact of DI in your code. This won't work in some UI frameworks, but you can get quite far with something like WinForms or WPF. You do need to initialize DI, because CSLA relies on it. So in WPF in your App.xaml.cs: using Csla;
using Csla.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Windows;
namespace SimpleWpf
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private IHost Host { get; }
public App()
{
Host = new HostBuilder()
.ConfigureServices((hostContext, services) => services
// register window and page types here
.AddSingleton<MainWindow>()
// add other services
.AddCsla(options => options.AddXaml())
).Build();
Host.UseCsla();
}
public static ApplicationContext Context { get; private set; }
private void OnStartup(object sender, StartupEventArgs e)
{
Context = Host.Services.GetRequiredService<ApplicationContext>();
var window = Host.Services.GetRequiredService<MainWindow>();
window.Show();
}
}
} That gets DI initialized and launches the first window pretty much like normal. The important thing here is the Having access to the ApplicationContext instance unlocks pretty much everything else. So if you want to use the client-side data portal, for example, you can write code like this: private async void Window_Loaded(object sender, RoutedEventArgs e)
{
var dp = App.Context.CreateInstanceDI<DataPortal<PersonEdit>>();
var obj = await dp.FetchAsync(42);
// set up data binding here
} Most of this code is the same as what you'd do in CSLA 5. The only difference is that you need an instance of In summary: moving to CSLA 6 requires some code changes, but doesn't require that you embrace DI throughout your code base if you don't want to. |
Beta Was this translation helpful? Give feedback.
-
If you can create 5.6.0 version that is the best, my current project is not small, there are hundreds of pages, thousands of business class, if use CSLA6.0 changes place very much, also is not very good in some places, so would ask, for a system has been used in a production environment, this upgrade is a big risk |
Beta Was this translation helpful? Give feedback.
-
HI@rockfordlhotka
I have been following the progress of CSLA6 and learned from your article that CSLA6 has to use DI framework mandatory. I am using WPF+CSLA5 and want to upgrade to NET6.0, but I don't want to use DI mandatory. I prefer traditional programming. Can I continue to use CSLA5.5 under NET6.0
Beta Was this translation helpful? Give feedback.
All reactions