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 / .NET Framework / Interop / March 2007

Tip: Looking for answers? Try searching our database.

Marshalling CComBstr to System.String

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
akumaramar@gmail.com - 01 Mar 2007 13:32 GMT
Hi,

I have below declaration in C#

void
UpdateSpousePayrollDetails([MarshalAs(UnmanagedType.IUnknown)]Object
termlf, [MarshalAs(UnmanagedType.IUnknown)]Object dpyCdh,
[MarshalAs(UnmanagedType.BStr)]String SD04);

and want to call this function from C++. The code to call this
function is

CComBSTR SD04;
SD04 = L"N";
pTermlfRules->UpdateSpousePayrollDetails(pObj,pUnkPydCdh,SD04);

While compilation, I am getting following error.

cannot convert parameter 3 from 'ATL::CComBSTR' to '_bstr_t' . No user-
defined-conversion operator available that can perform this
conversion, or the operator cannot be called.

I can not use SD04 as _bstr_t instead of CComBSTR. Since, it is being
used lots of places and I need to change lots of VC++ code. Initial 2
parameters are working properly.

How can we resolve this issue?

Thanks

Ajay
Mattias Sjögren - 01 Mar 2007 21:44 GMT
>cannot convert parameter 3 from 'ATL::CComBSTR' to '_bstr_t' . No user-
>defined-conversion operator available that can perform this
>conversion, or the operator cannot be called.

This is a C++ problem that isn't really related to the fact that the
method you're calling is implemented in C#. So you may want to turn to
the microsoft.public.dotnet.languages.vc groups for a better answer.

That said, try something like this

_bstr_t tmp((BSTR)SD04, true);
pTermlfRules->UpdateSpousePayrollDetails(pObj,pUnkPydCdh,tmp);

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Rate this thread:







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.