From: Marc Hillman on
I've been bashing my head up against a brick wall for 4 days, and I've
reached the limit of my frustration and knowledge. I'd appreciate some ideas
on what I'm doing wrong.

I have a simple Visual Basic Express 2008 program. It calls a DLL (supplied
by others). Calls to the DLL in small (trivial) programs work fine. When the
program grows in size I get a "vshost.exe has stopped working" message. It
happens when I call any dll function that tries to return a string. I have
googled and tried everything.

The full program is a few thousand lines, much of it auto coded because of
database access, but the critical bits are below.

In fileOziExplorer.vb
Imports System.Text
Module OziExplorer
Declare Ansi Function oziGetOziVersion Lib "oziapi" (ByRef Version As
StringBuilder, ByRef DataLength As Integer) As Integer
End Mdule

In file Form1.vb
Dim oziVersion As New StringBuilder(250), vDatalength As Integer
i = oziGetOziVersion(oziVersion, vDatalength)

When the i=oziGetOziVersion is called I get the vshost error message.

I have hacked vshost.exe to disable DEP.

I'm totally out of ideas. All the obvious fixes have been tried.



From: Armin Zingler on
Am 02.03.2010 13:20, schrieb Marc Hillman:
> I've been bashing my head up against a brick wall for 4 days, and I've
> reached the limit of my frustration and knowledge. I'd appreciate some ideas
> on what I'm doing wrong.

You're bashing your head against the wall. ;)

> I have a simple Visual Basic Express 2008 program. It calls a DLL (supplied
> by others). Calls to the DLL in small (trivial) programs work fine. When the
> program grows in size I get a "vshost.exe has stopped working" message. It
> happens when I call any dll function that tries to return a string. I have
> googled and tried everything.
>
> The full program is a few thousand lines, much of it auto coded because of
> database access, but the critical bits are below.
>
> In fileOziExplorer.vb
> Imports System.Text
> Module OziExplorer
> Declare Ansi Function oziGetOziVersion Lib "oziapi" (ByRef Version As
> StringBuilder, ByRef DataLength As Integer) As Integer

Try
BYVAL Version As StringBuilder

> End Mdule
>
> In file Form1.vb
> Dim oziVersion As New StringBuilder(250), vDatalength As Integer
> i = oziGetOziVersion(oziVersion, vDatalength)
>
> When the i=oziGetOziVersion is called I get the vshost error message.
>
> I have hacked vshost.exe to disable DEP.
>
> I'm totally out of ideas. All the obvious fixes have been tried.


--
Armin
From: Marc Hillman on
Good news and bad news.

The app no longer crashes, but the return results are curious. For the line
i = oziGetOziVersion(oziVersion, vDatalength)

1. vDatalength is 0
2. when I assign st (a string)=oziVersion.tostring the result is gibberish
3. oziVersion.Length is correct (6)

I think I'm close. How do I get the string out of the StringBuilder?

(and thanks heaps for your really rapid response)

"Armin Zingler" <az.nospam(a)freenet.de> wrote in message
news:OzXKXOguKHA.6124(a)TK2MSFTNGP04.phx.gbl...
> Am 02.03.2010 13:20, schrieb Marc Hillman:
>> I've been bashing my head up against a brick wall for 4 days, and I've
>> reached the limit of my frustration and knowledge. I'd appreciate some
>> ideas
>> on what I'm doing wrong.
>
> You're bashing your head against the wall. ;)
>
>> I have a simple Visual Basic Express 2008 program. It calls a DLL
>> (supplied
>> by others). Calls to the DLL in small (trivial) programs work fine. When
>> the
>> program grows in size I get a "vshost.exe has stopped working" message.
>> It
>> happens when I call any dll function that tries to return a string. I
>> have
>> googled and tried everything.
>>
>> The full program is a few thousand lines, much of it auto coded because
>> of
>> database access, but the critical bits are below.
>>
>> In fileOziExplorer.vb
>> Imports System.Text
>> Module OziExplorer
>> Declare Ansi Function oziGetOziVersion Lib "oziapi" (ByRef Version As
>> StringBuilder, ByRef DataLength As Integer) As Integer
>
> Try
> BYVAL Version As StringBuilder
>
>> End Mdule
>>
>> In file Form1.vb
>> Dim oziVersion As New StringBuilder(250), vDatalength As Integer
>> i = oziGetOziVersion(oziVersion, vDatalength)
>>
>> When the i=oziGetOziVersion is called I get the vshost error message.
>>
>> I have hacked vshost.exe to disable DEP.
>>
>> I'm totally out of ideas. All the obvious fixes have been tried.
>
>
> --
> Armin

From: Armin Zingler on
Am 02.03.2010 14:01, schrieb Marc Hillman:
> Good news and bad news.
>
> The app no longer crashes, but the return results are curious. For the line
> i = oziGetOziVersion(oziVersion, vDatalength)
>
> 1. vDatalength is 0
> 2. when I assign st (a string)=oziVersion.tostring the result is gibberish
> 3. oziVersion.Length is correct (6)
>
> I think I'm close. How do I get the string out of the StringBuilder?

I had searched for the function declaration and found

function oziGetOziVersion(var Version:pansichar;var DataLength:integer):integer;stdcall;


I'm not sure how to translate "var Version:pansichar". I guess that "p"ansichar is a
pointer to an ANSI char/string. In addition, var means it's passed by reference.
So a pointer to a pointer is passed, right? By heart, I don't know how to declare it
with the type String(builder). Anyone?


--
Armin
From: Jason Keats on
Marc Hillman wrote:
> I've been bashing my head up against a brick wall for 4 days, and I've
> reached the limit of my frustration and knowledge. I'd appreciate some
> ideas on what I'm doing wrong.
>
> I have a simple Visual Basic Express 2008 program. It calls a DLL
> (supplied by others). Calls to the DLL in small (trivial) programs work
> fine. When the program grows in size I get a "vshost.exe has stopped
> working" message. It happens when I call any dll function that tries to
> return a string. I have googled and tried everything.
>
> The full program is a few thousand lines, much of it auto coded because
> of database access, but the critical bits are below.
>
> In fileOziExplorer.vb
> Imports System.Text
> Module OziExplorer
> Declare Ansi Function oziGetOziVersion Lib "oziapi" (ByRef Version As
> StringBuilder, ByRef DataLength As Integer) As Integer
> End Mdule
>
> In file Form1.vb
> Dim oziVersion As New StringBuilder(250), vDatalength As Integer
> i = oziGetOziVersion(oziVersion, vDatalength)
>
> When the i=oziGetOziVersion is called I get the vshost error message.
>
> I have hacked vshost.exe to disable DEP.
>
> I'm totally out of ideas. All the obvious fixes have been tried.
>
>
>

Have you read the documentation?

http://www.oziexplorer3.com/oziapi/oziapi_docs.html#oziGetOziVersion

For starters, I would change "As StringBuilder" to "As String".