Click here to Skip to main content
11,428,497 members (61,919 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WinForm
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 11-Dec-12 3:27am
thoahn567
Comments
joshrduncan2012 at 11-Dec-12 9:38am
   
Have you tried importing that .dll to your project in Visual Studio?
thoahn at 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.
GeekBond at 11-Dec-12 11:09am
   
Can you show the code that finds all the form? Don't seem to understand what you mean.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

public List<form> FindAllFormsOnProject()
{
List<form> foundForms = new List<form>();
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.</form></form></form>
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.150428.2 | Last Updated 12 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100