Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C C# XML Visual-Studio
I made an DLL in C sharp and added to my VC++ project in visual studio,a method of my DLL on calling return the status as "success" or what the error is.
 
I did some thing like this
 
char *a=interfacepointer->DLL Function
 

I get the garbage value in variable "a".
When i check it through my C# code the output is like this :-
 
ON SUCCESS:-
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Success</string>
 
ON ERROR
 
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Unknown database 'nhms_temp11'</string>
 
I should get the Value as "SUCESS" or "Unknown database 'nhms_temp11'"
 
What should i do?
Posted 9-Oct-12 2:52am
Comments
Malli_S at 9-Oct-12 9:27am
   
What mechanism are you using to call the managed dll in native c++ project? Using interop ?
Tarun Batra at 9-Oct-12 10:07am
   
using COM,i solved the problem
Tejas Vaishnav at 9-Oct-12 9:32am
   
Not clear. please give more details...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Because char *a is a pointer, not a variable. The "garbage" as you call it is the memory address of your data.
In order to see that data you have to dereference your pointer again. Pointers[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Do like this
BSTR s1=interfacepointer->DLL Function
std::wcout <<s1<<std::endl ;
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 9 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100