Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created a custom label control for winforms on my C# project and exported the control as dll file. There is some methods which find all forms on my project and those methods don't work on project where imported dll file. How can i find all forms the last project?
Posted
Comments
joshrduncan2012 11-Dec-12 9:38am    
Have you tried importing that .dll to your project in Visual Studio?
thoahn 11-Dec-12 9:53am    
yes i have. Due to .dll file has already created in same proejct, worked on my project. But it doesn't work in another project due to can not reach all forms on that project.
Akinmade Bond 11-Dec-12 11:09am    
Can you show the code that finds all the form? Don't seem to understand what you mean.

You can add the dll as a reference to another project and reuse all the public classes. In your case, check if you have added the reference and if the control is set as public.
 
Share this answer
 
public List FindAllFormsOnProject()
{
List foundForms = new List();
Type[] typesOnProject = Assembly.GetExecutingAssembly().GetTypes();
foreach (Type tip in typesOnProject )
{
if (tip.BaseType == typeof (Form))
{
try
{
Form frm = (Form)Activator.CreateInstance(tip);
foundForms.Add(frm);
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}
}
}
return foundForms;
}


Method what i use to find all forms in my project. As i said, doesn't work on other project that includes .dll file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900