Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2005

Tip: Looking for answers? Try searching our database.

Problem with SAFEARRAY as property accessors.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ahmad Jalil Qarshi - 24 Mar 2005 15:51 GMT
i want to store binary data into my property. i read earlier positing on
"microsoft.public.dotnet.languages.vc" group with subject as SAFEARRAY in
attributed ATL7 Project. i followed the same approach but unfortunately i
failed to do that.
i  declared the property accessors as follow in my idl file.

[propget, id(2), helpstring("property Data")] HRESULT Data([out, retval,
satype(byte)] SAFEARRAY * *pVal);
[propput, id(2), helpstring("property Data")] HRESULT Data([in,
satype(byte)] SAFEARRAY * newVal);

when i compile code i get following error.
error MIDL2025 : syntax error : expecting ] or , near "satype".

any body there to help me.

Thanks in advance.

Ahmad Jalil Qarshi
Igor Tandetnik - 24 Mar 2005 15:57 GMT
> [propget, id(2), helpstring("property Data")] HRESULT Data([out,
> retval, satype(byte)] SAFEARRAY * *pVal);
[quoted text clipped - 3 lines]
> when i compile code i get following error.
> error MIDL2025 : syntax error : expecting ] or , near "satype".

In IDL, the syntax is different:

[propget, id(2), helpstring("property Data")]
HRESULT Data([out, retval] SAFEARRAY(BYTE) *pVal);
[propput, id(2), helpstring("property Data")]
HRESULT Data([in] SAFEARRAY(BYTE) newVal);

The syntax in your post is used in a .cpp file when building an
attributed project.
Signature

With best wishes,
   Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925

Ahmad Jalil Qarshi - 25 Mar 2005 12:54 GMT
Thanks Igor!
i have done that according to your instruction. but still i get same error
twice which is here under.

error C2259: 'CComObject<class CTestLoadObj>' : cannot instantiate abstract
class due to following members:
       c:\program files\microsoft visual
studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template
member function 'long __stdcall ATL::CComCreator<class ATL::CComObject<class
CTestLoadObj> >::CreateInstance(void *,const struct _GUID
&,void ** )'

could you plz tell me how to define these properties in .cpp file also.
i suppose that it would be like that:
STDMETHODIMP CTestLoadObj::get_Data(SAFEARRAY *pVal)
{
}
STDMETHODIMP CTestLoadObj::put_Data(SAFEARRAY pVal)
{
}
but i m sure that i m wrong that's y i m getting errors. please guide me.
Thanks in advance.
Ahmad Jalil Qarshi

> > [propget, id(2), helpstring("property Data")] HRESULT Data([out,
> > retval, satype(byte)] SAFEARRAY * *pVal);
[quoted text clipped - 21 lines]
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
Igor Tandetnik - 25 Mar 2005 16:11 GMT
> error C2259: 'CComObject<class CTestLoadObj>' : cannot instantiate
> abstract class due to following members:
[quoted text clipped - 13 lines]
> {
> }

A SAFEARRAY(Whatever) parameter in IDL becomes SAFEARRAY* in C++.
SAFEARRAY(Whatever)* becomes SAFEARRAY**, and so on. In other words, in
C++ you always specify one extra level of indirection compared to IDL
syntax.
Signature

With best wishes,
   Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925

Ahmad Jalil Qarshi - 25 Mar 2005 16:35 GMT
Thanks again!
i have done that. its compiled now successfully. but my object is not
persisting this safearray, whereas other properties of this object persist.
Isn't it possible to persist SAFEARRAYs.
Thanks.
Ahmad Jalil Qarshi

> > error C2259: 'CComObject<class CTestLoadObj>' : cannot instantiate
> > abstract class due to following members:
[quoted text clipped - 26 lines]
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
Igor Tandetnik - 25 Mar 2005 16:39 GMT
> i have done that. its compiled now successfully. but my object is not
> persisting this safearray, whereas other properties of this object
> persist. Isn't it possible to persist SAFEARRAYs.

ATL persistence implementation (IPersistStreamInitImpl et al) indeed
does not support safearrays. You will have to write your own.
Signature

With best wishes,
   Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.