[Mono-aspnet-list] Mono ASP.NET vs MS VS

Chris Rogus cricel472 at gmail.com
Fri Sep 26 19:34:50 UTC 2014

Hi, I am trying to build an ASP.NET website in C# using Razor templates in
MS Visual Studio that will then run in Mono on Linux.

I have never attempted to run an ASP.NET site with Mono before now, and I
only played with MonoDevelop briefly when I last explored Mono a couple
years ago.

I have mono-complete and mono-fastcgi-server4 installed from Xamarin's deb
on my Xubuntu 14.04 desktop VM (running in VirtualBox): sudo
add-apt-repository 'deb http://download.mono-project.com/repo/debian wheezy
main'  # etc

When I use Xamarin Studio 5.4 in Windows 7 (downloaded from
monodevelop.com and then upgraded in-app) to create a new solution of type
C# > ASP.NET > "ASP.NET MVC Razor Project", and then copy the bin dir,
Views dir and Global.asax + Web.config + package.config files into my Linux
machine's /var/www/ directory, and finally run xsp4 there, everything works
fine.  "Fine" here meaning that I open localhost:9000 and see a simple page
that says: "Welcome to ASP.NET MVC 5.2 on Mono!"  (Note that I can also
accomplish this with nginx + mono-fastcgi-server4.)

When I then use Visual Studio 2013 Professional Update 3 in Windows 7 to
create a new solution of type Visual C# > Web > "ASP.NET Web Application" >
Empty > check MVC, and then copy from the Xamarin solution I just created
(for demo purposes): Controllers/HomeController and all the contents of the
Views dir except Web.config (note that MS VS uses "web" and Mono/Xamarin
uses "Web", if ever that might matter).  I then right click on the project
in MS VS and then Publish > Custom > (name it) > Publish method: File
System > Target location: (somewhere).  Once that is published locally, I
will then copy that dir into my /var/www in Linux and finally run xsp4
there, where I see this error displayed in the browser when I open
localhost:9000 :

Cannot cast from source type to destination type.

Description: HTTP 500.Error processing request.

Details: Non-web exception. Exception origin (name of application or
object): System.Web.WebPages.Razor.
Exception stack trace:
at System.Web.WebPages.Razor.WebRazorHostFactory.GetRazorSection
(System.String virtualPath) [0x00000] in <filename unknown>:0

Version Information: 3.8.0 (tarball Thu Sep 4 12:24:26 UTC 2014); ASP.NET
Version: 4.0.30319.17020

Additionally, if I try to open the Mono solution in my MS VS, it fails to
convert it, with an error:

C:\Users\Chris\Documents\Visual Studio
2013\Projects\MonoSite\MonoSite\MonoSite.csproj : error  : The imported
project "C:\Program Files
was not found. Confirm that the path in the <Import> declaration is
correct, and that the file exists on disk.  C:\Users\Chris\Documents\Visual
Studio 2013\Projects\MonoSite\MonoSite\MonoSite.csproj

Now, I am an experienced C# developer and used to do C and C++ once upon a
time, so I would like to contribute / help myself here:

1) If there is something easy and obvious that I am missing in my config,
please let me know.  (e.g. the global or Views web.config files are
different between MS VS and Mono, for sure, but I am not an expert with
these files to know exactly what is needs to be changed in the MS VS one,
if anything, to fix this situation)

2) Otherwise, any advice on how I could figure out exactly where this error
is coming from?  What dll is missing or what line in my config xml is not
right, etc?  How can I debug an ASP.NET application in Mono -- using xsp4
or monodevelop anything else?

3) What do I need to do to get an ASP.NET solution created in MonoDevelop
to open in MS VS?  (Hopefully this is the same solution as getting my MS VS
ASP.NET site to work in Mono/xsp4.)

4) Any advice on where Mono might already have a Publish feature like MS VS
has in MonoDevelop?  Or else where I should go add one if no such feature
yet exists, if it acceptable to the team in charge of this product (I don't
want to do it, submit a pull request and be told it is an undesired
feature).  Such a feature would very helpful for me.


Chris Rogus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-aspnet-list/attachments/20140926/f02bc63c/attachment.html>

More information about the Mono-aspnet-list mailing list