Click here to Skip to main content
5,790,650 members and growing! (19,116 online)
Email Password   helpLost your password?
General Programming » Bugs & Workarounds » VS.NET IDE Issues     Beginner

IntelliSense Bug In VS.NET

By Tom Welch

Occasionally IntelliSense stops working and you are hard pressed to find out why. Here is one reason that I have discovered.
.NET 1.0, .NET, Dev

Posted: 10 Mar 2002
Updated: 27 Mar 2002
Views: 111,322
Bookmarked: 26 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
16 votes for this Article.
Popularity: 2.66 Rating: 2.21 out of 5
4 votes, 50.0%
1
1 vote, 12.5%
2
2 votes, 25.0%
3
1 vote, 12.5%
4
0 votes, 0.0%
5

Introduction

I have been irritated at times when MS IntelliSense stops working in the middle of programming. Sometimes the whole thing quits and at other times only certain sections of code fail to bring up Auto List Members and Parameter Info. Luckily, today I discovered one reason. Hopefully someone can help determine other situations that cause IntelliSense to fail.

I have grown to depend on IntelliSense when learning new libraries of functions. One such library is the GDI+ library. If you have not yet looked into it, I highly recommend you drop what you are doing and start now. Chances are, you are wasting a lot of time writing code that the GDI+ already does on its own. Anyhow, I was writing a sample application to check out features in the library when my IntelliSense stopped working. Irritated, I decided to figure out why.

After tinkering for a half hour I found one silly line in my code that brought IntelliSense to a stand-still. And you don't even need to be working with GDI+. Any code in VS.NET that uses a comma-list to define an array of object parameters will kill IntelliSense for all code following the definition.

The Problem

The problem is quite specific in this case. An array definition that includes object constructors to create elements confuses VS.NET and shuts down IntelliSense. Such a line is found in the following example.

void OnPaint(HDC hdc)
{
    Graphics graphics(hdc);

    // IntelliSense works here.


    Point arrayPoints[] = {Point(2,3), Point(5,7), Point(10,5)};

    // IntelliSense does NOT work here

}

The Workaround

Unfortunately, the long-hand version of the same code is the way to go. This is really terrible for cases where more elements could be added or removed later. I won't venture a guess as to how many people would like to chide me for suggesting that code be switched as in this work-around. But it seems that if you want IntelliSense to work, you need to do this (or join me in telling Microsoft about this problem and hope the fix it).

void OnPaint(HDC hdc)
{
    Graphics graphics(hdc);

    // IntelliSense works here on graphics object


    Point arrayPoints[3];
    arrayPoints[0] = Point(2,3);
    arrayPoints[1] = Point(5,7);
    arrayPoints[2] = Point(10,5);

    // IntelliSense works just fine

}

A Better Work Around

Special thanks to Anonymous for responding to this article with this work-around. I am adding it to the article so it won't be missed in the messages below. Notice that the array brackets are after the type not the identifier.

void OnPaint(HDC hdc)
{
    Graphics graphics(hdc);

    // IntelliSense works here on graphics object


    Point[] arrayPoints = {Point(2,3), Point(5,7), Point(10,5)};

    // IntelliSense works just fine

}

A Sidenote

Fortunately, this problem does not appear to affect simple arrays.

void OnPaint(HDC hdc)
{
    Graphics graphics(hdc);

    // IntelliSense works here on graphics object


    int oddNumbersLessThanTen[] = {1,3,5,7,9};
    char crookedLetters[] = "BCDGJOPQRSU";

    // IntelliSense works just fine

}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Tom Welch


Supporter

Occupation: Web Developer
Location: United States United States

Other popular Bugs & Workarounds articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 29 (Total in Forum: 29) (Refresh)FirstPrevNext
GeneralBracketsmemberaschwel23:36 8 Feb '07  
GeneralMore CausesmemberSynetech21:22 20 Jan '07  
NewsIDE Quick Watch, Framework 1.1 switch bugmemberReza Aghazadeh21:39 8 Apr '06  
GeneralRe: IDE Quick Watch, Framework 1.1 switch bugmembermkisaacs14:49 7 Nov '06  
GeneralStill alive in VS 2005 Beta2memberNicolasG11:39 2 Jul '05  
GeneralAnother reason why it breakssupporterJohn Cardinal18:05 15 Apr '05  
GeneralIntellisense does not work after "std::somename"sussAnonymous0:18 5 Aug '03  
GeneralIntellisense does not work after "std::somename"sussAnonymous0:14 5 Aug '03  
GeneralSome more infomemberBeliever12:34 30 Jul '03  
GeneralIntellisense for Web ServicesmemberLoai11:11 7 Apr '03  
GeneralIt doesn't work everytime in VC++ 6 too!memberRickard Andersson2:56 1 Apr '02  
GeneralWrong section IMHOmemberNish [BusterBoy]22:06 28 Mar '02  
GeneralRe: Wrong section IMHOmemberTom Welch3:00 29 Mar '02  
GeneralRe: Wrong section IMHOmemberNish [BusterBoy]19:16 29 Mar '02  
GeneralVisual Assist for VS.NETmemberTim Hodgson7:11 17 Mar '02  
GeneralRe: Visual Assist for VS.NETmemberwilliamsu19:03 23 Feb '08  
GeneralNo intelligence in the IntelliSense!memberPaul Selormey23:51 11 Mar '02  
GeneralRe: No intelligence in the IntelliSense!memberTom Welch10:40 12 Mar '02  
GeneralRe: No intelligence in the IntelliSense!memberAnonymous13:47 17 Mar '02  
GeneralRe: No intelligence in the IntelliSense!memberJason Gerard11:07 28 Mar '02  
GeneralRe: No intelligence in the IntelliSense!memberTom Welch11:30 28 Mar '02  
GeneralRe: No intelligence in the IntelliSense!memberMr. Tibbs8:21 1 Apr '02  
GeneralRe: No intelligence in the IntelliSense!memberVictor Boctor19:07 22 Apr '03  
GeneralRe: No intelligence in the IntelliSense! [modified]memberHenry Venn19:10 23 Sep '07  
GeneralRe: No intelligence in the IntelliSense!memberjohnsyd17:28 6 Feb '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 27 Mar 2002
Editor: Chris Maunder
Copyright 2002 by Tom Welch
Everything else Copyright © CodeProject, 1999-2009
Web08 | Advertise on the Code Project