I have an third part dll that have a function that returns a string. When I call the function I got for example ‘123456’ back. At least it seams like that, but when i do mystring.length it does not return any length. If I set the text property of a label it shows ‘123456’.
When I have the string I got from the dll I send it to a webservice function:
rem call dll and get string dim mystring as string=mydll.getstring() rem Send it to the webservice webservice.SaveString(mystring)
The webservice crashes with an webexeption (‘protocoll error’) when I send in the string I got from the dll. If I instead send it like this:
rem call dll and get string dim mystring as string=mydll.getstring() rem Send it to the webservice dim FixedString as string = mid(mystring,1,6) webservice.SaveString(mystring)
Then it works and everything is fine. That leads me to think that the string I got from the DLL is in someway not terminated correct. And I dont know how to fix it from vb.net (I cant change the DLL) and I dont know in beforehand how long the string will be.
The dll does only work on site when specific hardware is connected so I can’t sit at the office trying to fix this in dev-environment. So I would like to have some possibly solutions to this before I go to the customer again.
Edit 1: I tried to just do a loop that looped from 1 to 100 (because I dont know the real length) and tried to copy all characters that <>” to a new variable but it didnt work. I didnt try other variants because the day was over and I had to leave the customer site.
Edit 2:
The DLL Im talking to is made in VB6. That DLL is talking to other DLLs that is made in C++ (I think).
My program < – > vb6-DLL <-> c++-DLL <-> hardware
Check out the MSDN documentation about strings, especially the part about:
Instead I’d do something like:
(Note: I haven’t tried this)