Click here to Skip to main content
Click here to Skip to main content

IntelliSense Bug In VS.NET

By , 27 Mar 2002
 

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
Software Developer (Senior)
United States United States
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralIntellisense for Web ServicesmemberLoai7 Apr '03 - 10:11 

This is mostly unrelated to the intellisense problem(s) discussed here, but perhaps some of you have faced this before.
 
My problem is in providing custom intellisense support to a web service consumer through using the self-documenting XML feature of VS.NET (for C# and J#). This works fine when compiling and then referencing a documented DLL with an XML file of the same name; however there’s no DLL in the case of a web service only an ASMX file to reference, with a WSDL downloaded on the client-side. VS.NET does depend on this WSDL file to provide its intellisense of any web service (listing members for a certain type, etc…), yet I’m not being able provide my own descriptions and remarks as well.
 
I’d be more than grateful for any help on this issue.
 
Thanks,
L.

GeneralIt doesn't work everytime in VC++ 6 too!memberRickard Andersson1 Apr '02 - 1:56 
I've seen this bug before too, but it was in VC++ 6 and not in the .NET version. It's very annoying! Mad | :mad:
 
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
 
------------------------------------
GeneralWrong section IMHOmemberNish [BusterBoy]28 Mar '02 - 21:06 
This article should have come in the Bugs and Workarounds section and not in the .NET section.
 
You might want to move it there, to save the editors some time.
 
Nish Smile | :)
 

I am the Keyboard Smasher


GeneralRe: Wrong section IMHOmemberTom Welch29 Mar '02 - 2:00 
I am using the Article Submission Wizard and the "Modify this Article" tools and do not see any "Bugs and Workarounds" section. The closes match I found was .NET.
 
If anyone knows what I am missing, please let me know in explicit detail.
 
Boy. How ya gonna keep 'em down on the farm once they seen Karl Hungus.
<p style="text-align: right; margin: 0px;">- The Dude :cool:</p>

GeneralRe: Wrong section IMHOmemberNish [BusterBoy]29 Mar '02 - 18:16 
Hello Tom
 
I guess you are right. I remember Chris saying that the Bugs and Workaround section will not be a section in the submission wizard.
 
Nish
 

Heart | [heart] Has anyone seen my sig?Heart | [heart]


GeneralVisual Assist for VS.NETmemberTim Hodgson17 Mar '02 - 6:11 
Get Visual Assist by WholeTomato.com and you won't have these problems any longer.
 
Smile | :)
GeneralRe: Visual Assist for VS.NETmemberwilliamsu23 Feb '08 - 18:03 
cool
GeneralNo intelligence in the IntelliSense!memberPaul Selormey11 Mar '02 - 22:51 
Grab visual assist and forget that crap if you cherish your time. Funny we have to wait for 3 years for this.
 
They are beta testing VS.NET, but I do not have VS.NET yet and cannot say much, in VS 6.0, it is a great time saver.
 
Best regards,
Paul.

 
Paul Selormey, Bsc (Elect Eng), MSc (Mobile Communication) is currently Windows open source developer in Japan.
GeneralRe: No intelligence in the IntelliSense!memberTom Welch12 Mar '02 - 9:40 
I decided to try the beta of Visual Assist for .NET and it appears to be pretty stable. It does not have the problems that the built-in IntelliSense displays.
 
Also, there is another solution to the problem I presented.
 
While this line messes up Intellisense:
Point destPoints[] = {Point(200, 20), Point(110, 100), Point(250, 60)};
This one does not:
Point[] destPoints = {Point(200, 20), Point(110, 100), Point(250, 60)};

GeneralRe: No intelligence in the IntelliSense!memberAnonymous17 Mar '02 - 12:47 
Theres another better solution:
 
Point destPoints[] = {Point(200, 20), Point(110, 100), Point(250, 60),};
 
Note the extra comma at the end Point(250, 60).

GeneralRe: No intelligence in the IntelliSense!memberJason Gerard28 Mar '02 - 10:07 
Why would you use
Point destPoints[]
over
Point[] destPoints
anyway?
 
I mean destPoints is a Point Array so why not declare it they way you say it?
 
I'm just anal about those things I guess.
 
Jason Gerard
GeneralRe: No intelligence in the IntelliSense!memberTom Welch28 Mar '02 - 10:30 
Perhaps it is my background. I came from the VB world (placing the array notation after the identifier.
 
Dim aPoints() As POINTL
... etc ...
 

And I also see the style that causes the problem a LOT... On-line, in books, and in magazines. This is probably where I really picked it up.
 
I read: Point destPoints[]
As: destPoints is an array of type Point
 
It just seems natural. Anyway, I am making an effort to write it the other way in the future. Thanks for pointing this out.
 


 
Boy. How ya gonna keep 'em down on the farm once they seen Karl Hungus.

- The Dude Cool | :cool:


GeneralRe: No intelligence in the IntelliSense!memberMr. Tibbs1 Apr '02 - 7:21 
I agree, it should be Point[] destPoints... and I also come from a VB background.
 
This brings up a really important issue, one that made me avoid C++ for so long. Common syntactical style. Too many ways to write the same thing, and it's done differently every time. If you look at C++ programs from the same programmer you will see stuff like this:
 

byte* blah;
byte * blahblah;
byte *blahblahblah;

 
They all mean the same thing but it gets confusing when you are trying to read it. So if everyone will please write code the way I want them to I would greatly appreciate it. Thank you.
 
"Faith is believing in something you know isn't true."
- Arthur C. Clark
GeneralRe: No intelligence in the IntelliSense!memberVictor Boctor22 Apr '03 - 18:07 
Just to get you more confused:
 
The following mean the same thing:
const char *
char const *

 
While those don't:
char const *
char * const

 
Regards,
Victor Poke tongue | ;-P
 


 
phpWebNotes is a page annotation system modelled after php.net.
http://webnotes.sourceforge.net/demo.php[^]
GeneralRe: No intelligence in the IntelliSense! [modified]memberHenry Venn23 Sep '07 - 18:10 
Hey - my $0.01 is that while its been awhile, I actually miss C++ (stuck using VB.NET) but this used to just annoy me: I was never great at C. I may be wrong but is...
 
const char * var
 
an 8bit pointer to a constant value
while
 
char* const
 
is assigned when declared, and always points to the same memory address? =
 
D'Whizz!
 
. . . . . <--=_~.|-|./^\.\/.~_=--> . . . . .
 
*******************************************
GeneralRe: No intelligence in the IntelliSense!memberjohnsyd6 Feb '08 - 16:28 
Yes that's my understanding -- const always affects what comes immediately before it.
so
char const * var;
means the char's which `var` is pointing to are constant, and
char * const var;
means the pointer to those char's is constant.
 
Special case: When const comes before any type qualifiers, it is the same as if it came straight after the first type qualifier.
so
const char * var;
is same as
char const * var;
GeneralRe: No intelligence in the IntelliSense!memberThomas Eyde11 Jul '02 - 22:34 
I wasn't aware
Point destPoints[];
is possible. I didn't think of the typing as I read the article.
 
C# documentation suggests
Point[] destPoints;
 


GeneralRe: No intelligence in the IntelliSense!sussAnonymous6 Sep '02 - 7:56 
The original code, as others pointed out, is not valid; ie. it won't compile. So really, isn't this entire article invalid?
GeneralRe: No intelligence in the IntelliSense!memberTom Welch7 Sep '02 - 19:17 
Oh, it compiles alright.
 
--
If it starts to make sense, you're in a cult.
GeneralRe: No intelligence in the IntelliSense!memberJohn Cardinal15 Apr '05 - 17:02 
Actually the dirty secret of Visual Assist is that for c# it uses the built in intellisense so if there is a problem with the built in one Visual Assist has the exact same problem as I discovered when getting fed up with the intellisense that's built in breaking all the time.
 

 


"If there is a God, atheism must seem to Him as less of an insult than religion." - Edmond de Goncourt

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 28 Mar 2002
Article Copyright 2002 by Tom Welch
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid