无法在Mono 3上的xsp上运行asp.net 4.5应用程序

时间:2013-01-09 19:19:36

标签: asp.net mono xsp owin katana

我从源代码(tarball)构建了Mono 3.0.2,并使用最新的tarball和最新的Github构建了XSP,但我无法使用.net 4.5运行相对简单的asp.net应用程序,因为它将web.config中的'targetFramework =“4.5”'视为无效。构建应用程序,并运行控制台.net 4.5应用程序就可以了。

这是有问题的web.config:

<?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抛出的例外:

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 ---

有关版本/配置的一些信息:

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模块被连接起来。

有什么想法吗?我被告知xsp4应该可以正常工作,但从我可以看到它似乎没有更新到处理4.5。

2 个答案:

答案 0 :(得分:5)

尝试编辑该文件:

 vi /opt/mono/bin/xsp4

(您的位置可能会有所不同,因为您自己编译了它,您应该知道存储文件的位置)

在其中更改行:

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的家伙能在未来更加流畅,所以我们不需要手动执行此操作,但对我来说这个手动解决方法有效!

同样,我在CentOS下完成了这项工作,因此在Ubuntu上可能会有所不同。

答案 1 :(得分:0)

我遇到了与MVC 4和Mono 3相同的问题。最奇怪的是,这个错误突然出现了。恢复我的更改没有帮助。最后我最终删除了我的解决方案文件夹并查看了一个新版本。这必须删除一些创建的文件。在那之后,一切都像以前一样。