hides inherited member ApplicationInstance

W

Wayne Brantley

VS2005 RTM

Create a web user control to use as a base class for other web user
controls.
Now, create a new web user control, change the class it inherits from to
your base class and compile.
(You must have a <% Register %> so it will see it)

You will get TWO warnings per class like:

Warning 4 'YourUserControl.ApplicationInstance' hides inherited member
'BaseUserControl.ApplicationInstance'. Use the new keyword if hiding was
intended. c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\miniter\3f4ac539\1f8cc57b\App_Web_53s4mlbp.0.cs 29

Warning 3 'YourUserControl.Profile' hides inherited member
'BaseUserControl.Profile'. Use the new keyword if hiding was intended.
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\miniter\3f4ac539\1f8cc57b\App_Web_53s4mlbp.0.cs 23


Problem is the inherited member it is hiding was code generated by the base
class, and the code generated for the inheriting class automatically by
Visual Studio.

This warning does not seem to cause any issues, but would like to get rid of
it, because when I deploy I have to sift through them all.

Any help, future fixes? Should I file as a bug?
 
S

Steven Cheng[MSFT]

Hi Wayne,

Welcome to ASPNET newsgroup.
Regarding on the warning problem you mentioned, I did notice it in some
other scenario. Actually this is a expected behavior due to the new ASP.NET
page/usercontrol's partial class model. All the codebehind defines a
partial class so that the actual compiled class will contains other dynamic
generated properties...
Currently our suggestion will be move those common base page classes or
usercontrol base classes into a single alone class file (e.g put in the
App_Code dir ... ) rather than use existing page or usercontrol's
codebehind(partial class....)

Also, I think you can post this request through the MSDN feedback center:

http://lab.msdn.microsoft.com/productfeedback/default.aspx

but it may need sometime for the dev guys to reconsider it since that'll
cause change to the underlying page structure and compilation model....

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| From: "Wayne Brantley" <[email protected]>
| Subject: hides inherited member ApplicationInstance
| Date: Thu, 15 Dec 2005 17:06:45 -0500
| Lines: 31
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: pcp01076601pcs.midval01.tn.comcast.net 68.59.220.208
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:365214
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| VS2005 RTM
|
| Create a web user control to use as a base class for other web user
| controls.
| Now, create a new web user control, change the class it inherits from to
| your base class and compile.
| (You must have a <% Register %> so it will see it)
|
| You will get TWO warnings per class like:
|
| Warning 4 'YourUserControl.ApplicationInstance' hides inherited member
| 'BaseUserControl.ApplicationInstance'. Use the new keyword if hiding was
| intended. c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
| Files\miniter\3f4ac539\1f8cc57b\App_Web_53s4mlbp.0.cs 29
|
| Warning 3 'YourUserControl.Profile' hides inherited member
| 'BaseUserControl.Profile'. Use the new keyword if hiding was intended.
| c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
| Files\miniter\3f4ac539\1f8cc57b\App_Web_53s4mlbp.0.cs 23
|
|
| Problem is the inherited member it is hiding was code generated by the
base
| class, and the code generated for the inheriting class automatically by
| Visual Studio.
|
| This warning does not seem to cause any issues, but would like to get rid
of
| it, because when I deploy I have to sift through them all.
|
| Any help, future fixes? Should I file as a bug?
|
|
|
 
W

Wayne Brantley

Steven,
Partial class - yep, that is the exact problem. However, let me be
clear on what you are saying.

I have an .ascx file with NOTHING in it but the control tag.
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="BaseEdit.ascx.cs"
Inherits="Common_BaseEdit" %>

I then have code behind that inherits from
System.Web.UI.UserControl

That causes some code behind to be generated.

You are saying, I can just throw away the .ascx file (which stops the code
from being generated) and have the classes inherit from my base class
anyway? If this is true, the generated code is USELESS, even though I have
looked at it and it generates some constructors, calls to base class
methods, etc. Further if that is true, then it would be a SIMPLE change
for your dev guys, because if an ascx file is empty (only contains the
control tag) NO code generation is necessary!!!!! - (the ascx file cannot
contain any controls for base web user controls anyway, so that is always
the case)

If that is what you are saying, then I can certainly do that to stop these
warning methods (or better yet, I will move that file to an existing
supporting class project library).
 
S

Steven Cheng[MSFT]

Thanks for your response Wayne,

Sorry if I haven't made things clear, for the following:

=====================================
You are saying, I can just throw away the .ascx file (which stops the code
from being generated) and have the classes inherit from my base class
anyway? If this is true, the generated code is USELESS, even though I have
looked at it and it generates some constructors, calls to base class
methods, etc
======================================
Actually, what I want to mean is defining a separate base UserControl
class(derived from Usercontrol) and there is no ascx file associated with
it, in other words, it is just as a normal component class in the App_Code
folder.... Then, our other concrete ascx usercontrol's codebehind
UserControl class will derive from that class..... So to avoid those
warning(some autogenerated properteis being hidden), we have to avoid make
our ascx usercontrol's codebehind class derived from another ascx
usercontrol's codebehind class( being autocompiled through partial
class....)....

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| From: "Wayne Brantley" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: Re: hides inherited member ApplicationInstance
| Date: Fri, 16 Dec 2005 10:03:23 -0500
| Lines: 120
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: pcp01076601pcs.midval01.tn.comcast.net 68.59.220.208
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:365323
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Steven,
| Partial class - yep, that is the exact problem. However, let me be
| clear on what you are saying.
|
| I have an .ascx file with NOTHING in it but the control tag.
| <%@ Control Language="C#" AutoEventWireup="true"
CodeFile="BaseEdit.ascx.cs"
| Inherits="Common_BaseEdit" %>
|
| I then have code behind that inherits from
| System.Web.UI.UserControl
|
| That causes some code behind to be generated.
|
| You are saying, I can just throw away the .ascx file (which stops the
code
| from being generated) and have the classes inherit from my base class
| anyway? If this is true, the generated code is USELESS, even though I
have
| looked at it and it generates some constructors, calls to base class
| methods, etc. Further if that is true, then it would be a SIMPLE change
| for your dev guys, because if an ascx file is empty (only contains the
| control tag) NO code generation is necessary!!!!! - (the ascx file
cannot
| contain any controls for base web user controls anyway, so that is always
| the case)
|
| If that is what you are saying, then I can certainly do that to stop
these
| warning methods (or better yet, I will move that file to an existing
| supporting class project library).
|
|
| | > Hi Wayne,
| >
| > Welcome to ASPNET newsgroup.
| > Regarding on the warning problem you mentioned, I did notice it in some
| > other scenario. Actually this is a expected behavior due to the new
| > ASP.NET
| > page/usercontrol's partial class model. All the codebehind defines a
| > partial class so that the actual compiled class will contains other
| > dynamic
| > generated properties...
| > Currently our suggestion will be move those common base page classes or
| > usercontrol base classes into a single alone class file (e.g put in the
| > App_Code dir ... ) rather than use existing page or usercontrol's
| > codebehind(partial class....)
| >
| > Also, I think you can post this request through the MSDN feedback
center:
| >
| > http://lab.msdn.microsoft.com/productfeedback/default.aspx
| >
| > but it may need sometime for the dev guys to reconsider it since that'll
| > cause change to the underlying page structure and compilation model....
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| > --------------------
| > | From: "Wayne Brantley" <[email protected]>
| > | Subject: hides inherited member ApplicationInstance
| > | Date: Thu, 15 Dec 2005 17:06:45 -0500
| > | Lines: 31
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-RFC2646: Format=Flowed; Original
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: pcp01076601pcs.midval01.tn.comcast.net
68.59.220.208
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:365214
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | VS2005 RTM
| > |
| > | Create a web user control to use as a base class for other web user
| > | controls.
| > | Now, create a new web user control, change the class it inherits from
to
| > | your base class and compile.
| > | (You must have a <% Register %> so it will see it)
| > |
| > | You will get TWO warnings per class like:
| > |
| > | Warning 4 'YourUserControl.ApplicationInstance' hides inherited member
| > | 'BaseUserControl.ApplicationInstance'. Use the new keyword if hiding
was
| > | intended. c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary
| > ASP.NET
| > | Files\miniter\3f4ac539\1f8cc57b\App_Web_53s4mlbp.0.cs 29
| > |
| > | Warning 3 'YourUserControl.Profile' hides inherited member
| > | 'BaseUserControl.Profile'. Use the new keyword if hiding was intended.
| > | c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
| > | Files\miniter\3f4ac539\1f8cc57b\App_Web_53s4mlbp.0.cs 23
| > |
| > |
| > | Problem is the inherited member it is hiding was code generated by the
| > base
| > | class, and the code generated for the inheriting class automatically
by
| > | Visual Studio.
| > |
| > | This warning does not seem to cause any issues, but would like to get
| > rid
| > of
| > | it, because when I deploy I have to sift through them all.
| > |
| > | Any help, future fixes? Should I file as a bug?
| > |
| > |
| > |
| >
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top