Separate front-end and back-and from executable

Asked

Viewed 118 times

0

My idea is to separate the application into three distinct files, in the file MinhaAppBackend.dll, will be, as the name suggests, all classes and other elements that are part of the back end of the application (Model, Viewmodel, Daos, etc). In the archive MinhaAppFrontend.dll will be all related to the GUI (WPF) part of the application (main window, dialogues, daughter windows, etc). The archive MinhaApp.exe will only be the starting point of the application, it will only be responsible for calling the main window that is in the library MinhaAppFrontend.dll. Contrary to what most do it is to leave the front end in the file .exe with the method main generated at compile time. In my case it will be "donkey", it will have the only function to be the start of the application.

For the front-end, my idea is a project of the kind WPF User Control Library, compiling GUI (WPF) elements for a dll. The project that will generate the file .exe refers to dll containing the front-end and "calls" the main window. I have not yet implemented this "solution model", just idealized.

What I want?

To know the opinion of the class about my idea of "solution design", that is, if it can bring me some problem or some extra difficulty or if it can be incompatible with the MVVM (analyzing without putting a hand in the dough I think not). I also want to know what the main method for loading and displaying the main window is on dll.

I’m posting the link for a demo project, in case someone needs to see in practice what I want. The solution has two designs one Design is one Console Application that generates one executable the other is one WPF User Control Library which generates a window in a dll.

2 answers

1

Matheus in the case of WPF seeks to work with MVVM, since WPF does not work with "Controllers". You can even use the same principle of the MVC structure, but to do so create directories that "shelter" the layers. To use this "window" within the Mainwindow use the concept of Usercontrols where you can create components and load them into the Window.

  • Hold on, I don’t get it. I put this line where ( Process.Start("caminho do .exe"); ) ?

  • if you put it inside Mainwindow.xaml.Cs it will run the file . exe

  • I had understood your question differently. Take a look at the correction.. forgive me

  • You still don’t understand, there is no other window, this is the only and main window of the application. The difference is that it is in a Class Library (DLL) project. Main. In the project Main there is nothing, no GUI, no business rule, access to data, nothing. Main will only be responsible for "starta" the application. Ie, call the main window of the program which in case is MainWindows and is in a DLL.

  • Sorry for the huge delay in making a return, I really had to stop this project for a while. I realized that this question was not very well understood, so I edited the whole question and still shared a demo project.

0

You must make the project Main receive references of the other projects, hence the Main will can access all public items of other projects.

Within the project Main, click on References and in Add Reference.

Área de referências do projeto

In the window that will open, choose Projects > Solution in the menu on the left and then mark the projects you want to reference in the Main

Projetos para referenciar

  • Sorry for the huge delay in giving a return, I really had to stop this project for a while. Exact, this I have done. I need to know how the method main should call the wpf window that is on dll. I realized that this question was not very well understood, so I edited the whole question and still shared a demo project.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.