app path stopped working

Hi All,
I have :
GetExecutingAssembly.GetName.Name
Which was returning the application path.
Now for some reason it's returning windows\system32 ??
[188 byte] By [Bill Crawley] at [2007-11-19 14:06:08]
# 1 Re: app path stopped working
GetExecutingAssembly.GetName.Name
This should return the name of the Assembly.

Now for some reason it's returning windows\system32 ?? Either the folder oesn't exist or the way you are trying to access the file is not correct.

A code snippet would be helpful.
Shuja Ali at 2007-11-10 3:16:01 >
# 2 Re: app path stopped working
Dim objXML As DataSet

objXML = New DataSet

objXML.ReadXml(String.Concat(GetExecutingAssembly.GetName.Name, ".xml"))

I'm trying to load my XML file and it's in the app path.

the exception shows that it's trying to get the file at

c:\windows\system32\ypprocess.xml

I'm running from

c:\work\YPprocess

and expect to see c:\work\YPprocess\ypprocess.xml
Bill Crawley at 2007-11-10 3:17:12 >
# 3 Re: app path stopped working
Bill Crawley,
Application.StartupPath does not work?
DeepButi at 2007-11-10 3:18:08 >
# 4 Re: app path stopped working
sorry DeepButi,

I dont understand your answer. there isn't an application.startuppath is there??
Bill Crawley at 2007-11-10 3:19:14 >
# 5 Re: app path stopped working
HereobjXML.ReadXml(String.Concat(GetExecutingAssembly.GetName.Name, ".xml")) You are just passing the name of the assembly and not the whole path, So your application looks up for the file in System32 folder. And as the file doesn't exist there so you are getting this error.

Try this instead
objXML.ReadXML(String.Concat(Application.StartupPath, "\", System.Reflection.Assembly.GetExecutingAssembly.GetName.Name, ".xml"))
Shuja Ali at 2007-11-10 3:20:09 >
# 6 Re: app path stopped working
it say application doesn't exist.

I had the original declaration in a standard class project, Now I'm using a class in an asp.net project
Bill Crawley at 2007-11-10 3:21:09 >
# 7 Re: app path stopped working
it say application doesn't exist.

I had the original declaration in a standard class project, Now I'm using a class in an asp.net project
oops.. if it is an ASP.NET application, then Application.Path won't be present there.
Shuja Ali at 2007-11-10 3:22:10 >
# 8 Re: app path stopped working
thought I might be able to use System.IO.Directory.GetCurrentDirectory but that seems to be empty
Bill Crawley at 2007-11-10 3:23:13 >
# 9 Re: app path stopped working
Did you try using System.Reflection.Assembly.GetExecutingAssembly.GetExecutingAssembly.Location
Shuja Ali at 2007-11-10 3:24:11 >
# 10 Re: app path stopped working
using this i get

"Could not find file "c:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net files\ypprocess\52e39826\42a464b0\assembly\dl2\3744c7a8\9e7dc7f4_b1c9c501\ypprocess.xml"."
Bill Crawley at 2007-11-10 3:25:20 >
# 11 Re: app path stopped working
ok,

Have found the answer with the aid of another site.

in the global.asax.vb file declare a public shared variable, then in the session.start set the variable to the request.PhysicalApplicationPath

THen in the class just use this variable and it works.
Bill Crawley at 2007-11-10 3:26:19 >
# 12 Re: app path stopped working
You could also use this
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)
Shuja Ali at 2007-11-10 3:27:17 >