Project architecture:
All functions in the system are implemented separately in each dll. The main program loads the corresponding dll of each menu. For some highly repetitive functional code, you can write it in a main dll for other functions to call. You can directly reference the main dll for implementation.
Main.exe main program.
Core. dll public interface and storage cache.
T1.dll function 1
T2.dll function 2
Now the project has the following requirements:
The two functions must be called each other. In T1.dll, click Button1 in T1.MainForm to call the corresponding functions in T2.MainForm in T2.dll, and vice versa. In T2.MainForm, click Button1 to call the T1.dll function.
In this case, a problem occurs. If you reference dll directly in the project, circular references will appear. So we have to find another way.
Solution:
Calling dll using reflection avoids loop reference. Communication between different functions can be implemented through interfaces.
Specific implementation:
In Main.exe, you can use reflection to load various function menus, instantiate various forms, and cache them for other functions to call. The entry and instance are included in the HashTable Core. MenuFactory. htMenu.
Then construct the IInteraction interface.
Interface IInteraction
Public interface IInteraction
{
/// <Summary>
/// Simple interaction
/// </Summary>
Void InterAction ();
/// <Summary>
/// Advanced interaction, parameters can be passed
/// </Summary>
/// <Param name = "args"> </param>
Void InterAction (object [] args );
}