Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 No IntelliSense on COM objects using #import

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
wlopez Posted - Feb 24 2006 : 1:28:57 PM
When using com objects in vc++ projects I notice that there is no IntelliSense help. Im not sure if this happens only when using the #import statement and smart pointers. When using the #import statement Visual Studio adds two files in the project a *.tlh and *.tli.

#import <msado15.dll> no_namespace rename("EOF", "AdoEOF")
generates msado15.tli and msado15.tlh

Is there something I can do to get the intellisense to work with COM objects? I have Visual Assist X. Any help you can provide is appreciated.



12   L A T E S T    R E P L I E S    (Newest First)
support Posted - Aug 12 2006 : 11:14:47 PM
Build 1532 has better support for COM smart pointers.
feline Posted - Mar 06 2006 : 5:26:15 PM
bugfix is quite right about when pCon goes out of scope. it is possible the line:

pCon->Close();

is relevant to this question, but since i am happily ignorant of COM programming i really don't know.

the fact that when pasting this code into a new VS2005 project and compiling it results in a crash also supports the idea that there is a bug in the code. however this seems to be slightly beside the point.

what most interests me at the moment is that i have seen this work, and i have also seen this fail. VA's parser is unlikely to care about pCon going out of scope at the wrong point.

using VS2003 i have just created a new default C++ console application. after replacing the main function with the code from the top of this file "_ConnectionPtr" is shown in blue italic text, this is definitely a known type.

i am getting a completion listbox on "pCon." spontaniously
and i am getting a completion listbox on "pCon->" after pressing CTRL-SPACE.

wlopez you have said you are using 3 different IDE's, what results are you getting when you try this code in VS2005 and VS2003? can you reproduce this difference in behaviour that i am seeing?

either way, something very odd is happening here

case=997


wlopez if you think that the IDE's intellisense may be giving you some results here try turning on the option:

VA Options -> text editor -> listboxes -> get content from default intellisense

for me this stops all suggestions, but you may get better results.
bugfix Posted - Mar 06 2006 : 2:00:55 PM
int main()
{
CoInitialize(NULL);

_ConnectionPtr pCon; <-- this is a smart ptr objetct
...
CoUninitialize();
}

Now tell me when pCon is destroyed. It's destroyed when leaving scope and that's happening after CoUninitialize().
Get a c++ book:)

wlopez Posted - Mar 06 2006 : 1:48:43 PM
I dont see what your looking at. Here is the code.

#include <stdio.h>
#import "c:\\program files\\common files\\system\\ado\\msado15.dll" rename ( "EOF", "adoEOF" ) no_namespace
#define COL(rs,x) _bstr_t(rs->Fields->Item[_variant_t(x)]->Value)

int main()
{
CoInitialize(NULL);

_ConnectionPtr pCon;
pCon.CreateInstance(__uuidof(Connection));

// Generic connection to Northwind database
_bstr_t cnStr("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=(local)");

if(SUCCEEDED(pCon->Open(cnStr, "", "", -1)))
{
_bstr_t sql("select * from customers");

_RecordsetPtr rs = pCon->Execute(sql, NULL, NULL);
while(!rs->adoEOF)
{
printf("\\n%s", (char*)COL(rs, 1L));
rs->MoveNext();
}
rs->Close();
}

pCon->Close();

CoUninitialize();
}
bugfix Posted - Mar 06 2006 : 12:20:04 PM
Sure there is a bug.
CoInit();
ComPtr<bla> xx;
//work w/ xx
CoUninit();
xx.~bla(); <---boom

The bug of cause has nothing to do w/ VAX tho.
wlopez Posted - Mar 06 2006 : 11:41:21 AM
There is no bug in this code.

I installed the new version of Visual Assist X there still no intellisence.

This is interesting, when I disable Visual Assist I get the intellisense in pCon->. I'm not sure if this intellisense of Visual Studio since I always have Visual Assist installed.
bugfix Posted - Mar 04 2006 : 10:34:50 AM
The crash happens because the code is buggy:)
Smartpointers are beeing destroyed after the CoUnitialize call.
To resolve this simply put the code between CoInitialize and CoUnitialize in its on own scope.

-bugfix
feline Posted - Mar 04 2006 : 09:53:47 AM
using VS2005 and VA 1440 i have created a new "C++ -> Win32 -> Win32 Console Application" project, accepting the default application settings.

i then replaced all of the code in the cpp file with the code from this thread. this refused to compile so i put the line:

#include "stdafx.h"

back in at the top of the file, above the code from this thread. the code now runs, but crashes with the error:

Unhandled exception at 0x7c4ea4e1 in cpp_com_console.exe: Microsoft
C++ execption: _com_error at memory location 0x0012fc58..

selecting break this takes me to line 1271 in the file:
e:\\common_share\\code 2005\\cpp_com_console\\cpp_com_console\\debug\\msado15.tli

this is probably relevant, since i am back to the problem where "_ConnectionPtr" is underlined by VA as a mistyped symbol. it seems that there is something i have to do that has not been done. hopefully once that is done "_ConnectionPtr" will be a known type, and intellisense will start working again.

can you try upgrading to VA 1440 and see if that helps? i have seen this work with this version of VA.
wlopez Posted - Mar 02 2006 : 4:02:05 PM
Thank you for the quick response.

In my VS 2005 console project the pCon. does have intellisense but the pCon-> does not. I also tried the rs smart pointer and its same result rs. have intellisense and rs-> doesnt.



Here is my VA X and VS 2005 information.
------------------------------------------------
VA_X.dll file version 10.2.1438.0 built 2005.12.16
Licensed to:
VA X: [email protected] (1-user license) Support ends 2006.12.20
VAOpsWin.dll version 1.3.1.9
VATE.dll version 1.0.4.11
DevEnv.exe version 8.0.50727.42
msenv.dll version 8.0.50727.42
Font: Courier New 13(Pixels)
Comctl32.dll version 6.0.2900.2180
WindowsNT 5.1 Build 2600 Service Pack 2
Single processor

Platform: Win32
Stable Includes:
C:\\devel\\common\\inc;
C:\\Program Files\\Microsoft Visual Studio 8\\VC\\include;
C:\\Program Files\\Microsoft Visual Studio 8\\VC\\atlmfc\\include;
C:\\Program Files\\Microsoft Visual Studio 8\\VC\\PlatformSDK\\include;
C:\\Program Files\\Microsoft Visual Studio 8\\SDK\\v2.0\\include;
C:\\devel\\v6\\inc;
C:\\devel\\v6\\msvc;

Library Includes:
C:\\Program Files\\Microsoft Visual Studio 8\\VC\\atlmfc\\src\\mfc;
C:\\Program Files\\Microsoft Visual Studio 8\\VC\\atlmfc\\src\\mfcm;
C:\\Program Files\\Microsoft Visual Studio 8\\VC\\atlmfc\\src\\atl;
C:\\Program Files\\Microsoft Visual Studio 8\\VC\\crt\\src;
C:\\devel\\common\\src;

Other Includes:

feline Posted - Feb 28 2006 : 3:52:15 PM
creating a new cpp file and pasting this code into it resulted in VA underlining the type "_ConnectionPtr" as a mistyped symbol. as a result i was unable to get any intellisense suggestions for pCon.

however when i then create a new win32 console application and paste this code into the main cpp file _ConnectionPtr is a know type, shown in italic. i am now getting intellisense suggestions for both pCon. and pCon->

the lists are different, which i am taking as a good sign.

given this code, can you tell me what problem you are getting?
wlopez Posted - Feb 27 2006 : 5:25:11 PM
I'm using Visual Assist X on Visual Studio 6, 2003 and 2005.


Here's a complete sample.

#include <stdio.h>
#import "c:\\program files\\common files\\system\\ado\\msado15.dll" rename ( "EOF", "adoEOF" ) no_namespace
#define COL(rs,x) _bstr_t(rs->Fields->Item[_variant_t(x)]->Value)

int main()
{
CoInitialize(NULL);

_ConnectionPtr pCon;
pCon.CreateInstance(__uuidof(Connection));

// Generic connection to Northwind database
_bstr_t cnStr("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=(local)");

if(SUCCEEDED(pCon->Open(cnStr, "", "", -1)))
{
_bstr_t sql("select * from customers");

_RecordsetPtr rs = pCon->Execute(sql, NULL, NULL);
while(!rs->adoEOF)
{
printf("\\n%s", (char*)COL(rs, 1L));
rs->MoveNext();
}
rs->Close();
}

pCon->Close();

CoUninitialize();
}
feline Posted - Feb 26 2006 : 09:18:06 AM
i would expect VA to work with COM objects. there was a recent thread about VA not properly understanding COM smart pointers, but it did seem to be doing something.

assuming i know nothing about COM, can you tell me how to produce a very simple test of this problem? plus, which IDE and version of VA are you using?

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000