Board index » cppbuilder » Exception using COM with BDS2006 in TAutoDriver

Exception using COM with BDS2006 in TAutoDriver


2006-01-21 02:48:29 AM
cppbuilder43
Using BDS2006, Update 1, with FarPoint Spread COM, I get an exception in
Utilcls.h at
template <class DISPINTF>void
TAutoDriver<DISPINTF>::Unbind(bool release)
{
if (release && m_Dispatch)
m_Dispatch->Release();
m_Dispatch = 0;
}
or
template <class DISPINTF>
TAutoDriver<DISPINTF>::~TAutoDriver()
{
Unbind();
}
The error message is
"First chance exception at $7C81EB33. Exception class EAccessViolation with
message 'Access violation at address 00408615 in module 'MyApp.exe'. Read of
address B2D88B5B'. Process MyApp.exe (1184)"
My code looks like this:
Spread1->LoadFromFile( WideString("test.ss7").c_bstr() );
or
Spread1->LoadFromFile( WideString("test.ss7") );
Both fail.
I see that there have been corrections in Utilcls.h in the past.
Any suggestions for BDS2006?
-Ken
 
 

Re:Exception using COM with BDS2006 in TAutoDriver

"ken wilkinson" < XXXX@XXXXX.COM >wrote in message
Quote
Using BDS2006, Update 1, with FarPoint Spread COM, I get an exception
The only way I can think of for that exception to occur is if the reference
count of the interface is not being managed properly, such that the
interface is being freed from memory before TAutoDriver's Unbind() method is
called.
Quote
My code looks like this:
Spread1->LoadFromFile( WideString("test.ss7").c_bstr() );
or
Spread1->LoadFromFile( WideString("test.ss7") );
How does that code relate to TAutoDriver? Please show a more complete code
snippet that shows actually how you are using the COM object.
Gambit
 

Re:Exception using COM with BDS2006 in TAutoDriver

I don't exactly now how this code relates to the TAutoDriver, but it is my
*only* line of code in the form within a button click event handler.
Actually, I tried to narrow down the problem as much as I could.
The Farpoint Spread COM v7 worked fine with BCB6. In BDS2006, I created a
new package project, added the ActiveX control, corrected a documented
read/write flag error in the generated code, and installed the component.
Then I created a new project, added a form, added a descending form with a
Spread, added another descending form with the button event to load the
file. The other thing is, there is a time delay after the Spread is
initially put on the form and also, occasionally, when I switch back and
forth between the code and design view, giving an uneasy feeling about the
correctness of generated wrappers.
What do you think now?
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"ken wilkinson" < XXXX@XXXXX.COM >wrote in message
news:43d12fc7$ XXXX@XXXXX.COM ...

>Using BDS2006, Update 1, with FarPoint Spread COM, I get an exception

The only way I can think of for that exception to occur is if the
reference
count of the interface is not being managed properly, such that the
interface is being freed from memory before TAutoDriver's Unbind() method
is
called.

>My code looks like this:
>Spread1->LoadFromFile( WideString("test.ss7").c_bstr() );
>or
>Spread1->LoadFromFile( WideString("test.ss7") );

How does that code relate to TAutoDriver? Please show a more complete
code
snippet that shows actually how you are using the COM object.


Gambit


 

{smallsort}

Re:Exception using COM with BDS2006 in TAutoDriver

You may want to know what changes I made to the generated files, here are
the two edits I made to the generated wrapper, FPSpreadADO_OCX.cpp & .h:
[C++ Error] FPSpreadADO_OCX.h(1037): E2347 Parameter mismatch in write
access specifier of property DataSource
// __property Msdatasrc_tlb::DataSourcePtr DataSource={
read=get_DataSource, write=set_DataSource, stored=false };
__property Msdatasrc_tlb::DataSourcePtr DataSource={ read=get_DataSource,
/* write=set_DataSource,*/ stored=false };
// Flags for OnChanged PropertyNotification
//0x0000002F,
0x00000000,
300,// (IDE Version)
 

Re:Exception using COM with BDS2006 in TAutoDriver

"Ken Wilkinson" < XXXX@XXXXX.COM >wrote in message
Quote
I don't exactly now how this code relates to the TAutoDriver,
but it is my *only* line of code in the form within a button click
event handler. Actually, I tried to narrow down the problem as
much as I could.
What EXACTLY is 'Spread1' declared as? How exactly did you bring it into
the project? How exactly are you instantiating it?
Quote
The Farpoint Spread COM v7 worked fine with BCB6. In BDS2006,
I created a new package project, added the ActiveX control, corrected
a documented read/write flag error in the generated code, and installed
the component.
Please provide the exact step-by-step operations you performed to do all of
that.
Quote
Then I created a new project, added a form, added a descending form
with a Spread, added another descending form with the button event
to load the file.
So you are using multiple levels of inheritance in your forms?
Gambit
 

Re:Exception using COM with BDS2006 in TAutoDriver

Repeat posting as a reply...
There seems to be a problem with the code generation for the
TAutoDriver<T>::Unbind method in BDS 2006. It appears to be similar in
nature to that reported by Ken Wilkinson on 21/01/2006
I have imported an ActiveX control (LEADTools Imaging Main Control), and the
typelib importer has used the TAutoDriver<>template class to wrap the main
interface to the control. I have seen other controls imported using the
TComInterface<>template - I guess it depends on the implementation of the
ActiveX control as to which type of interface is used
When a method of the ActiveX control is called, I get an access violation in
the TAutoDriver<>::Unbind method.
When investigating this, I saw a number of oddities
1. The de{*word*81} does not show the members of the TAutoDriver<IDispatch>
class properly
2. When examinining the assembler, it seems that there is a 8 byte offset
from the "this" pointer value of the TAutoDriver<>instance and its first
data member (m_Dispatch). This is apparent in the constructors for the class
3. The 8 byte offset appears in the TAutoDriver<IDispatch>::Unbind method
assembler, but NOT in the TAutoDriver<_DLead>method (_DLead is the
interface for the control I am using). It appears to be this mismatch that
is causing the problem - the Unbind method uses m_Dispatch to dereference
the ActiveX object, but the TAutoDriver<_DLead>::Unbind method uses an
offset of 0 from the "this" pointer rather than 8 used for other method
In these circumstances, it is difficult to know exactly what is happening,
specifically
1. Is the 8 byte offset from the "this" pointer to "m_Dispatch" member
correct for the TAutoDriver<>class ?
2. If it is, then why does the de{*word*81} show it incorrectly for
TAutoDriver<IDispatch>but not TAutoDriver<_DLead>?
3. Is the correct behaviour to have a 0 byte offset, but the code seems to
run mostly OK because the erroneous offset is consistent?
There is a workaround to this problem by using the interface pointer
directly. I modified the "GetDefaultInterface" method to return the
interface pointer (_DLead*) directly
return (_DLead*) m_OCXIntf; // m_OCXIntf is of type TAutoDriver<_DLead>
I suspect there is a problem with code generation with the template classes.
This may only affect ActiveX controls.
As an aside, does anyone know of a channel (other than this forum, or a paid
support contract) that you can use to submit bug reports to Borland? I don't
expect any commitment to fix the error or indeed any response without paying
for support, but I would like to know that someone within Borland actually
gets this information
Best Regards,
Gary England
"ken wilkinson" < XXXX@XXXXX.COM >wrote in message
Quote
Using BDS2006, Update 1, with FarPoint Spread COM, I get an exception in
Utilcls.h at

template <class DISPINTF>void
TAutoDriver<DISPINTF>::Unbind(bool release)
{
if (release && m_Dispatch)
m_Dispatch->Release();
m_Dispatch = 0;
}

or

template <class DISPINTF>
TAutoDriver<DISPINTF>::~TAutoDriver()
{
Unbind();
}

The error message is
"First chance exception at $7C81EB33. Exception class EAccessViolation
with
message 'Access violation at address 00408615 in module 'MyApp.exe'. Read
of
address B2D88B5B'. Process MyApp.exe (1184)"


My code looks like this:
Spread1->LoadFromFile( WideString("test.ss7").c_bstr() );
or
Spread1->LoadFromFile( WideString("test.ss7") );

Both fail.

I see that there have been corrections in Utilcls.h in the past.
Any suggestions for BDS2006?
-Ken


 

Re:Exception using COM with BDS2006 in TAutoDriver

On Thu, 13 Apr 2006 10:22:08 +0100, "Gary England"
< XXXX@XXXXX.COM >wrote:
Quote
As an aside, does anyone know of a channel (other than this forum, or a paid
support contract) that you can use to submit bug reports to Borland? I don't
please visit qc.borland.com
--
Vladimir Ulchenko aka vavan
 

Re:Exception using COM with BDS2006 in TAutoDriver

Thanks
"vavan" < XXXX@XXXXX.COM >wrote in message
Quote
On Thu, 13 Apr 2006 10:22:08 +0100, "Gary England"
< XXXX@XXXXX.COM >wrote:

>As an aside, does anyone know of a channel (other than this forum, or a
paid
>support contract) that you can use to submit bug reports to Borland? I
don't

please visit qc.borland.com

--
Vladimir Ulchenko aka vavan