"ControlType is not accessible in this context because it is Friend" error in an inherited Windows Form application that inherits the form in another application (814319)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# 2005, Express Edition
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
Beta Information This article discusses a Beta release of a Microsoft
product. The information in this article is provided as-is and is subject to
change without notice.
No formal product support is available from
Microsoft for this Beta product. For information about how to obtain support
for a Beta release, see the documentation that is included with the Beta
product files, or check the Web location from which you downloaded the release.
SYMPTOMS You create an inherited Windows form in an application by
inheriting the form in another application, such as a class library. Next, you
add the code that handles the events of the inherited form controls. When you
build the project, you may receive the following error message: 'ClassLibraryName.FormName.Friend Dim WithEvents ControlName As
System.Windows.Forms.ControlType' is not accessible in this context because it
is 'Friend' CAUSEThis problem occurs because the control in the referenced
class library is declared with Friend modifiers. You cannot inherit Friend variables from one assembly to another. Therefore, you cannot add
handlers for Friend controls from another library in the inherited
form.WORKAROUNDTo work around this problem, set the access modifiers of the
control as Public or Protected in
the base form. To do this, follow these steps:
- Open the class library project in Microsoft Visual Studio
.NET or in Microsoft Visual Studio 2005.
- Right-click Control on the form, and then click
Properties.
- In the Properties window, locate the
Modifiers property.
- From the Modifiers list, click to select
Public or Protected.
- On the Build menu, click Build
Solution.
STATUS This
behavior is by design.
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005applies kbvs2005swept kbWebForms kbForms kbInheritance kbControl kbProperties kbEvent kbImport kbprb KB814319 kbAudDeveloper |
---|
|