[IronPython] invoke CreateApplicationHost in ironpython failed?

Dino Viehland dinov at exchange.microsoft.com
Mon Apr 24 18:07:06 CEST 2006


I suspect you're hitting cross-app domain issues.  A quick search shows that you need to have your assemblies in a "bin" directory for ASP.NET to find them, but IronPython is going to generate its snippets.dll somewhere else (usually the current working directory).

One thing you could try, not sure if it'll help, but if you layout your directory like:

D:\IronPython\httpd\bin\
                                IronPythonConsole.exe
                                IronPython.dll
                                ...

Then run from httpd:


D:\IronPython\httpd> bin\IronPythonConsole.exe


Then maybe snippets will end up in bin.

If that doesn't work you can try updating the path in OutputGenerator.CreateNewSnippetAssembly in IronPython\Compiler to point to a bin subdirectory.  If that works we could add a command line option to specify where this should get generated.

If none of those works it might help for you to re-run w/ the -X:ExceptionDetail command line option so we can see where from within .NET this is actually throwing.

Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of smppms2002
Sent: Monday, April 24, 2006 12:43 AM
To: users at lists.ironpython.com
Subject: [IronPython] invoke CreateApplicationHost in ironpython failed?

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