Hi Matthew,
not sure about that, but did you run the updateConfiguration command in an elevated Visual Studio prompt (i.e. as Administrator)?
Will probably have to dig deeper tomorrow.
Best regards
Frank
Frank, I did get further. I cleared the cache. Ran the devenv /updateConfiguration command and I could now see the wisej templates in Visual Studio 2022.
However, when I pick any of the WiseJ templates and attempt to create a project, I get. The system cannot find the file specified. (Exception from HRESULT: 0x80070002).
Any thoughts?
Hi Matthew,
did you already check our documentation for that issue and followed the steps described here?
https://docs.wisej.com/docs/getting-started-1/troubleshooting
If it still fails, please let us know and we investigate further.
Best regards
Frank
Hi Tom
Thanks for your interest in Wisej.NET
Here I let you a couple of videos that could help
Customizing DataGridView Cell Styles in Wisej
HTH
There is no GetServices() in https://docs.microsoft.com/en-us/dotnet/api/system.iserviceprovider. You cannot use AddDbContext there since it’s not part of that interface and not in our service container. The code snippets you saw probably use this
public class Startup
{
public void ConfigureServices(IServiceCollection services)
=> services.AddDbContext<EntityContext>();
}
You can use that one. However AddDbContext() is an extension from MS in nuget. You can simply add a DbContext using AddService() or add a simple class that contains a db context. The ASP.NET Core service container doesn’t support session-scoped services. In any case, it all depends on what you are trying to do.
What do you expect services.AddDbContext(data) to do? Create a new db context on each request? Create one db context shared across all sessions? Recreate it for each session? If you setup a smalt test case using services.AddDbContext(data) that shows what you want to achieve we may be able to help more.
Hi Matthias
Here documentation link for how wisej.net 3 manage the self hosting
but this is now part of premium extensions.
https://docs.wisej.com/deployment/targets/self-hosting
hth
Paul
I’ve tested your attached project and have exactly same issues (on two different machines). Please see attached screenshots. On net framework 4.8 it works ok all the time, but running it on net 6.0 will result in not loading mixins everytime and sometimes not loading default theme (bootstrap) correctly, falling back to blue.
Hi Luca,
I think what I would like to do, is access the ASP.Net ServiceProvider, created and loaded in ConfigureServices, from within a Wisej UserControl. How can we do this? How do I get hold of it, let’s say, in the click event of a button?
Alex
I provided a sample in the answer.
For “working all together” I have no idea what it would mean. A stateless webapi is different from a view controller and very different from a stateful wisej component. An api call is just a url handled by an handler. You can respond to the http request in many ways, all outside Wisej scope.
If you want to create and destroy a dbcontext, the using pattern is one way. If you want to save it for the session, then you can use the Application.Session object, if you want to have it automatically created on demand and automatically disposed use the new Application.AddService(). If you want to use any other .NET service container it’s also fine.
Hi Luca,
Hi Luca, as I was writing this answer I saw you posted a second one, but anyway, this is what I was writing:
Yes, this is the one, from ConfigureServices. I’ve been using ConfigureServices in ASP.NET WebAPI projects lately and I’ve seen things like services.AddDbContext, services.AddMediatR, services.AddCors etc, which, I suspect, do more than just AddService(Interface).
I’m also trying to get my head around the difference between WebAPI and WiseJ projects. As I understand it, in WebAPI one has a call to a Controller, which is instantiated on the spot using the injected dependencies in its constructor, e.g. a dbContext, does its job and gets disposed. And at the next call, this is repeated. On the other hand, in WiseJ, there is a Form, UserControl, whatever that is created once and is there “waiting”, so I don’t know if the approach of injecting a DbContext to the Form is correct, or it would be better to use a using(var db = new DbContext()) on the click of a button. Which soon gets disposed.
I could use the ConfigureServices to create the IServiceProvider of the ASP.Net application, but then how is this accessible from a Wisej UserControl?
It would be nice if you could provide an example of how all these can work together.
Best,
Alex
The demo app attached running on a tiny server used across an ocean initializes the js runtime in 67ms and shows the main UI with 82 controls in 237ms. Basically 1/4 of a second. Apps with hundreds of controls usually show in less than 1 second. It may even be faster than local desktop apps.
qx.js?v=3.0.10.2:174841 000067 qx.core.Init: Load runtime: 67ms
qx.js?v=3.0.10.2:174841 000081 qx.core.Init: Main runtime: 5ms
qx.js?v=3.0.10.2:174841 000084 qx.core.Init: Finalize runtime: 3ms
qx.js?v=3.0.10.2:174841 000496 Wisej: Welcome to Wisej 3.0.10.2 (C) Ice Tea Group, LLC – All Rights Reserved.
qx.js?v=3.0.10.2:174841 000496 qx.ui.core.queue.Manager: Flush Completed: 0 ms
qx.js?v=3.0.10.2:174841 000510 Wisej: Process Action 2
qx.js?v=3.0.10.2:174841 000714 Wisej: Action Create created: 82
qx.js?v=3.0.10.2:174841 000714 Wisej: Process Action 3
qx.js?v=3.0.10.2:174841 000718 Wisej: Action Update updated: 0
qx.js?v=3.0.10.2:174841 000718 Wisej: Process Actions elapsed: 237 ms
Hi Alex, I looked into AddDbContext() a bit more. It looks like it’s added as an extension to the aspnet container because the default implementation doesn’t support callbacks or custom initialization so they had to add AddDbContext() accepting an options instance. This way they are able to create a new customized DbContext according to the scope. Another problem is that the scope in aspnet core is never the session. At the most you can scope to the http request: i.e. each click creates a new db context.
https://docs.microsoft.com/en-us/ef/core/dbcontext-configuration/
Out service container supports custom initialization and supports the session scope. There is no need to add another method, AddService is all you need. You can of course use AddDbContext() with the aspnet container if you want to destroy and recreate the dbcontext on every request. Otherwise you can use:
Application.AddService(typeof(DbContext), (t, s) => { return new DbContext("connection string"); }, ServiceScope.Session); var dbc = (DbContext)Application.GetService(typeof(DbContext));
Or use your derived class, or change the scope, or register a created instance, or register just the type (wisej will create it on demand), etc. If you want to destroy and recreate the db context on every request let me know, we can add ServiceScope.Request. Consider that everything that coming from the browser is a request.
Hi Team, my client requested that the items be displayed in the middleLeft as alignment for the datagridview columns but i realised the progress bar gets distorted when i set the defaultCellStyle alignment to middleLeft as can be seen in the top datagridview vs the bottom grid in the attached image.
What could be wrong pls.
In our experience on dozens of projects in production with a large number of control is the opposite, it’s extremely fast.
It may be a problem with your connection or browser. If you send a test case and a deployed url we may be able to help you.
The Application class is already implementing the IServiceProvider. Is there any option to redirect the GetService calls to our preferred DI container?
You don’t have to use Application.GetService(). You an use any container. Usually a container instance is static. The container manages the lifetime of the services.
Is there any way to get session lifetime to the dotnet DI? What WiseJ callback would be suite best here to start and stop the scope lifetime?
Dotnet doesn’t have a default DI implementation. Aspnet core has it but I don’t think it supports the session scope.
It only supports static, request (scoped) and transient (a new instance on every request).
We don’t use the aspnet session and we don’t use the aspnet container. The app can use any container.
The Application class is already implementing the IServiceProvider. Is there any option to redirect the GetService calls to our preferred DI container?
Is there any way to get session lifetime to the dotnet DI? What WiseJ callback would be suite best here to start and stop the scope lifetime?
You can use aspnet core service container seamlessly in your code. The scope is whatever aspnet core supports. There is no concept of session though. Transient means that it’s recreated on every request.
Our service container supports sessions, singleton, and transient.
We are not merging our container with aspnet core’s container. Apps can use any service container they prefer, a popular is autofac, for example, but there are others as well.
When you replace an assembly the web server restarts. It’s not our web server and there is no way around it.
There are several ways to “gracefully” kick out users but they are all part of the application’s architecture and outside of Wisej’s scope.
Hi Frank,
Sent you a zipped test case on your email.
Alex
hi Alexander
We have done various checks for the two issues that you comment us, but both issues isn’t occurs.
Here I let you the sample that I used with mixin theme
I use the latest versions of browsers Edge, Chrome and FF and wisej.net 3.0.11
We appreciate if can compare with your test and comment us
Regards
Paul