Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 No IntelliSense on COM objects using #import
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

wlopez
New Member

5 Posts

Posted - Feb 24 2006 :  1:28:57 PM  Show Profile  Reply with Quote
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.



feline
Whole Tomato Software

United Kingdom
19001 Posts

Posted - Feb 26 2006 :  09:18:06 AM  Show Profile  Reply with Quote
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?

zen is the art of being at one with the two'ness
Go to Top of Page

wlopez
New Member

5 Posts

Posted - Feb 27 2006 :  5:25:11 PM  Show Profile  Reply with Quote
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();
}
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19001 Posts

Posted - Feb 28 2006 :  3:52:15 PM  Show Profile  Reply with Quote
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?

zen is the art of being at one with the two'ness
Go to Top of Page

wlopez
New Member

5 Posts

Posted - Mar 02 2006 :  4:02:05 PM  Show Profile  Reply with Quote
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:

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19001 Posts

Posted - Mar 04 2006 :  09:53:47 AM  Show Profile  Reply with Quote
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.

zen is the art of being at one with the two'ness
Go to Top of Page

bugfix
Tomato Guru

Germany
324 Posts

Posted - Mar 04 2006 :  10:34:50 AM  Show Profile  Reply with Quote
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

http://www.mf-sd.de
Go to Top of Page

wlopez
New Member

5 Posts

Posted - Mar 06 2006 :  11:41:21 AM  Show Profile  Reply with Quote
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.
Go to Top of Page

bugfix
Tomato Guru

Germany
324 Posts

Posted - Mar 06 2006 :  12:20:04 PM  Show Profile  Reply with Quote
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.

http://www.mf-sd.de
Go to Top of Page

wlopez
New Member

5 Posts

Posted - Mar 06 2006 :  1:48:43 PM  Show Profile  Reply with Quote
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();
}
Go to Top of Page

bugfix
Tomato Guru

Germany
324 Posts

Posted - Mar 06 2006 :  2:00:55 PM  Show Profile  Reply with Quote
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:)


http://www.mf-sd.de
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19001 Posts

Posted - Mar 06 2006 :  5:26:15 PM  Show Profile  Reply with Quote
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.

zen is the art of being at one with the two'ness
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Aug 12 2006 :  11:14:47 PM  Show Profile  Reply with Quote
Build 1532 has better support for COM smart pointers.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000