Hi Salam,
Based on my understanding, you have Control Library project which contains
a UserControl and a Class Library project and some Windows Application
projects in a solution.
If you add add a reference to the Control Library project in the Class
Library project and then add a reference to the Class Library project in
the Windows Application projects and then add the UserControl on the form,
the UserControl doesn't appear on the form when the application is run.
If I'm off base, please feel free to let me know.
I performed a test based on your description, but didn't reproduce the
problem on my side. The steps of my test are as follows:
1. Create a solution and add a Control Library project and a Class Library
project and a Windows Application project to the solution. Add a
UserControl in the Control Library project.
2. Derive the Class1 in the Class Library project from the UserControl in
the Control Library project:
namespace ClassLibrary1
{
public class Class1:WindowsControlLibrary1.UserControl1
{
}
}
3. Build the solution.
4. Drag the UserControl from Toolbox and drop it onto the form in the
Windows Application project. A reference to the Control Library project is
added to the Windows Application project automatically. Build and run the
application and the UserControl appears on the form.
5. Remove the reference to the Control Library project from the Windows
Application project and add a reference to the Class Library project in the
Windows Application project.
6. Add the following lines of code in the Form's Load event handler to add
the UserControl on the form dynamically:
private void Form1_Load(object sender, EventArgs e)
{
ClassLibrary1.Class1 mycontrol = new ClassLibrary1.Class1();
this.Controls.Add(mycontrol);
}
7. Build the solution. An compilation error occurs:
The 'WindowsControlLibrary1.UserControl1' is defined in an assembly that is
not referenced. You must add a reference to the assembly "...".
Is there any difference between your solution and mine?
Sincerely,
Linda Liu
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.