Newbie: VC++ #import problem 
Author Message
 Newbie: VC++ #import problem

Using the #import for a class, I get successful compile & link but on calling
a function of the class using a smart pointer

_bstr_t CurrencyStr = p->GetCurrencyStr(lCurrencyID, lBaseCurrencyID, dPrice);

I get error:

First-chance exception in WebUtilClient.exe: 0xC0000005: Access Violation.

running in de{*filter*} the access violation occurs whan I try to step into the
statement below at the arrow -->

inline _bstr_t IWebUtils::GetCurrencyStr ( long CurrencyID, long BaseCurrencyID,
double Price ) {
    BSTR _result;
-->HRESULT _hr = raw_GetCurrencyStr(CurrencyID, BaseCurrencyID, Price, &_result);
    if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
    return _bstr_t(_result, false);

Quote:
}

it appears that raw_GetCurrencyStr is just an unimplemented virtual function.

Do I need to implement the raw_GetCurrencyStr method created by the #import or is
there some other step I missed along the way?



Mon, 27 Oct 2003 08:12:48 GMT  
 Newbie: VC++ #import problem
If the com object compiles and registers correctly then the
raw_GetCurrencyStr is created automaticly for you, no need to implement
anything(as long as GetCurrencyStr is implemented in the object)

if you abend at the raw call i'm guessing the com object is an exe and you
don't have a proxy/stub dll registered to do marsheling for it. I've ran
into that problem a few times

see "Building and Registering a Proxy DLL" in MSDN

marc


Using the #import for a class, I get successful compile & link but on
calling
a function of the class using a smart pointer

_bstr_t CurrencyStr = p->GetCurrencyStr(lCurrencyID, lBaseCurrencyID,
dPrice);

I get error:

First-chance exception in WebUtilClient.exe: 0xC0000005: Access Violation.

running in de{*filter*} the access violation occurs whan I try to step into the
statement below at the arrow -->

inline _bstr_t IWebUtils::GetCurrencyStr ( long CurrencyID, long
BaseCurrencyID,
double Price ) {
    BSTR _result;
-->HRESULT _hr = raw_GetCurrencyStr(CurrencyID, BaseCurrencyID, Price,
&_result);
    if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
    return _bstr_t(_result, false);

Quote:
}

it appears that raw_GetCurrencyStr is just an unimplemented virtual
function.

Do I need to implement the raw_GetCurrencyStr method created by the #import
or is
there some other step I missed along the way?



Mon, 27 Oct 2003 20:05:39 GMT  
 Newbie: VC++ #import problem
Couldn't it be simpler - he forgot to create an instance of the object?

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.*-*-*.com/
=====================================


Quote:
> If the com object compiles and registers correctly then the
> raw_GetCurrencyStr is created automaticly for you, no need to implement
> anything(as long as GetCurrencyStr is implemented in the object)

> if you abend at the raw call i'm guessing the com object is an exe and you
> don't have a proxy/stub dll registered to do marsheling for it. I've ran
> into that problem a few times

> see "Building and Registering a Proxy DLL" in MSDN

> marc



> Using the #import for a class, I get successful compile & link but on
> calling
> a function of the class using a smart pointer

> _bstr_t CurrencyStr = p->GetCurrencyStr(lCurrencyID, lBaseCurrencyID,
> dPrice);

> I get error:

> First-chance exception in WebUtilClient.exe: 0xC0000005: Access Violation.

> running in de{*filter*} the access violation occurs whan I try to step into
the
> statement below at the arrow -->

> inline _bstr_t IWebUtils::GetCurrencyStr ( long CurrencyID, long
> BaseCurrencyID,
> double Price ) {
>     BSTR _result;
> -->HRESULT _hr = raw_GetCurrencyStr(CurrencyID, BaseCurrencyID, Price,
> &_result);
>     if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
>     return _bstr_t(_result, false);
> }

> it appears that raw_GetCurrencyStr is just an unimplemented virtual
> function.

> Do I need to implement the raw_GetCurrencyStr method created by the
#import
> or is
> there some other step I missed along the way?



Tue, 28 Oct 2003 02:03:44 GMT  
 Newbie: VC++ #import problem

Quote:
> Couldn't it be simpler - he forgot to create an instance of the object?

No, it couldn't as safe pointer -> operator throws exception in such case
and IWebUtils::GetCurrencyStr function is never reached...

--
Best regards,
Vadim Melnik,
{*filter*} Consultant.
_____________________________
http://www.*-*-*.com/

Quote:

> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD

> MVP VC FAQ: http://www.*-*-*.com/
> =====================================



> > If the com object compiles and registers correctly then the
> > raw_GetCurrencyStr is created automaticly for you, no need to implement
> > anything(as long as GetCurrencyStr is implemented in the object)

> > if you abend at the raw call i'm guessing the com object is an exe and
you
> > don't have a proxy/stub dll registered to do marsheling for it. I've ran
> > into that problem a few times

> > see "Building and Registering a Proxy DLL" in MSDN

> > marc



> > Using the #import for a class, I get successful compile & link but on
> > calling
> > a function of the class using a smart pointer

> > _bstr_t CurrencyStr = p->GetCurrencyStr(lCurrencyID, lBaseCurrencyID,
> > dPrice);

> > I get error:

> > First-chance exception in WebUtilClient.exe: 0xC0000005: Access
Violation.

> > running in de{*filter*} the access violation occurs whan I try to step into
> the
> > statement below at the arrow -->

> > inline _bstr_t IWebUtils::GetCurrencyStr ( long CurrencyID, long
> > BaseCurrencyID,
> > double Price ) {
> >     BSTR _result;
> > -->HRESULT _hr = raw_GetCurrencyStr(CurrencyID, BaseCurrencyID, Price,
> > &_result);
> >     if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
> >     return _bstr_t(_result, false);
> > }

> > it appears that raw_GetCurrencyStr is just an unimplemented virtual
> > function.

> > Do I need to implement the raw_GetCurrencyStr method created by the
> #import
> > or is
> > there some other step I missed along the way?



Tue, 28 Oct 2003 02:39:42 GMT  
 Newbie: VC++ #import problem
It seems that the error is in this WebUtil function called.  The line you are
showing is not the actual code.  You have to load the dll or exe and step into
that function to find out why that COM object is throwing an exception.
Quote:
-----Original Message-----
Using the #import for a class, I get successful compile & link but on calling
a function of the class using a smart pointer

_bstr_t CurrencyStr = p->GetCurrencyStr(lCurrencyID, lBaseCurrencyID, dPrice);

I get error:

First-chance exception in WebUtilClient.exe: 0xC0000005: Access Violation.

running in de{*filter*} the access violation occurs whan I try to step into the
statement below at the arrow -->

inline _bstr_t IWebUtils::GetCurrencyStr ( long CurrencyID, long BaseCurrencyID,
double Price ) {
    BSTR _result;
-->HRESULT _hr = raw_GetCurrencyStr(CurrencyID, BaseCurrencyID, Price, &_result);
    if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
    return _bstr_t(_result, false);
}

it appears that raw_GetCurrencyStr is just an unimplemented virtual function.

Do I need to implement the raw_GetCurrencyStr method created by the #import or is
there some other step I missed along the way?

.



Tue, 28 Oct 2003 11:03:22 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. VB type libraray import problem in VC...

2. #import problem in VC++.NET (tlb is created after the DLL)

3. VC 5.0 Import Library Problems

4. Problem importing a VB ActiveX control into VC++ 5.0

5. import problem with VC++ Circle Tu

6. Problem with .NET COM object import to VC++ 6

7. Importing c code into vc++

8. Importing c code into vc++ and mfc

9. Newbie: #import confusion

10. Newbie: Import text file into Access Table ?

11. VC++ Newbie - Compiling Problems

12. Source Code Debugging of Imported Project (newbie needs help)

 

 
Powered by phpBB® Forum Software