Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autofac on Linux/Mono makes Razor not working #689

Closed
marxin opened this issue Oct 27, 2015 · 3 comments
Closed

Autofac on Linux/Mono makes Razor not working #689

marxin opened this issue Oct 27, 2015 · 3 comments

Comments

@marxin
Copy link

marxin commented Oct 27, 2015

Hello.

I've got a project utilizing MVC5 & Autofac on Mono/Linux platform. It shows that after updating to mono-4.x, I've got problem that Razor engine is somehow not registered.

I've tried to reduce test-case, created just Example MVC5 project in Monodevelop:
https://github.com/marxin/test-mvc5-mono-autofac

Razor works, however if I just add Autofac MVC5 Integration package (no registration in code is done), it stops working with following message:

System.InvalidOperationException
The view found at '~/Views/Home/Index.cshtml' was not created.

Description: HTTP 500.Error processing request.

Details: Non-web exception. Exception origin (name of application or object): System.Web.Mvc.
Exception stack trace:
at System.Web.Mvc.BuildManagerCompiledView.Render (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer) in :line 0
at System.Web.Mvc.ViewResultBase.ExecuteResult (System.Web.Mvc.ControllerContext context) in :line 0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) in :line 0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (IList1 filters, Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) in <filename unknown>:line 0 at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (IList1 filters, Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) in :line 0
Version Information: 4.2.1 (Stable 4.2.1.60/804ddbc Tue Oct 27 00:22:01 UTC 2015); ASP.NET Version: 4.0.30319.17020

Thanks for help,
Martin

@tillig
Copy link
Member

tillig commented Oct 27, 2015

It appears to me that you asked this question a year ago on StackOverflow and found the answer in modifying your web.config. Is the same answer not still working?

Unfortunately, I don't really have a Linux/Mono environment on which I can test this - when we compile Autofac core for PCL, we trust that the framework is doing the right thing; and when we test Autofac MVC integration, it's with native Windows + .NET.

I do know that the Autofac.Mvc5 package takes advantage of the PreApplicationStartMethodAttribute to register an HttpModule into the application pipeline. I believe the Microsoft Razor assemblies do the same thing. You don't need to do anything to make that happen, though, which is why I raise it - that dynamic HttpModule addition may be part of the problem.

I see in WebActivator that they had to change the way they register app startup stuff so it works correctly in Mono..

Here's what I'd recommend - fork Autofac.Mvc and try implementing something in the PreApplicationStartCode class that looks like the ActivationManager on WebActivator - the part where it checks to see if it's running in Mono and changes the way it registers modules. See if that makes a difference.

If it does, file an issue over on the Autofac.Mvc repository and reference this one, letting us know. We try to keep the issues for each package in the respective repository. Better yet - send us a PR with the patch you made and verified as working.

Again, though, I don't have an environment on which I can replicate or troubleshoot it, so I'm probably not going to be able to be any more help than this. If the above patch works - awesome, we'll integrate it accordingly. If not... perhaps re-asking on StackOverflow with more information may yield better results - someone else out there that I'm unaware of may have encountered the same issue and know how to fix it.

@tillig tillig closed this as completed Oct 27, 2015
@marxin
Copy link
Author

marxin commented Dec 8, 2015

Hello.

Sorry for a delay, I was busy with other stuff.

You've got very smart ideas how to fix the issue, however as I've just cloned Autofac repository, I've spotted couple of blockers:

  1. Autofac converted *.csproj file to *.xproj - that can be fixed by checking out v3.5.2 tag
  2. Opening top-level solution file works fine, however as my Linux machine does not contain PCL binaries, I can't build the solution. Is there any way how could I switch to framework v4.5. Or should I install these PCL binaries?

@marxin
Copy link
Author

marxin commented Apr 3, 2016

So the situation was much easier than original looked.
It was sufficient just to fix: "Access to the path “/etc/mono/registry” is denied":
http://stackoverflow.com/questions/24872394/access-to-the-path-etc-mono-registry-is-denied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants