473,508 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Visual Studio forgets about variable declarations

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
Nov 19 '05 #1
2 1333
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!

"Nick Stansbury" wrote:
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

Nov 19 '05 #2
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.AddNewBu tton
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

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2568
by: gerd | last post by:
Hello, I want to port an MFC Application from Visual Studio 6 MFC application to Visual C++ 2005 express edition beta. While building i get following error: ------ Build started: Project:...
0
774
by: gerd | last post by:
Hello, I want to port an MFC Application from Visual Studio 6 MFC application to Visual C++ 2005 express edition beta. While building i get following error: ------ Build started: Project:...
65
18963
by: xuanbai98 | last post by:
I want to know the current support status of c99 on Microsoft Visual Studio. Anyone know whether Microsoft has any plan to support c99 on Visual Studio? Thanks, Xuan
4
1777
by: Steve Richter | last post by:
using visual studio 2003 for my asp.net projects ... Once I undock the property window to get a better look at things, I cant dock it back where it came from. Can someone tell me how to redock...
8
2194
by: HELLO $$$ | last post by:
To those who are familiar to MS Visual studio : I have recently Visual Studio 2005. Please can any body tells me , when I write a code: How can I separate the files of such code from the Studio...
4
6522
by: kurt.kurtsmith | last post by:
I am trying to import a tlb from a COM server(exe) I wrote with the following statement: #import "C:\\em2\\EM\\src\\core\\UMOSEFax\\Debug\\UMOSEFax.tlb" no_namespace auto_search the tlh and...
4
2625
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
4
1827
by: Juha Nieminen | last post by:
Unknownmat wrote: VS2005 has a bug related to this. When you use size_t, it internally converts it to 'unsigned int'. In some situations it forgets that the type was actually size_t and only...
0
7295
jwwicks
by: jwwicks | last post by:
Introduction This tutorial describes how to use Visual Studio to create a new C++ program, compile/run a program, resume work on an existing program and debug a program. It is aimed at the...
0
7227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7331
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.