Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 4th, 2007, 10:40 AM
Authorized User
Join Date: Jul 2007
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting junk bstr values in C# dll from VC++

Hi All

Been trying to figure out a solution to this problem since long. Would appreciate if someone can throw some light.

I am calling a managed C# dll in VC++ code. My problem is that I'm unable to pass the bstr data from VC++ to C#. In fact, the bstr data is coming to C#, but its all junk values that looks something like this...

ç‘¨ç´â¼ºã„¯ãˆ¹ã„®ã ¶ã„®ã„°ã„®ãŒ°æœ¯â½·ç•°å ½´ç¡¸â¹¸æ¡°p.280ã…—Ä„

Though if I pass a data of type "int", I get the correct value in C#. The problem is with the bstr values. This is how my code is in VC++...

unsigned char* URL ;

I have typecasted this unsigned char* into a binary string as following

 BSTR PURL =SysAllocString((BSTR)URL.p);

and call a function in VC++ written in C# dll as following

pIclass1->raw_HTTP_Put_Query (&PURL ,nBufLen,&retVal );

In C# I receive the values as following

public int HTTP_Put_Query(ref string PURL,int nBufLen)





Now, the problem is that the PURL parameter of type "bstr" recieves junk values in the C# dll, the nBufLen variable being of type "int" is getting correct value.

Is there a way I can convert the bstr to string so that it doesnt return junk values?

Would really appreciate much needed help.


Vishal Khanna



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting junk bstr values in C# dll from VC++ dotnetuncle Visual C++ 2005 0 July 4th, 2007 10:41 AM
Getting junk bstr values in managed C# DLL from VC dotnetuncle C++ Programming 0 July 4th, 2007 10:38 AM
want to use the old Vc++ dll in asp.Net sjs950 ASP.NET 1.0 and 1.1 Basics 0 May 25th, 2006 05:30 AM
How to call a COM DLL from VC++, subhash_w Visual C++ 0 July 15th, 2005 11:33 PM
DLL in VC#.NET sachin-csharp .NET Framework 2.0 1 August 23rd, 2004 11:57 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.