无法在Mono 3的xsp上运行asp.net 4.5应用 [英] Unable to run an asp.net 4.5 app on xsp on Mono 3
问题描述
我已经从源代码(tarball)构建了Mono 3.0.2,并从最新的tarball和Github上的最新版本构建了XSP,但是我无法使用.net 4.5运行相对简单的asp.net应用程序,因为它在web.config中将'targetFramework ="4.5"'视为无效.构建应用程序并运行控制台.net 4.5应用程序就可以了.
I've build Mono 3.0.2 from source (tarball), and built XSP from both the latest tarball and the latest on Github, but I'm unable to run a relatively simple asp.net app using .net 4.5 because it sees 'targetFramework="4.5"' in the web.config as invalid. Building the app, and running a console .net 4.5 app works just fine.
这是有问题的web.config:
This is the web.config in question:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="owin:HandleAllRequests" value="true" />
<add key="owin:SetCurrentDirectory" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
这是xsp4抛出的异常:
And this is the exception that xsp4 is throwing:
An exception has occurred while generating HttpException page:
System.NullReferenceException: Object reference not set to an instance of an object
at System.Web.Util.HttpEncoder.GetCustomEncoderFromConfig () [0x00000] in <filename unknown>:0
at System.Lazy`1[System.Web.Util.HttpEncoder].InitValue () [0x00000] in <filename unknown>:0
The actual exception which was being reported was:
System.Web.HttpException: Initial exception ---> System.Configuration.ConfigurationErrorsException: Error deserializing configuration section httpRuntime: Unrecognized attribute 'targetFramework'. (/home/srobbins/Projects/nancykatana/NancyKatana/Web.config line
1)
at System.Configuration.ConfigurationSection.DeserializeSection (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, Boolean createDefaultInstance) [0x00000] in <filename unknown>:0
at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.GetSection (System.String path) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path, System.Web.HttpContext context) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0
at System.Web.HttpRuntime..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
有关版本/配置的一些信息:
And some information about the versions/configuration:
xsp-2.11
Build Environment
Install prefix: /usr/local
Datadir: /usr/local/share
Libdir: /usr/local/lib
Build documentation: yes
Mono 2.0 compiler: /usr/local/bin/gmcs
Mono 4.0 compiler: /usr/local/bin/dmcs
Target frameworks: .NET 2.0, .NET 4.0
Build SQLite samples: yes
srobbins@ubuntu-vm:~/Downloads/xsp$ /usr/local/bin/mono --version
Mono JIT compiler version 3.0.2 (tarball Tue Jan 8 08:23:06 GMT 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
srobbins@ubuntu-vm:~/Downloads/xsp$
如果我从web.config中删除了targetFramework元素,则错误消失了,但是我只得到了404,所以没有一个http模块被挂上.
If I remove the targetFramework elements from the web.config then the error goes away, but I just get a 404, so none of the http modules are getting hooked up.
有什么想法吗?有人告诉我xsp4应该可以正常工作,但是据我所知,它似乎根本没有更新为可以处理4.5.
Any ideas? I've been told that xsp4 should work just fine, but from what I can see it does't appear to have been updated to handle 4.5 at all.
推荐答案
尝试并编辑该文件:
vi /opt/mono/bin/xsp4
(您的位置可能有所不同,因为您自己编译了它,所以您应该知道文件的存储位置)
(your location might be different, since you compiled it yourself you should know where you stored the files)
在其中更改行:
exec /opt/mono/bin/mono $MONO_OPTIONS "/opt/mono/lib/mono/4.0/xsp4.exe" "$@"
与此:
exec /opt/mono/bin/mono $MONO_OPTIONS "/opt/mono/lib/mono/4.5/xsp4.exe" "$@"
然后复制可执行文件:
cp /opt/mono/lib/mono/4.0/xsp4.exe /opt/mono/lib/mono/4.5/
我希望Mono的人在将来使它变得更灵活一些,所以我们不需要手动执行此操作,但是对我来说,这种手动解决方法有效!
I hope the Mono guys make it a little bit more fluid in the future so we don't need to manually do this, but for me this manual workaround works!
同样,我是在CentOS上完成的,因此在Ubuntu上可能会有所不同.
Again, I've done this under CentOS so it could be a bit different on Ubuntu.
这篇关于无法在Mono 3的xsp上运行asp.net 4.5应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!