Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ASP.NET runtime hosting problem

5 views
Skip to first unread message

PJ on Development

unread,
May 2, 2008, 4:15:57 PM5/2/08
to
I've created a stand alone Web Server using HttpListener and
System.Web.Hosting, but I'm stuck with the following error.

The path '/App_GlobalResources/' maps to a directory outside this
application, which is not supported.

The StackTrace is as follows:

[HttpException (0x80004005): The path '/App_GlobalResources/' maps to
a directory outside this application, which is not supported.]

System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath
virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet
excludedSubdirectories, Boolean isDirectoryAllowed) +739

System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath
virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet
excludedSubdirectories) +199
System.Web.Compilation.BuildManager.CompileResourcesDirectory() +53
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
+385

[HttpException (0x80004005): The path '/App_GlobalResources/' maps to
a directory outside this application, which is not supported.]

System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()
+81
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
+525
System.Web.Compilation.BuildManager.GetGlobalAsaxTypeInternal() +25
System.Web.Compilation.BuildManager.GetGlobalAsaxType() +28
System.Web.HttpApplicationFactory.CompileApplication() +29
System.Web.HttpApplicationFactory.Init() +128
System.Web.HttpApplicationFactory.EnsureInited() +81

System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext
context) +100
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
+353

I've searched the web for the past two days with no luck in finding a
definitive solution.

Most of the solutions I find does not apply, becuase they are to the
stablished IIS, not a stand alone Web Server running using
System.Web.Hosting.

In order to create the AppDomain I use the following code:

Private Function CreateApplicationHost(ByVal hostType As Type, _
ByVal virtualPath As String, _
ByVal physicalPath As String)
As Object

If (Not physicalPath.EndsWith("\")) Then
physicalPath &= "\"
End If

Dim aspDir = System.Web.HttpRuntime.AspInstallDirectory
Dim domainId =
DateTime.Now.ToString(Globalization.DateTimeFormatInfo.InvariantInfo).GetHashCode().ToString("x")
Dim appName = (virtualPath &
physicalPath).GetHashCode().ToString("x")

Dim setup = New AppDomainSetup()
setup.ApplicationName = appName
setup.ConfigurationFile = physicalPath & "web.config"

Dim ad = AppDomain.CreateDomain(domainId, Nothing, setup)
ad.SetData(".appDomain", "*")
ad.SetData(".appId", domainId)
ad.SetData(".appPath", physicalPath)
ad.SetData(".appVPath", virtualPath)
ad.SetData(".domainId", domainId)
ad.SetData(".hostingVirtualPath", virtualPath)
ad.SetData(".hostingInstallDir", aspDir)

Return ad.CreateInstance(hostType.Module.Assembly.FullName,
hostType.FullName).Unwrap

End Function

The code above create the AppDomain nicely, but fails when I call the
ProcessRequest Function below:

Public Sub ProcessRequest(ByVal page As String, _
ByVal query As String, _
ByVal output As IO.TextWriter)

'*
'* Fix the parameters
'*
If page.StartsWith("/") Then page = page.Substring(1)
If Not String.IsNullOrEmpty(query) AndAlso query.StartsWith("?")
Then query = query.Substring(1)

'*
'* Process the request
'*
Try
Dim swr = New System.Web.Hosting.SimpleWorkerRequest(page,
query, output)
System.Web.HttpRuntime.ProcessRequest(swr)
Catch ex As Exception
My.Application.Log.WriteException(ex, TraceEventType.Warning,
ex.StackTrace)
End Try

End Sub

I really don't knwo what else to do.

Does anyone have some pointers on it?

Regards,

Paulo Santos
http://pjondevelopment.50webs.com

0 new messages