How to create Global.asax in a Winform application? - WITH#/. NET

I am trying to create Global.asax in Winform. I could do this in ASP.NET, but I could not find a way for Windows Application. Any help would be appreciated.

I have a singleton class called DataAccessLayer, I need to instantiate it only once, so I can easily call its method / properties anywhere in the application.

+3
source share
5 answers

You cannot add Global.asaxwinform to the application in the same way you cannot add a page aspx. They are parts of web forms.

Global.asax - . Main() winform.

+8

, Global.asax Asp.NET. ? .

, global.asax - . , . , , , .

+6

, Global.cs .

+2
source

My DataAccessLayer class is set to Singleton (sealed)

0
source

It looks like you want to load global variables and then execute and unload when the program ends.
Use a static class, such as the mentioned Oded.
You can also see the Application.ApplicationExit event for the equivalent of Application_End and Session_End   http://msdn.microsoft.com/en-us/library/system.windows.forms.application.applicationexit.aspx

0
source

Source: https://habr.com/ru/post/1745853/


All Articles