无法在单3 XSP运行一个asp.net 4.5应用程序(Unable to run an asp.

2019-08-06 04:53发布

我从源(压缩档)建立单3.0.2,并内置XSP来自最新的tar包和最新的Github上,但我不能,因为它看到“运行使用.NET 4.5的相对简单的asp.net应用targetFramework = “4.5””在web.config为无效。 构建应用程序,并运行一个控制台.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可言。

Answer 1:

尝试和编辑文件:

 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/

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

同样,我的CentOS下做到了这一点,因此可以在Ubuntu上有点不同。



Answer 2:

我遇到同样的问题与MVC 4和Mono 3.奇怪的是,这个错误突然出现。 还原我的变化并没有帮助。 最后,我结束了我删除解决方案文件夹,检查出一个新的版本。 那一定是删除了一些创建的文件。 在那之后,一切都按之前。



文章来源: Unable to run an asp.net 4.5 app on xsp on Mono 3