Different variable results in debugger than in application

G

Guest

Hi,
I'm making some minor changes to a VB 6 app that I converted to VB .NET a
couple of years ago and I'm running into an issue with a function that is
seemingly returning a different result in the debugger than when I run the
exe.

The code in question is this;
iniFileName =
Replace(System.Reflection.Assembly.GetExecutingAssembly.Location, ".exe", "")
& ".ini"
This is how I had the code originally and when I run it in the debugger, I
have no problems but when I run the EXE, I get the message
c:\bin\vtexvip.exe.ini not found but it seems to be in XP Pro SP2 only. If I
run it under W2K (Where the app will be run),I have no problems. In the
debugger, the variable inifilename shows the correct value of
c:\bin\vtexvip.ini. This is driving me cookoo.
I decided to change the above code to the following;
iniFileName =
Replace(System.Reflection.Assembly.GetExecutingAssembly.Location, ".exe",
".ini")
but this doesn't work at all. Although once again, in the debugger, the
variable inifilename shows the correct value of c:\bin\vtexvip.ini.
This is just a small app and is running on W2K where the problem does not
seem to exist but eventually, I may need to run it on XP and would like to
address this issue now rather that later so if anyone has any suggestions, it
would be really appreciated.

Thanks a bunch.
 
K

Ken Tucker [MVP]

Hi,

Try this instead.

iniFileName =
Replace(System.Reflection.Assembly.GetEntryAssembly.Location, ".exe",
".ini")

Ken
-----------------
Hi,
I'm making some minor changes to a VB 6 app that I converted to VB .NET a
couple of years ago and I'm running into an issue with a function that is
seemingly returning a different result in the debugger than when I run the
exe.

The code in question is this;
iniFileName =
Replace(System.Reflection.Assembly.GetExecutingAssembly.Location, ".exe",
"")
& ".ini"
This is how I had the code originally and when I run it in the debugger, I
have no problems but when I run the EXE, I get the message
c:\bin\vtexvip.exe.ini not found but it seems to be in XP Pro SP2 only. If I
run it under W2K (Where the app will be run),I have no problems. In the
debugger, the variable inifilename shows the correct value of
c:\bin\vtexvip.ini. This is driving me cookoo.
I decided to change the above code to the following;
iniFileName =
Replace(System.Reflection.Assembly.GetExecutingAssembly.Location, ".exe",
".ini")
but this doesn't work at all. Although once again, in the debugger, the
variable inifilename shows the correct value of c:\bin\vtexvip.ini.
This is just a small app and is running on W2K where the problem does not
seem to exist but eventually, I may need to run it on XP and would like to
address this issue now rather that later so if anyone has any suggestions,
it
would be really appreciated.

Thanks a bunch.
 
A

Armin Zingler

Ryan Gaudet said:
Hi,
I'm making some minor changes to a VB 6 app that I converted to VB
.NET a couple of years ago and I'm running into an issue with a
function that is seemingly returning a different result in the
debugger than when I run the exe.

The code in question is this;
iniFileName =
Replace(System.Reflection.Assembly.GetExecutingAssembly.Location,
".exe", "") & ".ini"
This is how I had the code originally and when I run it in the
debugger, I have no problems but when I run the EXE, I get the
message
c:\bin\vtexvip.exe.ini not found but it seems to be in XP Pro SP2
only. If I run it under W2K (Where the app will be run),I have no
problems. In the debugger, the variable inifilename shows the
correct value of
c:\bin\vtexvip.ini. This is driving me cookoo.
I decided to change the above code to the following;
iniFileName =
Replace(System.Reflection.Assembly.GetExecutingAssembly.Location,
".exe", ".ini")
but this doesn't work at all. Although once again, in the debugger,
the variable inifilename shows the correct value of
c:\bin\vtexvip.ini. This is just a small app and is running on W2K
where the problem does not seem to exist but eventually, I may need
to run it on XP and would like to address this issue now rather that
later so if anyone has any suggestions, it would be really
appreciated.



Maybe the upper/lower case does not match on different machines? ".exe",
".Exe" etc.


There shouldn't be a difference because, in opposite to VB6, the code is
compiled to an Exe even when started from the debugger and not interpreted
anymore.


Try


iniFileName = System.IO.Path.ChangeExtension( _
System.Reflection.Assembly.GetExecutingAssembly.Location, _
".ini" _
)





Armin
 
H

Herfried K. Wagner [MVP]

Ken Tucker said:
Try this instead.

iniFileName =
Replace(System.Reflection.Assembly.GetEntryAssembly.Location, ".exe",
".ini")

I would use the according methods of the 'System.IO.Path' class to remove
and replace the exension. Otherwise the code will fail if the path contains
".exe" somewhere in a folder name.

Just my 2 Euro cents...
 
G

Guest

After changing the code to use the System.IO call instead, it appears to be
working.
Thanks a bunch for your quick responses.
Ryan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top