Ask a Question related to ASP.NET Security, Design and Development.
-
news.iq.ca #1
The process aspnet_wp is a surviver !
Hi. I am trying to use a treeview - after a few attempts, it works, but only
up to a point - my exercise was to dynamically create nodes in the treeview.
I read about binding the treeview to a XML file. Okay, so I decided to
complicate my exercise and to create the XML file on the fly. I am using
this code to browse through the list of my other projects, create the XML
file and then populate the treeview. I am not using the XML writer object
because I did not reach that point with my learning, so I am writing it "the
old way":
<code>
Private m_strPath As String = "C:\Documents and
Settings\Administrator\My Documents\My
Projects\ASPNETProjects\vsnet\ThirdPartyControls\T reeNodes.XML"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
CreateXMLFile()
TreeView1.TreeNodeSrc = m_strPath
TreeView1.DataBind()
End If
End Sub
Private Sub CreateXMLFile()
Dim objDirectory As Directory
Dim ProjectInfo As FileInfo
Dim lstFiles As String()
Dim strProjectLongName As String
Dim strProjectShortName As String
Dim strmFile As StreamWriter
Dim objStringBuilder As New StringBuilder()
Const PROJECTS_PATH As String = "C:\Documents and
Settings\Administrator\My Documents\My Projects\ASPNETProjects\notepad\"
strmFile = File.CreateText(m_strPath)
strmFile.WriteLine("<TREENODES>")
strmFile.WriteLine("<TREENODE TEXT=""ASP.NET PROJECTS"">")
lstFiles = objDirectory.GetFiles(PROJECTS_PATH, "*.aspx")
For Each strProjectLongName In lstFiles
ProjectInfo = New FileInfo(strProjectLongName)
strProjectShortName = ProjectInfo.Name
objStringBuilder = New StringBuilder()
objStringBuilder.Append("<TREENODE TEXT=""" &
strProjectShortName & """ NAVIGATEURL =
""HTTP:\\LOCALHOST\ASPNETPROJECTS\NOTEPAD\")
objStringBuilder.Append(strProjectShortName)
objStringBuilder.Append("""" & "/>")
strmFile.WriteLine(objStringBuilder.ToString)
Next strProjectLongName
strmFile.WriteLine("</TREENODE>")
strmFile.Write("</TREENODES>")
strmFile.Flush()
strmFile.Close()
strmFile = Nothing
objStringBuilder = Nothing
lstFiles = Nothing
objDirectory = Nothing
End Sub
</code>
This code works fine, but ... if I run the application one more time, I get:
________________________________________________
Exception Details: System.IO.IOException: The process cannot access the file
"C:\Documents and Settings\Administrator\My Documents\My
Projects\ASPNETProjects\vsnet\ThirdPartyControls\T reeNodes.XML" because it
is being used by another process.
________________________________________________
I also discovered that I can't even delete the "TreeNodes.XML" file IN
EXPLORER (!) because the file is locked.. VERY STRANGE - this happens EVEN
if I close VS.NET !
I discovered that the only way out is to kill the process "aspnet_wp" in
task manager - it gets recreated instantly, even with VS.NET closed (!?),
but at least I can now delete the file in Explorer. So the sequence to make
it work is this: run the app the first time - stop it - kill the aspnet_wp
process (it gets recreated) - now I can run the app again without having the
above-mentioned error.
What's with this lock ??? Am I doing something wrong in this code ? I even
set to nothing almost all objects in my app, except the strings, even if
this is useless....
Thank you.
Alex.
news.iq.ca Guest
-
Must manually attach to ASPNET_WP process to debug ASP.NET code
We're using Visual Studio 2003 .NET (C#) on Windows XP Pro SP2. We have a smart client (WinForms) application that calls an ASP.NET web service. On... -
aspnet_wp process recycles itself
Hi, We have a webservice in c# which makes use of XML and COM objects. The MemoryLimit in processModel in machine.config is set to the default of... -
worker process aspnet_wp.exe identity
If the woker process is configured to be run under username="machine" in machine.config and impersonate=true under web.config, will the impersonated... -
debugger not automatically attaching aspnet_wp.exe as a debugged process
Hi-- All of sudden (?) the VS.NET v1 IDE is NOT automatically attaching aspnet_wp.exe as a debugged process. Why? Here is the situation. ... -
Unloading web application instance w/o trashing aspnet_wp process
I have a simple question for the right person, is there a way to unload an application (the resources held by a single virtual directory) from some... -
Jiri Richter [MSFT] #2
Re: The process aspnet_wp is a surviver !
Alex,
The aspnet_wp process is part of ASP.Net and is responsible for executing
the code behind your page. Here's what I think is happening with the lock.
When you set the TreeNodeSrc property and call DataBind method of the
TreeView object the object open the XML file and doesn't close it. It seems
that the TreeNodeSrc property can be assigned either a file name or directly
the XML data as a System.String. You can try that to get around the issue
with the lock.
--
Jiri Richter
Microsoft Corp.
This posting is provided "AS IS" with no warranties, and confers no rights.
"news.iq.ca" <REMOVETHIScuca_macaii2000@yahoo.com> wrote in message
news:41c12a17$1_4@aeinews....> Hi. I am trying to use a treeview - after a few attempts, it works, but
> only up to a point - my exercise was to dynamically create nodes in the
> treeview. I read about binding the treeview to a XML file. Okay, so I
> decided to complicate my exercise and to create the XML file on the fly. I
> am using this code to browse through the list of my other projects, create
> the XML file and then populate the treeview. I am not using the XML writer
> object because I did not reach that point with my learning, so I am
> writing it "the old way":
>
> <code>
> Private m_strPath As String = "C:\Documents and
> Settings\Administrator\My Documents\My
> Projects\ASPNETProjects\vsnet\ThirdPartyControls\T reeNodes.XML"
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> If Not IsPostBack Then
> CreateXMLFile()
> TreeView1.TreeNodeSrc = m_strPath
> TreeView1.DataBind()
> End If
> End Sub
>
> Private Sub CreateXMLFile()
>
> Dim objDirectory As Directory
> Dim ProjectInfo As FileInfo
>
> Dim lstFiles As String()
> Dim strProjectLongName As String
> Dim strProjectShortName As String
>
> Dim strmFile As StreamWriter
> Dim objStringBuilder As New StringBuilder()
>
> Const PROJECTS_PATH As String = "C:\Documents and
> Settings\Administrator\My Documents\My Projects\ASPNETProjects\notepad\"
>
> strmFile = File.CreateText(m_strPath)
> strmFile.WriteLine("<TREENODES>")
> strmFile.WriteLine("<TREENODE TEXT=""ASP.NET PROJECTS"">")
>
> lstFiles = objDirectory.GetFiles(PROJECTS_PATH, "*.aspx")
> For Each strProjectLongName In lstFiles
> ProjectInfo = New FileInfo(strProjectLongName)
> strProjectShortName = ProjectInfo.Name
> objStringBuilder = New StringBuilder()
> objStringBuilder.Append("<TREENODE TEXT=""" &
> strProjectShortName & """ NAVIGATEURL =
> ""HTTP:\\LOCALHOST\ASPNETPROJECTS\NOTEPAD\")
> objStringBuilder.Append(strProjectShortName)
> objStringBuilder.Append("""" & "/>")
> strmFile.WriteLine(objStringBuilder.ToString)
> Next strProjectLongName
>
> strmFile.WriteLine("</TREENODE>")
> strmFile.Write("</TREENODES>")
> strmFile.Flush()
>
> strmFile.Close()
> strmFile = Nothing
> objStringBuilder = Nothing
> lstFiles = Nothing
> objDirectory = Nothing
> End Sub
> </code>
>
> This code works fine, but ... if I run the application one more time, I
> get:
> ________________________________________________
> Exception Details: System.IO.IOException: The process cannot access the
> file "C:\Documents and Settings\Administrator\My Documents\My
> Projects\ASPNETProjects\vsnet\ThirdPartyControls\T reeNodes.XML" because it
> is being used by another process.
> ________________________________________________
>
> I also discovered that I can't even delete the "TreeNodes.XML" file IN
> EXPLORER (!) because the file is locked.. VERY STRANGE - this happens EVEN
> if I close VS.NET !
>
> I discovered that the only way out is to kill the process "aspnet_wp" in
> task manager - it gets recreated instantly, even with VS.NET closed (!?),
> but at least I can now delete the file in Explorer. So the sequence to
> make it work is this: run the app the first time - stop it - kill the
> aspnet_wp process (it gets recreated) - now I can run the app again
> without having the above-mentioned error.
>
> What's with this lock ??? Am I doing something wrong in this code ? I even
> set to nothing almost all objects in my app, except the strings, even if
> this is useless....
>
> Thank you.
> Alex.
>
Jiri Richter [MSFT] Guest



Reply With Quote

