System.Web.Hosting

  • Thread starter Thread starter Ching-Lung
  • Start date Start date
C

Ching-Lung

Hi,

*********
MyHost.cs
*********
using System;
using System.IO;
using System.Web;
using System.Web.Hosting;
using System.Diagnostics;

public class MyHost : MarshalByRefObject
{
public void CreateHtmlPage(string webPage, string
query, string file)
{
StreamWriter stream = new StreamWriter(file);
SimpleWorkerRequest swr = new SimpleWorkerRequest
(webPage, query, stream);
HttpRuntime.ProcessRequest(swr);
stream.Close();
}
}

********
Form1.cs
********
I am getting the following error message:
An unhandled exception of
type 'System.IO.FileNotFoundException' occurred in
mscorlib.dll

on line:
host = (MyHost)ApplicationHost.CreateApplicationHost
(typeof(MyHost), "/foo", Environment.CurrentDirectory);


Which file is it trying to open? Please help.

Thanks.
 
You need to put a copy of the MyHost assembly into .\bin directory. This
behavior is by design. ASP.NET loads its dependencies from the .\bin
folder. Also you can put the MyHost class to a separate DLL and register it
to the GAC.

Regards,
Xin

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. (c) 2003 Microsoft Corporation. All
rights reserved.
 
Back
Top