9

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.

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>

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$

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.

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.

Steven Robbins
  • 26,441
  • 7
  • 76
  • 90
  • what do you mean with "built XSP from both the latest tarball and the latest on Github"? either you build from the tarball or you build from github – knocte Jan 10 '13 at 12:34
  • and AFAIK the tarball is very old so you should build from github – knocte Jan 10 '13 at 12:35
  • Quite simple, I built both, tried both, both gave the same problem. – Steven Robbins Jan 10 '13 at 13:01
  • Did you properly uninstall the previous one before trying the github one? – knocte Jan 10 '13 at 16:57
  • I tried the github one first, and made sure I nuked everything. – Steven Robbins Jan 10 '13 at 17:22
  • how did you "make sure to nuke everything"? you have to make sure of removing ALL mono&xsp packages from your distro before installing mono&xsp from sources (unless you follow carefully these instructions to not mix them: http://www.mono-project.com/Parallel_Mono_Environments ) – knocte Jan 10 '13 at 17:27
  • Mono was never installed until I installed it from source (and Mono works perfectly fine with 4.5 projects, it just won't with asp.net). Xsp I built from github master, installed and tested it, found this problem and tried to get help on IRC, I only tried the tarball (which you say is out of date) afterwards (and have since uninstalled it with make uninstall and reverted back to github master) – Steven Robbins Jan 10 '13 at 18:08
  • did you use the same prefix when installing both mono and xsp? – knocte Jan 10 '13 at 18:26
  • (I'm starting to think that this is a mono bug, but the reason I keep asking setup questions is that I think I've seen this bug in the past, but not anymore, so it might have been fixed recently) – knocte Jan 10 '13 at 18:27
  • Yep, you can see that in the stuff above - everything is set to /usr/local – Steven Robbins Jan 11 '13 at 06:53
  • Oh, and no problem on all the setup questions.. if it turns out I've done something done that's fine, just want to get it working :) – Steven Robbins Jan 11 '13 at 07:07
  • Steven, did you ever solve this issue? – Brian Jul 27 '13 at 18:25

2 Answers2

5

Try and edit that file:

 vi /opt/mono/bin/xsp4

(your location might be different, since you compiled it yourself you should know where you stored the files)

In it change the line:

exec /opt/mono/bin/mono $MONO_OPTIONS "/opt/mono/lib/mono/4.0/xsp4.exe" "$@"

With this:

exec /opt/mono/bin/mono $MONO_OPTIONS "/opt/mono/lib/mono/4.5/xsp4.exe" "$@"

And then copy the executable:

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

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!

Again, I've done this under CentOS so it could be a bit different on Ubuntu.

Astaar
  • 5,858
  • 8
  • 40
  • 57
0

I ran into the same issue with MVC 4 and Mono 3. The strangest thing was, that this error suddenly appeared. Reverting my changes didn't help. Eventually I ended up deleting my solution folder and checking out a fresh version. That must have removed some created files. After that, everything worked as before.

scho
  • 323
  • 1
  • 14