473,385 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Hosting ASP.Net fails after upgrade to .Net 2

I have been hosting ASP.Net in my app for some time, with no problems, with
framework 1.1 (VS 2003). Having just upgraded to 2.0 (VS 2005), and it now
gives this error:

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

The ApplicationBase for my app is "/MyApp" so the statement in the error
message would appear to be incorrect. I have no explicit mapping for
"App_GlobalResources". It makes no difference whether the subfolder actually
exists.

Here's the code that creates the host:

public static Host Create(Type HostType, string VirtualDir, string
PhysicalDir, string AppBase, string BinPath)
{
if (!PhysicalDir.EndsWith("\\"))
PhysicalDir += "\\";

string aspDir = HttpRuntime.AspInstallDirectory;
string domainId = "ASPHOST_" +
DateTime.Now.ToString().GetHashCode().ToString("x" );
string appName = (VirtualDir + PhysicalDir).GetHashCode().ToString("x");
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationName = appName;
setup.ConfigurationFile = "web.config";
setup.ApplicationBase = AppBase!=null ? AppBase : (AppBase = PhysicalDir);
setup.PrivateBinPath = BinPath!=null ? BinPath : AppBase + "bin";
setup.PrivateBinPathProbe = "*"; // if non-blank, excludes AppBase from
search path, so only looks in PrivateBinPath.
setup.DisallowCodeDownload = true;

AppDomain ad = AppDomain.CreateDomain(domainId, null, setup);
ad.SetData(".appDomain", "*");
ad.SetData(".appPath", PhysicalDir);
ad.SetData(".appVPath", VirtualDir);
ad.SetData(".domainId", domainId);

// VS2003 only:
//ad.SetData(".hostingVirtualPath", VirtualDir);
//ad.SetData(".hostingInstallDir", aspDir);

// VS2005 only:
ad.SetData(".appId", appName);
string dataDir = PhysicalDir + "App_Data";
ad.SetData("DataDirectory", dataDir, new
System.Security.Permissions.FileIOPermission(Syste m.Security.Permissions.FileIOPermissionAccess.Path Discovery,
dataDir));

Host host =
(Host)ad.CreateInstanceAndUnwrap(HostType.Module.A ssembly.FullName,
HostType.FullName);
return host;
}

The other way to create a host is to use the ApplicationHost CLR class, as
in the following code, whic does work. It is simpler, but does not allow
control of PrivateBinPath. By the time CreateApplicationHost returns,
assemblies have been loaded in the new AppDomain, so it is too late to set
it. That's why I need to use the above method.

public static Host Create(Type HostType, string VirtualDir, string
PhysicalDir)
{
Host newHost = (Host)ApplicationHost.CreateApplicationHost(HostTy pe,
VirtualDir, PhysicalDir);
return newHost;
}

The line 'ad.SetData("DataDirectory" ...etc.' in the first method makes no
difference, I included it in an attempt to mimic the AppDomain created by
the second method (I saw in the debugger that it added such an entry).
Granting 'AllAccess' instead of 'PathDiscovery' makes no difference either.

Thanks
Paul Newman


Oct 20 '06 #1
1 2694
"Paul Newman" <pnewman@aurora-solutions_NoSpamPlease.netwrote in message
news:FU******************@newsfe7-win.ntli.net...
>I have been hosting ASP.Net in my app for some time, with no problems, with
framework 1.1 (VS 2003). Having just upgraded to 2.0 (VS 2005), and it now
gives this error:

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

The ApplicationBase for my app is "/MyApp" so the statement in the error
message would appear to be incorrect. I have no explicit mapping for
"App_GlobalResources". It makes no difference whether the subfolder
actually
exists.

Here's the code that creates the host:

public static Host Create(Type HostType, string VirtualDir, string
PhysicalDir, string AppBase, string BinPath)
{
if (!PhysicalDir.EndsWith("\\"))
PhysicalDir += "\\";

string aspDir = HttpRuntime.AspInstallDirectory;
string domainId = "ASPHOST_" +
DateTime.Now.ToString().GetHashCode().ToString("x" );
string appName = (VirtualDir + PhysicalDir).GetHashCode().ToString("x");
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationName = appName;
setup.ConfigurationFile = "web.config";
setup.ApplicationBase = AppBase!=null ? AppBase : (AppBase =
PhysicalDir);
setup.PrivateBinPath = BinPath!=null ? BinPath : AppBase + "bin";
setup.PrivateBinPathProbe = "*"; // if non-blank, excludes AppBase from
search path, so only looks in PrivateBinPath.
setup.DisallowCodeDownload = true;

AppDomain ad = AppDomain.CreateDomain(domainId, null, setup);
ad.SetData(".appDomain", "*");
ad.SetData(".appPath", PhysicalDir);
ad.SetData(".appVPath", VirtualDir);
ad.SetData(".domainId", domainId);

// VS2003 only:
//ad.SetData(".hostingVirtualPath", VirtualDir);
//ad.SetData(".hostingInstallDir", aspDir);

// VS2005 only:
ad.SetData(".appId", appName);
string dataDir = PhysicalDir + "App_Data";
ad.SetData("DataDirectory", dataDir, new
System.Security.Permissions.FileIOPermission(Syste m.Security.Permissions.FileIOPermissionAccess.Path Discovery,
dataDir));

Host host =
(Host)ad.CreateInstanceAndUnwrap(HostType.Module.A ssembly.FullName,
HostType.FullName);
return host;
}

The other way to create a host is to use the ApplicationHost CLR class, as
in the following code, whic does work. It is simpler, but does not allow
control of PrivateBinPath. By the time CreateApplicationHost returns,
assemblies have been loaded in the new AppDomain, so it is too late to set
it. That's why I need to use the above method.

public static Host Create(Type HostType, string VirtualDir, string
PhysicalDir)
{
Host newHost = (Host)ApplicationHost.CreateApplicationHost(HostTy pe,
VirtualDir, PhysicalDir);
return newHost;
}

The line 'ad.SetData("DataDirectory" ...etc.' in the first method makes no
difference, I included it in an attempt to mimic the AppDomain created by
the second method (I saw in the debugger that it added such an entry).
Granting 'AllAccess' instead of 'PathDiscovery' makes no difference
either.

Thanks
Paul Newman
Anyone?

It would be good to hear from anyone who HAS managed to host asp.net in
their app, but didn't get this error. At least that would mean the framework
is not at fault.

TIA
Oct 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeff Wagner | last post by:
Does anyone know of a good web hosting company who supports Python? When I finally get my numerology program written, I would like to put it on my web site for everyone to be able to use but my...
0
by: John W. | last post by:
I have developed and ASP.NET application that uses the aadvapi32.dll to impersonate a domain user to gain access to files on a different server. The application runs fine with the .NET Framework...
2
by: JG | last post by:
I recently upgraded a small VB 6.0 app to VB.Net. The upgrade process completed ok and everything seems to function properly in VB.Net except for the FTPPutFile. It consistently fails and returns a...
8
by: David | last post by:
Any recommendations for a web site rating ASP.net web hosting providers? The one I have seen are poor and also alot of providers offer ASP.net but mySql rather than MS SQL. I just need a...
2
by: Michael D. Reed | last post by:
I am using ClickOnce to distribute a program. It works well except for one detail. When a new version is installed, the program does not initialize properly immediately after the update. The...
4
by: NOTICIAS | last post by:
Hi everybody. A very basic web page using an ScriptManager and a RoundedCornersExtender fails loading at a shared hosting environment. In my local server, such page loads correctly. I'm...
0
by: lazydba | last post by:
Hi, I installed the evaluation copy on a server, the eval license expired, and now I'm trying upgrade to a retail version. I have read the docs http://support.microsoft.com/kb/914158/en-us and...
21
by: Herb | last post by:
Why do so many hosting services only offer PHP4? That's even true for Yahoo.
1
by: Joseph | last post by:
Hi all, My shared host provides python 2.3. Since it is a shared hosting, he is not willing to upgrade to a newer version. I am looking for option to upload 2.5 on my own. Is this possible and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.