ATL problem with COM+ 
Author Message
 ATL problem with COM+

I wrote  an in-process dll with ATL that I use by a client vb.
This is ok.
My problem starts when I want to use the same dll, with COM +.
The interface I need to use with COM+ is the following:

 interface IGestoreProcedureBL : IDispatch
 {
  typedef struct S_ParametriProcedura {
   BSTR NomeParametro;
   BSTR ValoreParametro;
  } S_ParametriProcedura;

  [id(1), helpstring("method ChiamaProcedura")] HRESULT ChiamaProcedura([in]
S_Org *org, [in] BSTR nomeproc, [in] long cMax, [in, out] long *pcActual,
[in, size_is(cMax)] S_ParametriProcedura *va);
 };

...

STDMETHODIMP CGestoreProcedureBL::ChiamaProcedura(S_Org *org, BSTR nomeproc,
long cMax, long *pcActual, S_ParametriProcedura *pp)
{
 int i;
 _bstr_t b_np, b_vp;

 try{
  for (i=0; (i<*pcActual) && (i < cMax);i++) {
   b_np = pp[i].NomeParametro;
   b_vp = pp[i].ValoreParametro;
    ...
  }
...
If pcActual is 1 there is no problem, but if pcActual = 2 or more, the
values are not read (pointer to second element of the array is incorrect).

The client code (VB) is:

Dim cmax As Long
Dim pcactual As Long
Dim ppar() As ENERGIABUSINESSLOGICLib.S_ParametriProcedura

cmax = 2
pcactual = 2
ReDim ppar(cmax)
ppar(0).NomeParametro = "DataFattura"
ppar(0).ValoreParametro = Me.tDataFatt
ppar(1).NomeParametro = "IdLotto"
ppar(1).ValoreParametro = Me.tLottoConf
Call enp.ChiamaProcedura(org, "CONFERMA BOLLETTAZIONE", cmax, pcactual,
ppar(0))

Do I need to use  Personalized marshaling ? And if I do, how can I implement
this ?

Thank you for the help.
Best Regards, Stefania Oliviero.



Sat, 11 Sep 2004 01:45:05 GMT  
 ATL problem with COM+
You are passing ppar(0) as the last parameter, that is, just one
element. Try passing ppar.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> I wrote  an in-process dll with ATL that I use by a client vb.
> This is ok.
> My problem starts when I want to use the same dll, with COM +.
> The interface I need to use with COM+ is the following:

>  interface IGestoreProcedureBL : IDispatch
>  {
>   typedef struct S_ParametriProcedura {
>    BSTR NomeParametro;
>    BSTR ValoreParametro;
>   } S_ParametriProcedura;

>   [id(1), helpstring("method ChiamaProcedura")] HRESULT

ChiamaProcedura([in]
Quote:
> S_Org *org, [in] BSTR nomeproc, [in] long cMax, [in, out] long
*pcActual,
> [in, size_is(cMax)] S_ParametriProcedura *va);
>  };

> ...

> STDMETHODIMP CGestoreProcedureBL::ChiamaProcedura(S_Org *org, BSTR
nomeproc,
> long cMax, long *pcActual, S_ParametriProcedura *pp)
> {
>  int i;
>  _bstr_t b_np, b_vp;

>  try{
>   for (i=0; (i<*pcActual) && (i < cMax);i++) {
>    b_np = pp[i].NomeParametro;
>    b_vp = pp[i].ValoreParametro;
>     ...
>   }
> ...
> If pcActual is 1 there is no problem, but if pcActual = 2 or more, the
> values are not read (pointer to second element of the array is
incorrect).

> The client code (VB) is:

> Dim cmax As Long
> Dim pcactual As Long
> Dim ppar() As ENERGIABUSINESSLOGICLib.S_ParametriProcedura

> cmax = 2
> pcactual = 2
> ReDim ppar(cmax)
> ppar(0).NomeParametro = "DataFattura"
> ppar(0).ValoreParametro = Me.tDataFatt
> ppar(1).NomeParametro = "IdLotto"
> ppar(1).ValoreParametro = Me.tLottoConf
> Call enp.ChiamaProcedura(org, "CONFERMA BOLLETTAZIONE", cmax,
pcactual,
> ppar(0))

> Do I need to use  Personalized marshaling ? And if I do, how can I
implement
> this ?

> Thank you for the help.
> Best Regards, Stefania Oliviero.



Sat, 11 Sep 2004 02:02:42 GMT  
 ATL problem with COM+
Your interface derives from IDispatch (I assume it is dual). However,
it is not Automation compatible - passes a C-style array. MIDL should
have issued a warning in this regard... Well, that is really a severe
error and you suffer the consequences. Fix your interface - use a
ASAFEARRAY instead of C-style conformat array.

Item 4 in the COM/ATL FAQ in my signature may be of some assistance
with regard to using structs in a safe array.

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

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:

> I wrote  an in-process dll with ATL that I use by a client vb.
> This is ok.
> My problem starts when I want to use the same dll, with COM +.
> The interface I need to use with COM+ is the following:

>  interface IGestoreProcedureBL : IDispatch
>  {
>   typedef struct S_ParametriProcedura {
>    BSTR NomeParametro;
>    BSTR ValoreParametro;
>   } S_ParametriProcedura;

>   [id(1), helpstring("method ChiamaProcedura")] HRESULT ChiamaProcedura([in]
> S_Org *org, [in] BSTR nomeproc, [in] long cMax, [in, out] long *pcActual,
> [in, size_is(cMax)] S_ParametriProcedura *va);
>  };

> ...

> STDMETHODIMP CGestoreProcedureBL::ChiamaProcedura(S_Org *org, BSTR nomeproc,
> long cMax, long *pcActual, S_ParametriProcedura *pp)
> {
>  int i;
>  _bstr_t b_np, b_vp;

>  try{
>   for (i=0; (i<*pcActual) && (i < cMax);i++) {
>    b_np = pp[i].NomeParametro;
>    b_vp = pp[i].ValoreParametro;
>     ...
>   }
> ...
> If pcActual is 1 there is no problem, but if pcActual = 2 or more, the
> values are not read (pointer to second element of the array is incorrect).

> The client code (VB) is:

> Dim cmax As Long
> Dim pcactual As Long
> Dim ppar() As ENERGIABUSINESSLOGICLib.S_ParametriProcedura

> cmax = 2
> pcactual = 2
> ReDim ppar(cmax)
> ppar(0).NomeParametro = "DataFattura"
> ppar(0).ValoreParametro = Me.tDataFatt
> ppar(1).NomeParametro = "IdLotto"
> ppar(1).ValoreParametro = Me.tLottoConf
> Call enp.ChiamaProcedura(org, "CONFERMA BOLLETTAZIONE", cmax, pcactual,
> ppar(0))

> Do I need to use  Personalized marshaling ? And if I do, how can I implement
> this ?

> Thank you for the help.
> Best Regards, Stefania Oliviero.



Sat, 11 Sep 2004 03:46:34 GMT  
 ATL problem with COM+
Now I use a SAFEARRAY of BSTR and I solved the problem.
Thank you for the help.


Your interface derives from IDispatch (I assume it is dual). However,
it is not Automation compatible - passes a C-style array. MIDL should
have issued a warning in this regard... Well, that is really a severe
error and you suffer the consequences. Fix your interface - use a
ASAFEARRAY instead of C-style conformat array.

Item 4 in the COM/ATL FAQ in my signature may be of some assistance
with regard to using structs in a safe array.

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

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> I wrote  an in-process dll with ATL that I use by a client vb.
> This is ok.
> My problem starts when I want to use the same dll, with COM +.
> The interface I need to use with COM+ is the following:

>  interface IGestoreProcedureBL : IDispatch
>  {
>   typedef struct S_ParametriProcedura {
>    BSTR NomeParametro;
>    BSTR ValoreParametro;
>   } S_ParametriProcedura;

>   [id(1), helpstring("method ChiamaProcedura")] HRESULT

ChiamaProcedura([in]
Quote:
> S_Org *org, [in] BSTR nomeproc, [in] long cMax, [in, out] long *pcActual,
> [in, size_is(cMax)] S_ParametriProcedura *va);
>  };

> ...

> STDMETHODIMP CGestoreProcedureBL::ChiamaProcedura(S_Org *org, BSTR
nomeproc,
> long cMax, long *pcActual, S_ParametriProcedura *pp)
> {
>  int i;
>  _bstr_t b_np, b_vp;

>  try{
>   for (i=0; (i<*pcActual) && (i < cMax);i++) {
>    b_np = pp[i].NomeParametro;
>    b_vp = pp[i].ValoreParametro;
>     ...
>   }
> ...
> If pcActual is 1 there is no problem, but if pcActual = 2 or more, the
> values are not read (pointer to second element of the array is incorrect).

> The client code (VB) is:

> Dim cmax As Long
> Dim pcactual As Long
> Dim ppar() As ENERGIABUSINESSLOGICLib.S_ParametriProcedura

> cmax = 2
> pcactual = 2
> ReDim ppar(cmax)
> ppar(0).NomeParametro = "DataFattura"
> ppar(0).ValoreParametro = Me.tDataFatt
> ppar(1).NomeParametro = "IdLotto"
> ppar(1).ValoreParametro = Me.tLottoConf
> Call enp.ChiamaProcedura(org, "CONFERMA BOLLETTAZIONE", cmax, pcactual,
> ppar(0))

> Do I need to use  Personalized marshaling ? And if I do, how can I
implement
> this ?

> Thank you for the help.
> Best Regards, Stefania Oliviero.



Sat, 11 Sep 2004 17:47:50 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ATL COM - Passing ATL COM classes through another ATL COM class in the same app

2. HELP - ATL NT Service and COM Interface Problem

3. problem invoke Atl com with two interfaces

4. ATL COM Project with MFC Support causes problem with Processor Pack for VC.

5. ATL COM component is giving a list of problems

6. Problem using activex control inside ATL com dll

7. Threading problem in ATL COM object

8. Threading problem in ATL COM Object

9. VC++/ATL COM ASP component thread problem.

10. An ATL COM DLL problem!

11. ATL Com wrapper for C DLL - problem with Connection Points

12. Problem creating ToolBar/Statusbar in a ATL COM DLL

 

 
Powered by phpBB® Forum Software