I have a windows forms project in VS 2003 which I migrated to VS 2005 after migration I found out that the following code does not work after migration
using System;
using
System.Drawing;
using
System.Collections;
using
System.ComponentModel;
using
System.Windows.Forms;
using
System.Data;
using
System.Reflection;
......
......
private
void OpenForm(string strName)
{
....
string strModName = "FX.FORM.UI.REPORT.FRMRPT"; // this just an eample the value is fetched from the database
Form objCurrFrm = (Form) Activator.CreateInstance(Type.GetType(strModName)); <--fails
objCurrFrm.GetType().InvokeMember("Show",BindingFlags.Default |BindingFlags.InvokeMethod,null,objCurrFrm,new object[]{});
....
}
......
.....
this is becaue Type.GetType is returning null.
I tried using the Assembly.GetTyp but I am getting an error as "Cannot load file or assembly ... or one of its dependencies"
But if I directly do
Form objCurrFrm = new FX.FORM.UI.REPORT.FRMRPT();
It works fine.
Iin my solution I have a login form which is a seperate project. This project has ref. to the main project which biuld the menu etc and rest of each are seperate project like sub project of the main all this individual project are being ref. by the main project.
After the login in successful the main project is loaded. This has the menu which is built from the database the dll names are fetched from the database. Once the menu is clicked the corrosponding dll has to be loaded.
Does anyone has any idea how to solve it.