Click here to Skip to main content
12,291,471 members (63,071 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: (untagged)
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 2:27am
thoahn581
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.
GeekBond 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160518.1 | Last Updated 12 Dec 2012
Copyright © CodeProject, 1999-2016
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