-
-
Save Scribbio/f823a4e5bf397a0742143ba1d19640af to your computer and use it in GitHub Desktop.
LOADING ASSETS FROM REFERENCED PROJECTS AND DLLs DYNAMICALLY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| LOADING ASSETS FROM REFERENCED PROJECTS DYNAMICALLY | |
| --CONTEXT------------------------------------------------------------------------------------------------- | |
| For example, you have a winforms application and you reference other winform projects which deal | |
| with specific sections of your application. | |
| These sections are accessible through a single menu, in our example a listview (named LvAdministration) | |
| We can load a particular form from one of these projects depending on the user's selection during run-time. | |
| The listview has two columns, represented by "|", the second is hidden. | |
| FIGURE 1 - Form ADMINISTRATION | |
| |----------------------------------------------------------| | |
| | ADMINSTATION | | |
| |----------------------------------------------------------| | |
| | | | |
| | |Listview | | |
| | ---------------------------------- | | |
| | |Add Users | UserForms| | | |
| | |Delete Users | UserForms| | | |
| | |Manage Users | UserForms| | | |
| | |Add Invoice | FinanceForms| | | |
| | |Manage Payrolls | FinanceForms| | | |
| | |Order Stock | UserForms| | | |
| | |Delete Stock | UserForms| | | |
| | |Manage Users | UserForms| | | |
| | | | |
| ------------------------------------------------------------ | |
| --HOW TO DO IT------------------------------------------------------------------------------------------------- | |
| Handle the listview's click event. | |
| Private Sub LvAdministation_Selection(ByVal eventSender As System.Object, ByVal e As EventArgs) | |
| string dllName = "UserForms"; | |
| var loadedClassFromDll = Assembly.Load(dllName).CreateInstance(strObjTmp); | |
| loadedClassFromDll.Show(); | |
| Dim nspc As String = strObjTmp.Substring(0, strObjTmp.LastIndexOf("."c)) | |
| Dim o As Object = Nothing | |
| clsObjet = Assembly.Load(nspc).CreateInstance(strObjTmp) | |
| clsObjet.frmFenMDI = FMdiBal | |
| strTable = lvwMenu.clsSubItems("FctCod").Text | |
| Select Case strTypeFonction | |
| Case "Consultation" | |
| clsObjet.Consulter(strTable) | |
| Case "Proposition" | |
| clsObjet.Saisir(strTable) | |
| Case "Hors Proposition" | |
| clsObjet.Saisir(strTable, strAcces) | |
| Case "Tables de référence" | |
| clsObjet.Table(strTable, strAcces) | |
| Case "Impression" | |
| clsObjet.Imprimer(strTable) | |
| End Select | |
| End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment