Visual Studio forgets about variable declarations

N

Nick Stansbury

Hi,

I'm not sure where to post this - but I'll try here. I'm encountering
some really weird behaviour in visual studio and I can't work out where it
is coming from.

In various files, seemingly at random, the compiler seems to "forget" about
references declared in the code behind file. So when I build I get a whole
string of errors like "dgdSearchResults is not defined", but if I right
click -> goto definition it goes straight to the declaration in the code
behind file.

Sometimes rebuilding the solution solves the problem, but at other times I
have to delete the declaration and paste it in again somewhere else.

Has anyone encountered this? It seems to be on just one machine (mine) and
not on any of the other developers. It seems to only occur in the one
project.

Nick
 
G

Guest

1. check whether the proctection level of the declared variables is at least
Protected.
2. This problem may also occur if you manually delete the control from the
code behind file and do some operation and again paste the declaration so in
this case, just check whether you have proper event handler in the
InitializeComponent() method.

If still you face the problem then please give some more details, like the
exact Page attribute that you are having in your aspx page.
Whether you are creating control by dragging them from the toolbox or you
are adding them in code.
and at what point of time you are getting this error.


Hope this Helps!
 
N

Nick Stansbury

Hi,
1. check whether the proctection level of the declared variables is at least
Protected.
At least protected - in fact I never change these (I've found
changing it to public is never a good idea because it changes it back to
protected sometimes!) - so I use public properties to get references outside
the page.
2. This problem may also occur if you manually delete the control from the
code behind file and do some operation and again paste the declaration so in
this case, just check whether you have proper event handler in the
InitializeComponent() method.

This doesn't apply. This happens to a number of controls - some of
which haven't been touched in months.
If still you face the problem then please give some more details, like the
exact Page attribute that you are having in your aspx page.
Whether you are creating control by dragging them from the toolbox or you
are adding them in code.
and at what point of time you are getting this error.

The error occurs at compile time - it's a build error i.e.
"DataGrid1 is not defined"

Here is the control attribute : Control Language="vb"
AutoEventWireup="false" Codebehind="RelTypesList.ascx.vb"
Inherits="iirfnew.RelTypesList"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"

Here is an example of a problem control:

Public Class RelTypesList
Inherits GlobalLeague.UI.EntryEditControls.InLineListBase
Implements GlobalLeague.UI.EntryEditControls.ISetupObject


#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents RelTypeAdd1 As RelTypeAdd
Protected WithEvents AddEditPanel1 As System.Web.UI.WebControls.Panel
Protected WithEvents AddNewButton1 As
iirfnew.GlobalLeague.UI.EntryEditControls.AddNewButton
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top