Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Why is it whenever I use System.Web.Hosting.ApplicationHost.CreateApplicationHost it always returns System.IO.FileNotFoundException?

Posted on 2008-06-19
3
Medium Priority
?
2,471 Views
Last Modified: 2013-12-16
I'm trying to host asp.net application and asp web services without IIS. I found the cassini web project and other tutorial around the net. All of them are using the CreateApplicationHost from System.Web.Hosting.ApplicationHost namespace. I copied some code from those project and build it properly but whenever I tried to run it on debug I always get the file not found error. I think it is caused by the Virtual Directory path but don't know how to fix it.


public class MySimpleHost : MarshalByRefObject
    {
        public void ProcessRequest(string page, string query, TextWriter tw)
        {
            SimpleWorkerRequest swr = 
                new SimpleWorkerRequest(page, query, tw);
            HttpRuntime.ProcessRequest(swr);
        }
    }
 
 
namespace SimpleHost
{
    class Program
    {
        static void Main(string[] args)
        {
            string dir = System.IO.Directory.GetCurrentDirectory();
 
            MySimpleHost msh = (MySimpleHost)ApplicationHost.CreateApplicationHost(
                typeof(MySimpleHost), "/", dir);
         }
    }

Open in new window

0
Comment
Question by:hackpin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 21819947
Its looking for a file containing MyHost class. It is included with the main program itself (UsingAspRuntime.exe). The ASP.NET runtime looks for all assembalies in the bin directory. So be sure that the bin directory has been created and it contain the UsingAspRuntime.exe. The build script does this automatically.
http://www.codeproject.com/KB/dotnet/usingaspruntime.aspx

Another thread about it
http://forums.asp.net/rss.aspx?ForumID=67&PostID=771470
0
 
LVL 1

Author Comment

by:hackpin
ID: 21852250
I compiled the projects Dhaest mention above properly unfortunately I encountered the same problem  the System.io.filenotfound exception. What I wanted to do is to make my own hosting application rather than using the code on code project. I want to make it from scratch for me to understand it well.

I looked on my bin folder and the exe file is already created for me after my build. Can anyone point me out what am I missing?
0
 
LVL 1

Accepted Solution

by:
hackpin earned 0 total points
ID: 21852408
Thanks for the reply Dhaest I now know what I need to do first before I can use the System.Web.Hosting namespace.

I created my own implementation of http server using httplistener.
Create a SNK file for that library.

To create SNK file
Use visual studio command line then use the following:
sn.exe -k [name of the snk file].snk

In your solution project go to configuration  manager under the Singing tab and then add your newly created snk file.

once again use your visual studio command line then go to the folder of your class library.
Use the following command to add your dll to global assembly cache.

gacutil -i [library name].dll

Now I can properly use the .CreationApplicationHost method provided by System.Web.Hosting namespace.

I good example of cassini web server ported out to vb.net for other developer:
http://www.codeproject.com/KB/applications/xNetServer.aspx
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question