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

问题描述:

我已经从源代码(tarball)构建Mono 3.0.2,并且从最新的tarball和Github上的最新版本构建了XSP,但我无法使用.net 4.5运行一个相对简单的asp.net应用程序,因为它将web.config中的'targetFramework =“4.5”'视为无效。构建应用程序并运行控制台.net 4.5应用程序工作得很好。无法在Mono 3上的xsp上运行asp.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 
[email protected]:~/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) 
[email protected]:~/Downloads/xsp$ 

如果我从web.config中删除targetFramework元素,那么错误消失,但我只是得到一个404,所以没有一个http模块挂钩了。

任何想法?我被告知xsp4应该可以正常工作,但是从我所看到的情况来看,它似乎没有更新以处理4.5。

+0

对于“从最新的tarball和最新的Github构建XSP”,你是什么意思?无论你是从tarball构建还是从github构建,你都可以从github – knocte

+0

和AFAIK构建压缩包非常老,所以你应该从github构建 – knocte

+0

非常简单,我构建了两个,都尝试了两个,都给出了同样的问题。 –

尝试和编辑文件:

vi /opt/mono/bin/xsp4 

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

在它改线:

exec /opt/mono/bin/mono $MONO_OPTIONS "/opt/mono/lib/mono/4.0/xsp4.exe" "[email protected]" 

有了这个:

exec /opt/mono/bin/mono $MONO_OPTIONS "/opt/mono/lib/mono/4.5/xsp4.exe" "[email protected]" 

,然后复制可执行文件:

cp /opt/mono/lib/mono/4.0/xsp4.exe /opt/mono/lib/mono/4.5/ 

我希望单人做它一点点在未来更加流畅,所以我们不需要手动做到这一点,但对我来说本手册变通办法!

同样,我在CentOS下这样做,所以它在Ubuntu上可能会有点不同。

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