Application.ExecutablePath throws ArgumentException: Illegal characters in path.]

T

Thomas

Hi,

I have written a simple web application in asp.net 1.1.4322. following
is the code written in Page_Load

private void Page_Load(object sender, System.EventArgs e)
{
string str = System.Windows.Forms.Application.ExecutablePath
Response.Write(str);
}

string str = System.Windows.Forms.Application.ExecutablePath statement
throws following exception
-- System.ArgumentException: Illegal characters in path

What could be the reason behind this? This method is used in our web
application to get the calling applications name (aspnet_wp or
w3wp.exe).
Please help as this need to be resolved as soon as possible.

Stack trace Detail

[ArgumentException: Illegal characters in path.]

System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[]
str) +276

System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess
access, String[] pathListOrig, Boolean checkForDuplicates, Boolean
needFullPath, Boolean copyPathList) +88

System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess
access, String[] pathList, Boolean checkForDuplicates, Boolean
needFullPath) +43
System.IO.Path.GetFullPath(String path) +82
System.Windows.Forms.IntSecurity.UnsafeGetFullPath(String fileName)
+83
System.Windows.Forms.Application.get_ExecutablePath() +148
Path.WebForm1.Page_Load(Object sender, EventArgs e) in
f:\temp\path\webform1.aspx.cs:23
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
 
T

Tim_Mac

i don't really like the idea of using a property designed for Windows Forms
in an Asp.Net web application, not surprised it bails out on you! this
should give you the info you want:
System.Diagnostics.Process.GetCurrentProcess().ProcessName

hope this helps
tim
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top