[IronPython] invoke CreateApplicationHost in ironpython failed?

smppms2002 smppms2002 at yahoo.com.cn
Mon Apr 24 09:42:51 CEST 2006


invoke CreateApplicationHost in ironpython failed?

I want to implement a mini asp.net web server in
ironpython,
but I am a .NET newbie, so I google some article about
ASMX in msdn
(https://msdn.microsoft.com/msdnmag/issues/04/12/ServiceStation/),
then write a simple demo, but some errors happen.

below is the error message and source .

D:\IronPython\httpd>IronPythonConsole
IronPython 1.0.60420 (Beta) on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights
reserved.
>>> ^Z

D:\IronPython\httpd>IronPythonConsole http_test2.py
Traceback (most recent call last):
  File D:\IronPython\httpd\http_test2.py, line 57, in
Initialize
  File D:\IronPython\httpd\http_test2.py, line 34, in
test
  File , line 0, in CreateApplicationHost##12
  File System.Web, line unknown, in
CreateApplicationHost
  File System.Web, line unknown, in
CreateInstanceInNewWorkerAppDomain
  File System.Web, line unknown, in CreateInstance
IOError: Could not load file or assembly 'snippets1,
Version=0.0.0.0, Culture=ne
utral, PublicKeyToken=null' or one of its
dependencies. 


import sys
import nt
import clr
clr.AddReference("System.Web")

from System import *
from System.Web import *
from System.Web.Hosting import *
from System.Diagnostics import *
from System.Text import *
from System.Net  import *
from System.Net.Sockets import *
from System.Threading import *

class aspxHost(MarshalByRefObject):
	def ProcessRequest(self, webpage, query, tw):
		swr = SimpleWorkerRequest( webpage, query, tw )
		HttpRuntime.ProcessRequest(swr)


def test():
	_tmphost = aspxHost()
	host = ApplicationHost.CreateApplicationHost(
_tmphost.GetType(), "/", nt.getcwd() )
	
	listener = HttpListener()
	listener.Prefixes.Add("http://localhost:80/")
	listener.Prefixes.Add("http://127.0.0.1:80/")
	listener.Start()
	
	print "Listening for requests on
http://localhost:80/"
	
	while True:
		ctx = listener.GetContext()
		page = ctx.Request.Url.LocalPath.Replace("/", "")
		query = ctx.Request.Url.Query.Replace("?", "")
		
		print "page is [%s] query is [%s]" %( page, query )
		
		sw = StreamWriter(ctx.Response.OutputStream)
		msh.ProcessRequest(page, query, sw)
		sw.Flush()
		ctx.Response.Close()


if __name__ == "__main__":
	test()
	

thanks a lot.


		
___________________________________________________________

无限容量雅虎相册,原图等大下载,超快速度,赶快抢注! 
http://cn.photos.yahoo.com


		
___________________________________________________________
 
情人节,用雅虎邮箱送玫瑰! 




More information about the Ironpython-users mailing list