Click here to Skip to main content
15,867,308 members
Articles / .NET
Article

IntelliSense Bug In VS.NET

Rate me:
Please Sign up or sign in to vote.
2.07/5 (9 votes)
27 Mar 20022 min read 164.5K   30   30
Occasionally IntelliSense stops working and you are hard pressed to find out why. Here is one reason that I have discovered.

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


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalgood find Pin
Donsw21-Aug-09 17:15
Donsw21-Aug-09 17:15 
GeneralBrackets Pin
aschwel8-Feb-07 22:36
aschwel8-Feb-07 22:36 
GeneralMore Causes Pin
Synetech20-Jan-07 20:22
Synetech20-Jan-07 20:22 
NewsIDE Quick Watch, Framework 1.1 switch bug Pin
Reza Aghazadeh8-Apr-06 20:39
Reza Aghazadeh8-Apr-06 20:39 
GeneralRe: IDE Quick Watch, Framework 1.1 switch bug Pin
mkisaacs7-Nov-06 13:49
professionalmkisaacs7-Nov-06 13:49 
GeneralStill alive in VS 2005 Beta2 Pin
NicolasG2-Jul-05 10:39
NicolasG2-Jul-05 10:39 
GeneralAnother reason why it breaks Pin
Member 9615-Apr-05 17:05
Member 9615-Apr-05 17:05 
GeneralIntellisense does not work after "std::somename" Pin
Anonymous4-Aug-03 23:18
Anonymous4-Aug-03 23:18 
GeneralIntellisense does not work after "std::somename" Pin
Anonymous4-Aug-03 23:14
Anonymous4-Aug-03 23:14 
GeneralSome more info Pin
Believer30-Jul-03 11:34
Believer30-Jul-03 11:34 
Thanks for the article Tom. At one stage I thought I was the only one having this problem. I did a re-install of VS.Net thinking perhaps that something might have gone wrong with my VS.NET 2003 update. Of course, the problem still continues.

MS states in VS.Net that intellisense may become unavailable in some situations including:

There are certain cases when the IntelliSense options may not work as you expect.

There is a code error above the cursor

If there is an incomplete function or other coding error above the location of the insertion point, IntelliSense may be unable to parse the code elements and therefore will not work. You can comment out the applicable code to enable IntelliSense again.


However I've noticed that when Intellisense fails, even when you fix your code while editing it still doesn't come back. The symptoms are the same as Tom explained: all the colored fonts disappear, no autolist and so forth. Worst still, try to do a copy and paste and the IDE comes back with the crude message: VS IDE: Copy/Paste error. If you had done a cut/paste you might as well kiss goodbye to what you had put in the clipboard. The IDE becomes unable to perform any Undo/Redo. Yesterday, I kept working while the intellisense was gone, and got the message saying I had to save my work and exit the VS IDE :-Dbecause a memory corruption had occurred!

I've been coding in both C# and VB.net and noticed that this behaviour only happens with C#, and not with VB.

The only way I've known to restore the IDE and get Intellisense back on track is by switching between the code screen and design screen, if you're working on a form.

I've no doubt MS will fix the problem. However I find a bit disappointing that a tool like VS.Net being touted as a high-level productivity tool can make us waste precious programming time trying to cope with problems like that.

Having said all that, overall I am very satisfied with MS efforts in making VS.Net a reality and believe the solution of the problem will come soon.
GeneralIntellisense for Web Services Pin
Loai7-Apr-03 10:11
Loai7-Apr-03 10:11 
GeneralIt doesn't work everytime in VC++ 6 too! Pin
Rickard Andersson201-Apr-02 1:56
Rickard Andersson201-Apr-02 1:56 
GeneralWrong section IMHO Pin
Nish Nishant28-Mar-02 21:06
sitebuilderNish Nishant28-Mar-02 21:06 
GeneralRe: Wrong section IMHO Pin
Tom Welch29-Mar-02 2:00
Tom Welch29-Mar-02 2:00 
GeneralRe: Wrong section IMHO Pin
Nish Nishant29-Mar-02 18:16
sitebuilderNish Nishant29-Mar-02 18:16 
GeneralVisual Assist for VS.NET Pin
Tim Hodgson17-Mar-02 6:11
Tim Hodgson17-Mar-02 6:11 
GeneralRe: Visual Assist for VS.NET Pin
williamsu23-Feb-08 18:03
williamsu23-Feb-08 18:03 
GeneralNo intelligence in the IntelliSense! Pin
Paul Selormey11-Mar-02 22:51
Paul Selormey11-Mar-02 22:51 
GeneralRe: No intelligence in the IntelliSense! Pin
Tom Welch12-Mar-02 9:40
Tom Welch12-Mar-02 9:40 
GeneralRe: No intelligence in the IntelliSense! Pin
17-Mar-02 12:47
suss17-Mar-02 12:47 
GeneralRe: No intelligence in the IntelliSense! Pin
Jason Gerard28-Mar-02 10:07
Jason Gerard28-Mar-02 10:07 
GeneralRe: No intelligence in the IntelliSense! Pin
Tom Welch28-Mar-02 10:30
Tom Welch28-Mar-02 10:30 
GeneralRe: No intelligence in the IntelliSense! Pin
Mr. Tibbs1-Apr-02 7:21
Mr. Tibbs1-Apr-02 7:21 
GeneralRe: No intelligence in the IntelliSense! Pin
Victor Boctor22-Apr-03 18:07
Victor Boctor22-Apr-03 18:07 
GeneralRe: No intelligence in the IntelliSense! [modified] Pin
Henry Venn23-Sep-07 18:10
Henry Venn23-Sep-07 18:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.