Hi there

I have a DLL written in C++ which I call in my Embedded Visual Basic
Application. The problem is when I call a particular function from the
DLL which requires an LPTSTR argument. I send the argument as a String
from VB.

It works FINE if I run the Debug-version of the DLL, but when I run
the Release-version of the DLL it sends an empty string to the
function..

Any Ideas for this anomaly..

Cheers
Sid

Re: Release DLL Problem by Michael

Michael
Wed Mar 12 17:23:47 CDT 2008

Impossible to say without seeing the source code. One thing to understand
is that just because something works in debug build, it's not guaranteed to
work ok in retail build - and vice versa.

Most common problem that gets uncovered between debug and retail builds is
uninitialized variables. Check all your member variables to make sure they
are properly initialized. Also check all local variables to ensure they are
properly initialized.

--
Michael Salamone, eMVP
Entrek Software, Inc.
www.entrek.com


"sid" <mailsid@gmail.com> wrote in message
news:a4e9e618-1a11-42f8-a6c3-d37638013e06@s19g2000prg.googlegroups.com...
> Hi there
>
> I have a DLL written in C++ which I call in my Embedded Visual Basic
> Application. The problem is when I call a particular function from the
> DLL which requires an LPTSTR argument. I send the argument as a String
> from VB.
>
> It works FINE if I run the Debug-version of the DLL, but when I run
> the Release-version of the DLL it sends an empty string to the
> function..
>
> Any Ideas for this anomaly..
>
> Cheers
> Sid


Re: Release DLL Problem by sid

sid
Wed Mar 12 18:00:34 CDT 2008

On Mar 12, 10:23=A0pm, "Michael Salamone" <mikesa#at#entrek#dot#com>
wrote:
> Impossible to say without seeing the source code. =A0One thing to understa=
nd
> is that just because something works in debug build, it's not guaranteed t=
o
> work ok in retail build - and vice versa.
>
> Most common problem that gets uncovered between debug and retail builds is=

> uninitialized variables. =A0Check all your member variables to make sure t=
hey
> are properly initialized. =A0Also check all local variables to ensure they=
are
> properly initialized.
>
> --
> Michael Salamone, eMVP
> Entrek Software, Inc.www.entrek.com
>
> "sid" <mail...@gmail.com> wrote in message
>
> news:a4e9e618-1a11-42f8-a6c3-d37638013e06@s19g2000prg.googlegroups.com...
>
>
>
> > Hi there
>
> > I have a DLL written in C++ which I call in my Embedded Visual Basic
> > Application. The problem is when I call a particular function from the
> > DLL which requires an LPTSTR argument. I send the argument as a String
> > from VB.
>
> > It works FINE if I run the Debug-version of the DLL, but when I run
> > the Release-version of the DLL it sends an empty string to the
> > function..
>
> > Any Ideas for this anomaly..
>
> > Cheers
> > Sid- Hide quoted text -
>
> - Show quoted text -

thanks for that..yes i do have many variables in the code both local
and global. there is a strong chance i missed to initialise one or
two. i will check that and see if i find any...


Re: Release DLL Problem by mind_the_gap

mind_the_gap
Thu Mar 13 04:55:02 CDT 2008

On Mar 13, 12:00=A0am, sid <mail...@gmail.com> wrote:
> On Mar 12, 10:23=A0pm, "Michael Salamone" <mikesa#at#entrek#dot#com>
> wrote:
>
>
>
> > Impossible to say without seeing the source code. =A0One thing to unders=
tand
> > is that just because something works in debug build, it's not guaranteed=
to
> > work ok in retail build - and vice versa.
>
> > Most common problem that gets uncovered between debug and retail builds =
is
> > uninitialized variables. =A0Check all your member variables to make sure=
they
> > are properly initialized. =A0Also check all local variables to ensure th=
ey are
> > properly initialized.
>
> > --
> > Michael Salamone, eMVP
> > Entrek Software, Inc.www.entrek.com
>
> > "sid" <mail...@gmail.com> wrote in message
>
> >news:a4e9e618-1a11-42f8-a6c3-d37638013e06@s19g2000prg.googlegroups.com...=

>
> > > Hi there
>
> > > I have a DLL written in C++ which I call in my Embedded Visual Basic
> > > Application. The problem is when I call a particular function from the=

> > > DLL which requires an LPTSTR argument. I send the argument as a String=

> > > from VB.
>
> > > It works FINE if I run the Debug-version of the DLL, but when I run
> > > the Release-version of the DLL it sends an empty string to the
> > > function..
>
> > > Any Ideas for this anomaly..
>
> > > Cheers
> > > Sid- Hide quoted text -
>
> > - Show quoted text -
>
> thanks for that..yes i do have many variables in the code both local
> and global. there is a strong chance i missed to initialise one or
> two. i will check that and see if i find any...

On Problem that got me searching some time and which had sometimes
same effects was that my DLL function declaration reqired a double for
a particular parameter and I, on the C# side, sent an integer - this
had as result that I got sometimes a number and sometimes just zero -
Maybe ou could also look for that :)

Re: Release DLL Problem by sid

sid
Thu Mar 13 10:38:16 CDT 2008

On Mar 13, 9:55=A0am, mind_the_gap <2voo...@gmx.de> wrote:
> On Mar 13, 12:00=A0am, sid <mail...@gmail.com> wrote:
>
>
>
>
>
> > On Mar 12, 10:23=A0pm, "Michael Salamone" <mikesa#at#entrek#dot#com>
> > wrote:
>
> > > Impossible to say without seeing the source code. =A0One thing to unde=
rstand
> > > is that just because something works in debug build, it's not guarante=
ed to
> > > work ok in retail build - and vice versa.
>
> > > Most common problem that gets uncovered between debug and retail build=
s is
> > > uninitialized variables. =A0Check all your member variables to make su=
re they
> > > are properly initialized. =A0Also check all local variables to ensure =
they are
> > > properly initialized.
>
> > > --
> > > Michael Salamone, eMVP
> > > Entrek Software, Inc.www.entrek.com
>
> > > "sid" <mail...@gmail.com> wrote in message
>
> > >news:a4e9e618-1a11-42f8-a6c3-d37638013e06@s19g2000prg.googlegroups.com.=
..
>
> > > > Hi there
>
> > > > I have a DLL written in C++ which I call in my Embedded Visual Basic=

> > > > Application. The problem is when I call a particular function from t=
he
> > > > DLL which requires an LPTSTR argument. I send the argument as a Stri=
ng
> > > > from VB.
>
> > > > It works FINE if I run the Debug-version of the DLL, but when I run
> > > > the Release-version of the DLL it sends an empty string to the
> > > > function..
>
> > > > Any Ideas for this anomaly..
>
> > > > Cheers
> > > > Sid- Hide quoted text -
>
> > > - Show quoted text -
>
> > thanks for that..yes i do have many variables in the code both local
> > and global. there is a strong chance i missed to initialise one or
> > two. i will check that and see if i find any...
>
> On Problem that got me searching some time and which had sometimes
> same effects was that my DLL function declaration reqired a double for
> a particular parameter and I, on the C# side, sent an integer - this
> had as result that I got sometimes a number and sometimes just zero -
> Maybe ou could also look for that :)- Hide quoted text -
>
> - Show quoted text -

I have just looked carefully at the problem. Its the problem with
datatype mismatch.

the c++ function I call from Visual Basic is

Friend Declare Function DoRecognition Lib "CastAPI.dll" (ByVal
ifilename As String, ByVal ofilename As String, _
ByVal windowSize As Integer, ByVal targetRate As Integer, ByVal
sampFrequency As Integer, ByVal preEmCoef As Single, _
ByVal nfBankChannels As Integer, ByVal cepLifter As Integer, ByVal
loFreq As Single, ByVal hiFreq As Single, ByVal warpFreq As Single, _
ByVal numCeps As Integer, ByVal sourceRate As Integer, ByVal
useHamming As Boolean, ByVal useDelta As Boolean, _
ByVal useCMN As Boolean, ByVal beamWidth As Integer, ByVal
pruneModelLimit As Integer) As Boolean

CASTAPI_API BOOL DoRecognition(LPTSTR filename,LPSTR ofilename,DWORD
windowSize,DWORD targetRate,DWORD sampFrequency,
FLOAT preEmCoef,INT nfBankChannels,INT cepLifter,FLOAT
loFreq,FLOAT hiFreq,FLOAT warpFreq,
INT numCeps,WORD sourceRate,BOOL useHamming,BOOL useDelta,BOOL
useCMN,INT beamWidth,INT pruneModelLimit);

The above works perfectly fine with the DEBUG-version of the DLL, but
for Release-version I do not see anything for FLOAT's and
LPTSTR's..they come as blanks or they does not show up at all (like
expression cannot be computed or similar errors)

Any Say

Re: Release DLL Problem by sid

sid
Thu Mar 13 13:08:37 CDT 2008

On 13 Mar, 15:38, sid <mail...@gmail.com> wrote:
> On Mar 13, 9:55=A0am, mind_the_gap <2voo...@gmx.de> wrote:
>
>
>
>
>
> > On Mar 13, 12:00=A0am, sid <mail...@gmail.com> wrote:
>
> > > On Mar 12, 10:23=A0pm, "Michael Salamone" <mikesa#at#entrek#dot#com>
> > > wrote:
>
> > > > Impossible to say without seeing the source code. =A0One thing to un=
derstand
> > > > is that just because something works in debug build, it's not guaran=
teed to
> > > > work ok in retail build - and vice versa.
>
> > > > Most common problem that gets uncovered between debug and retail bui=
lds is
> > > > uninitialized variables. =A0Check all your member variables to make =
sure they
> > > > are properly initialized. =A0Also check all local variables to ensur=
e they are
> > > > properly initialized.
>
> > > > --
> > > > Michael Salamone, eMVP
> > > > Entrek Software, Inc.www.entrek.com
>
> > > > "sid" <mail...@gmail.com> wrote in message
>
> > > >news:a4e9e618-1a11-42f8-a6c3-d37638013e06@s19g2000prg.googlegroups.co=
m...
>
> > > > > Hi there
>
> > > > > I have a DLL written in C++ which I call in my Embedded Visual Bas=
ic
> > > > > Application. The problem is when I call a particular function from=
the
> > > > > DLL which requires an LPTSTR argument. I send the argument as a St=
ring
> > > > > from VB.
>
> > > > > It works FINE if I run the Debug-version of the DLL, but when I ru=
n
> > > > > the Release-version of the DLL it sends an empty string to the
> > > > > function..
>
> > > > > Any Ideas for this anomaly..
>
> > > > > Cheers
> > > > > Sid- Hide quoted text -
>
> > > > - Show quoted text -
>
> > > thanks for that..yes i do have many variables in the code both local
> > > and global. there is a strong chance i missed to initialise one or
> > > two. i will check that and see if i find any...
>
> > On Problem that got me searching some time and which had sometimes
> > same effects was that my DLL function declaration reqired a double for
> > a particular parameter and I, on the C# side, sent an integer - this
> > had as result that I got sometimes a number and sometimes just zero -
> > Maybe ou could also look for that :)- Hide quoted text -
>
> > - Show quoted text -
>
> I have just looked carefully at the problem. Its the problem with
> datatype mismatch.
>
> the c++ function I call from Visual Basic is
>
> =A0 =A0 Friend Declare Function DoRecognition Lib "CastAPI.dll" (ByVal
> ifilename As String, ByVal ofilename As String, _
> =A0 =A0 ByVal windowSize As Integer, ByVal targetRate As Integer, ByVal
> sampFrequency As Integer, ByVal preEmCoef As Single, _
> =A0 =A0 ByVal nfBankChannels As Integer, ByVal cepLifter As Integer, ByVal=

> loFreq As Single, ByVal hiFreq As Single, ByVal warpFreq As Single, _
> =A0 =A0 =A0 ByVal numCeps As Integer, ByVal sourceRate As Integer, ByVal
> useHamming As Boolean, ByVal useDelta As Boolean, _
> =A0 =A0 =A0 ByVal useCMN As Boolean, ByVal beamWidth As Integer, ByVal
> pruneModelLimit As Integer) As Boolean
>
> CASTAPI_API BOOL DoRecognition(LPTSTR filename,LPSTR ofilename,DWORD
> windowSize,DWORD targetRate,DWORD sampFrequency,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0FLOAT preEmCoef,INT=
nfBankChannels,INT cepLifter,FLOAT
> loFreq,FLOAT hiFreq,FLOAT warpFreq,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0INT numCeps,WORD so=
urceRate,BOOL useHamming,BOOL useDelta,BOOL
> useCMN,INT beamWidth,INT pruneModelLimit);
>
> The above works perfectly fine with the DEBUG-version of the DLL, but
> for Release-version I do not see anything for FLOAT's and
> LPTSTR's..they come as blanks or they does not show up at all (like
> expression cannot be computed or similar errors)
>
> Any Say- Hide quoted text -
>
> - Show quoted text -

the problem is solved for now...i have switched of all the compilation
optimisation options..and it compiles and runs well...

the problem is when i optimise hte code for speed or minimum space .
in that case also it compiles well but my function parameters like
float, LPTSTR stops working..

Re: Release DLL Problem by Rick

Rick
Thu Mar 13 14:53:12 CDT 2008

If playing around with debug vs. release or various optimization options
makes it APPEAR to work, then you probably haven't solved the problem,
you've just masked it. Unless you found a compiler bug, your problem is
still there, so you should keep looking for it, otherwise as you add code
you will probably see the problem magically reappear at some point.

"sid" <mailsid@gmail.com> wrote in message
news:b3f7c1b9-4009-4f70-83a5-73b6dadf1164@e10g2000prf.googlegroups.com...
the problem is solved for now...i have switched of all the compilation
optimisation options..and it compiles and runs well...

the problem is when i optimise hte code for speed or minimum space .
in that case also it compiles well but my function parameters like
float, LPTSTR stops working..



Re: Release DLL Problem by Mike

Mike
Thu Mar 13 15:20:52 CDT 2008

sid wrote:
> Hi there
>
> I have a DLL written in C++ which I call in my Embedded Visual Basic
> Application. The problem is when I call a particular function from the
> DLL which requires an LPTSTR argument. I send the argument as a String
> from VB.
>
> It works FINE if I run the Debug-version of the DLL, but when I run
> the Release-version of the DLL it sends an empty string to the
> function..
>
> Any Ideas for this anomaly..

I've only used un-embedded VB. How do you import the function within VB
(specifying the DLL name)?

Mike.




Re: Release DLL Problem by Mike

Mike
Wed Mar 12 14:54:58 CDT 2008

sid wrote:
> Hi there
>
> I have a DLL written in C++ which I call in my Embedded Visual Basic
> Application. The problem is when I call a particular function from the
> DLL which requires an LPTSTR argument. I send the argument as a String
> from VB.
>
> It works FINE if I run the Debug-version of the DLL, but when I run
> the Release-version of the DLL it sends an empty string to the
> function..
>
> Any Ideas for this anomaly..

I've only used un-embedded VB. How do you import the function within VB
(specifying the DLL name)?

Mike.



Re: Release DLL Problem by Mike

Mike
Thu Mar 13 16:23:29 CDT 2008

Rick C wrote:
> If playing around with debug vs. release or various optimization
> options makes it APPEAR to work, then you probably haven't solved the
> problem, you've just masked it. Unless you found a compiler bug,
> your problem is still there, so you should keep looking for it,
> otherwise as you add code you will probably see the problem magically
> reappear at some point.
> "sid" <mailsid@gmail.com> wrote in message
> news:b3f7c1b9-4009-4f70-83a5-73b6dadf1164@e10g2000prf.googlegroups.com...
> the problem is solved for now...i have switched of all the compilation
> optimisation options..and it compiles and runs well...
>
> the problem is when i optimise hte code for speed or minimum space .
> in that case also it compiles well but my function parameters like
> float, LPTSTR stops working..

I think if I had that problem I'd write a test harness program in C++ to
test the DLL functions at least to isolate any VB interfacing problems from
any that are down solely to C++ optimisation, variable iniitialisation and
pitfalls that others have mentioned.

Mike.