[Help] Cannot retrieve a bstr* via com interface into a system.string in vb.net

Hello Everyone,

I am getting the following issue:
Cannot retrieve a bstr* via com interface into a system.string in vb.net

I tryed to use StringBuilder but then I get a compilation error.
I also did:  

Dim Str as String = nothing

--> result: nothing

Is there an equivalent like in c# using [ref] - > myobj.getMessage(ref Str);  where this works as expected.

All inputs are welcome.
Thank you very much in advance.
Best regards
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dim Str as String = "something"
If you pass Nothing as a reference, your method might have trouble with it.
festijazzAuthor Commented:
this solution does not work, I get something back as result. This does not modify the string.

please help.
thank you.
Best regards.
But you are not getting the string itself, rather you are getting the pointer.  You need to retrieve the string value from the memory location that the pointer references.  For that, .NET has some ready made helper methods in the System.Runtime.InteropServices namespace.  The one that is of benefit to you is Marshal.PtrToStringBSTR(IntPtr).

Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

festijazzAuthor Commented:
Thank you for your comment, I just found the issue.  It was not possible as like vb6 it won't work the same way.  It was related to the odl definition.  The parameter was only set [in] but should be [in, out].  Now it works nicely.

Thank you for your inputs but it related to the unmanaged code.
Hopefully not a big change to cover it.
Best regards.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
festijazzAuthor Commented:
This might be closed.
Glad you got it sorted out.

Author solved the issue on their own.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.