<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/rss.xsl"?><rss version="2.0"><channel><title>RazorGenerator Discussions Rss Feed</title><link>http://razorgenerator.codeplex.com/discussions</link><description>RazorGenerator Discussions Rss Description</description><item><title>New Post: Problem when trying to use precompiled views in a separate library</title><link>http://razorgenerator.codeplex.com/discussions/282737</link><description>&lt;div style="line-height: normal;"&gt;Great, thanks for following up with the workaround!&lt;br /&gt;
&lt;/div&gt;</description><author>davidebbo</author><pubDate>Fri, 24 May 2013 20:52:28 GMT</pubDate><guid isPermaLink="false">New Post: Problem when trying to use precompiled views in a separate library 20130524085228P</guid></item><item><title>New Post: Problem when trying to use precompiled views in a separate library</title><link>http://razorgenerator.codeplex.com/discussions/282737</link><description>&lt;div style="line-height: normal;"&gt;I just realized that my final post somehow didn't make it here somehow.&lt;br /&gt;
&lt;br /&gt;
I discovered that the above did NOT solve my problem with the real project.&lt;br /&gt;
&lt;br /&gt;
I began to look for differences between the project I created to test and the one with the actual site in it. And I found it; somehow the library requires WebGrease on the main (i.e Host) application.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce (in VS 2010):&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Create an app and a view library as described in &lt;a href="http://blog.davidebbo.com/2011/06/precompile-your-mvc-views-using.html" rel="nofollow"&gt;http://blog.davidebbo.com/2011/06/precompile-your-mvc-views-using.html&lt;/a&gt; with one exception, make both of them using the MVC4 &amp;quot;Empty&amp;quot; template (the blog post recommends using the &amp;quot;Internet Application&amp;quot; template)&lt;/li&gt;
&lt;li&gt;Create a HomeController and a simple ~/Views/Home/Index.cshtml in the main application&lt;/li&gt;
&lt;li&gt;
Continue as described in the blog post&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;
You will get the ArrayTypeMismatchException described at the beginning of this discussion.&lt;br /&gt;
&lt;br /&gt;
To fix:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Open the NuGet manager for the main application (not the library)&lt;/li&gt;
&lt;li&gt;
Add the latest version of WebGrease&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;
The app should now run without additional changes.&lt;br /&gt;
&lt;br /&gt;
This requirement was invisible using the &amp;quot;Internet Application&amp;quot; template because it includes WebGrease out of the box, as do all of the MVC4 standard templates except &amp;quot;empty&amp;quot;. It turns out that my app (created long before I contemplated a view library) was made from &amp;quot;empty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Thanks for your help.&lt;br /&gt;
Jacob&lt;br /&gt;
&lt;/div&gt;</description><author>JacobWagner</author><pubDate>Fri, 24 May 2013 20:40:33 GMT</pubDate><guid isPermaLink="false">New Post: Problem when trying to use precompiled views in a separate library 20130524084033P</guid></item><item><title>New Post: UsePhysicalViewsIfNewer Not Working?</title><link>http://razorgenerator.codeplex.com/discussions/444576</link><description>&lt;div style="line-height: normal;"&gt;My attempt failed. So far I've stripped the view engine down to what I need:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;protected override bool FileExists(ControllerContext controllerContext, string virtualPath) {
    return VirtualPathProvider.FileExists(virtualPath) || _mappings.ContainsKey(virtualPath);
}

protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath) {
    Type type;

    // If the physical file exists then use that instead (useful for overriding), else try and find a virtual one
    if (VirtualPathProvider.FileExists(partialPath))
        return new RazorView(controllerContext, partialPath, null, false, FileExtensions);
    else if (_mappings.TryGetValue(partialPath, out type))
        return new PrecompiledView(type, partialPath, null, false, FileExtensions);

    return null;
}

protected override IView CreateView(ControllerContext controllerContext, string viewPath, string layoutPath) {
    Type type;

    // If the physical file exists then use that instead (useful for overriding), else try and find a virtual one
    if (VirtualPathProvider.FileExists(viewPath))
        return new RazorView(controllerContext, viewPath, layoutPath, true, FileExtensions);
    else if (_mappings.TryGetValue(viewPath, out type))
        return new PrecompiledView(type, viewPath, layoutPath, true, FileExtensions);

    return null;
}&lt;/code&gt;&lt;/pre&gt;

I was able to remove all the IVirtualPathFactory stuff, i'm not sure if this is wise as I can't actually see what it's doing but it works.&lt;br /&gt;
&lt;br /&gt;
I won't be using RazorGenerator for views within the web application project (only the referenced projects). Therefore if a view exists in the web application which has the same path as a view in a referenced project then it will use the web application one. I was hoping I could use this same code to return the one on disk if it's last modification date is more recent than the assembly last write time. However RazorView takes a virtual path and not a physical path. This could be the issue you mention above about the view existing outside of the web root. Is there an alternative way of doing this?&lt;br /&gt;
&lt;/div&gt;</description><author>jgd12345</author><pubDate>Fri, 24 May 2013 14:33:38 GMT</pubDate><guid isPermaLink="false">New Post: UsePhysicalViewsIfNewer Not Working? 20130524023338P</guid></item><item><title>New Post: UsePhysicalViewsIfNewer Not Working?</title><link>http://razorgenerator.codeplex.com/discussions/444576</link><description>&lt;div style="line-height: normal;"&gt;Ah thanks for letting me know. This perhaps should be documented somewhere as it's not immediately obvious. I can see the problem. However because the files do physically exist at design time, I may be able to customize the view engine to come up with something that suits my need.&lt;br /&gt;
&lt;/div&gt;</description><author>jgd12345</author><pubDate>Fri, 24 May 2013 10:17:34 GMT</pubDate><guid isPermaLink="false">New Post: UsePhysicalViewsIfNewer Not Working? 20130524101734A</guid></item><item><title>New Post: UsePhysicalViewsIfNewer Not Working?</title><link>http://razorgenerator.codeplex.com/discussions/444576</link><description>&lt;div style="line-height: normal;"&gt;If you're brave enough, you can get it from the PDB file of the compiled Views assembly.&lt;br /&gt;
&lt;br /&gt;
However, I'm not even sure that the standard view engine will be able to process views that are outside the web root, short of using a VirtualPathProvider (which is painful).&lt;br /&gt;
&lt;/div&gt;</description><author>davidebbo</author><pubDate>Thu, 23 May 2013 17:53:08 GMT</pubDate><guid isPermaLink="false">New Post: UsePhysicalViewsIfNewer Not Working? 20130523055308P</guid></item><item><title>New Post: UsePhysicalViewsIfNewer Not Working?</title><link>http://razorgenerator.codeplex.com/discussions/444576</link><description>&lt;div style="line-height: normal;"&gt;We could add an extra property to the compiled view and point to the full path on disk. I'm not entirely sure that is do-able (being able to figure out the absolute path during compile time) and it's ugly to have the full path embedded in the generated type, but it might help in the local debugging scenario.&lt;br /&gt;
&lt;/div&gt;</description><author>pranavkm</author><pubDate>Thu, 23 May 2013 17:41:55 GMT</pubDate><guid isPermaLink="false">New Post: UsePhysicalViewsIfNewer Not Working? 20130523054155P</guid></item><item><title>New Post: UsePhysicalViewsIfNewer Not Working?</title><link>http://razorgenerator.codeplex.com/discussions/444576</link><description>&lt;div style="line-height: normal;"&gt;Ah yes. Probably not much that can be done about that, since in this scenario, the aspx files essentially don't exist (from the point of you of IIS) when you run your site.&lt;br /&gt;
&lt;/div&gt;</description><author>davidebbo</author><pubDate>Thu, 23 May 2013 17:22:13 GMT</pubDate><guid isPermaLink="false">New Post: UsePhysicalViewsIfNewer Not Working? 20130523052213P</guid></item><item><title>New Post: UsePhysicalViewsIfNewer Not Working?</title><link>https://razorgenerator.codeplex.com/discussions/444576</link><description>&lt;div style="line-height: normal;"&gt;The way the flag works is it compares the last write times of the compiled assembly and the view files and determines which is newer when it needs to serve them. It works when your precompiled views are in the Mvc project being served. In the case of the sample above, the views are referenced from an externally compiled assembly and consequently the view engine has no way to figure out where the view files are. &lt;br /&gt;
&lt;br /&gt;
It's definitely a bug in the behavior, but I'm not entirely certain how this scenario could be solved.&lt;br /&gt;
&lt;/div&gt;</description><author>pranavkm</author><pubDate>Thu, 23 May 2013 13:43:25 GMT</pubDate><guid isPermaLink="false">New Post: UsePhysicalViewsIfNewer Not Working? 20130523014325P</guid></item><item><title>New Post: UsePhysicalViewsIfNewer Not Working?</title><link>http://razorgenerator.codeplex.com/discussions/444576</link><description>&lt;div style="line-height: normal;"&gt;Thanks David, that's what I had assumed. I am testing locally and still the contents of the page are not updated until I do a re-build.&lt;br /&gt;
&lt;/div&gt;</description><author>jgd12345</author><pubDate>Thu, 23 May 2013 07:56:02 GMT</pubDate><guid isPermaLink="false">New Post: UsePhysicalViewsIfNewer Not Working? 20130523075602A</guid></item><item><title>New Post: UsePhysicalViewsIfNewer Not Working?</title><link>http://razorgenerator.codeplex.com/discussions/444576</link><description>&lt;div style="line-height: normal;"&gt;The project sets &lt;code&gt;UsePhysicalViewsIfNewer&lt;/code&gt; only if running locally (see &lt;a href="https://github.com/davidebbo/MvcApplicationRazorGeneratorSeparateLibrary/blob/master/LibraryViewProject/App_Start/RazorGeneratorMvcStart.cs" rel="nofollow"&gt;here&lt;/a&gt;. So it should find updated views at runtime only in the local case.&lt;br /&gt;
&lt;/div&gt;</description><author>davidebbo</author><pubDate>Wed, 22 May 2013 17:39:16 GMT</pubDate><guid isPermaLink="false">New Post: UsePhysicalViewsIfNewer Not Working? 20130522053916P</guid></item><item><title>New Post: UsePhysicalViewsIfNewer Not Working?</title><link>https://razorgenerator.codeplex.com/discussions/444576</link><description>&lt;div style="line-height: normal;"&gt;What does UsePhysicalViewsIfNewer do?&lt;br /&gt;
&lt;br /&gt;
I downloaded the project at &lt;a href="https://github.com/davidebbo/MvcApplicationRazorGeneratorSeparateLibrary" rel="nofollow"&gt;https://github.com/davidebbo/MvcApplicationRazorGeneratorSeparateLibrary&lt;/a&gt; to have a little play around. I assumed whenever I changed one of the views I wouldn't need to rebuild the project. However when I change the Home View and click refresh nothing happens until I do a rebuild.&lt;br /&gt;
&lt;br /&gt;
I'd appreciate it if someone could clear this up for me. Thanks&lt;br /&gt;
&lt;/div&gt;</description><author>jgd12345</author><pubDate>Wed, 22 May 2013 11:56:09 GMT</pubDate><guid isPermaLink="false">New Post: UsePhysicalViewsIfNewer Not Working? 20130522115609A</guid></item><item><title>New Post: compilation issue</title><link>http://razorgenerator.codeplex.com/discussions/444328</link><description>&lt;div style="line-height: normal;"&gt;Well, I've gotten a little deeper with this issue.  It turns out that whats dying is my unit test library.  If I comment that out of my csproj (post build event), and from my buildDeploy.cmd script, the actual application builds just fine with RazorGenerator.&lt;br /&gt;
&lt;br /&gt;
I'll take a peek at the config for the unittest project, and report back.&lt;br /&gt;
&lt;br /&gt;
One thing is particularly confusing to me still, though.  if I have configuration issues, shouldn't it fail to build in my development environment also?  I'm confused how it builds with identical configuration in one place, but fails on another one.&lt;br /&gt;
&lt;br /&gt;
Also, because I'm not the person who does the builds, I have to schedule time with them to attempt another build, so the availability for that kind of thing is a bit spotty....(just to explain any delays)&lt;br /&gt;
&lt;br /&gt;
Thanks again for your attention and suggestions.&lt;br /&gt;
&lt;/div&gt;</description><author>brianAckermann</author><pubDate>Tue, 21 May 2013 17:08:01 GMT</pubDate><guid isPermaLink="false">New Post: compilation issue 20130521050801P</guid></item><item><title>New Post: Problem when trying to use precompiled views in a separate library</title><link>http://razorgenerator.codeplex.com/discussions/282737</link><description>&lt;div style="line-height: normal;"&gt;ok, this has got to be some kind of race condition having to do with the server starting up.&lt;br /&gt;
&lt;br /&gt;
I recreated both apps from scratch just as I described in my last post. I discovered several things:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;If I simply stop and run it again, the code runs correctly, as in my last post&lt;/li&gt;
&lt;li&gt;If I stop the site in the ASP.Net development server, from the system tray; then the error reoccurs, but only the first time&lt;/li&gt;
&lt;li&gt;If I force it to recompile MyPrecompiledViews but leave the server running, the error does not reoccur&lt;/li&gt;
&lt;li&gt;If I stop the site but place a breakpoint at the beginning of RazorGeneratorMvcStart.Start then continue after the breakpoint is hit; then the error does NOT reoccur&lt;/li&gt;
&lt;li&gt;If I switch to using IIS Express instead of the ASP.NET Development Server, the error does not occur and cannot be reproduced&lt;/li&gt;
&lt;li&gt;
If I switch back to ASP.NET Development Server (without recreating the project), the problem does not occur and cannot be reproduced&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;
Armed with this odd set of facts I will see if I can get it working in my real site.&lt;br /&gt;
&lt;br /&gt;
Jacob&lt;br /&gt;
&lt;/div&gt;</description><author>JacobWagner</author><pubDate>Tue, 21 May 2013 15:16:21 GMT</pubDate><guid isPermaLink="false">New Post: Problem when trying to use precompiled views in a separate library 20130521031621P</guid></item><item><title>New Post: Problem when trying to use precompiled views in a separate library</title><link>http://razorgenerator.codeplex.com/discussions/282737</link><description>&lt;div style="line-height: normal;"&gt;It worked when I originally tested this concept, before I tried to incorporate it into my real site.&lt;br /&gt;
&lt;br /&gt;
However, I went back to the basics at &lt;a href="http://blog.davidebbo.com/2011/06/precompile-your-mvc-views-using.html" rel="nofollow"&gt;http://blog.davidebbo.com/2011/06/precompile-your-mvc-views-using.html&lt;/a&gt; and created two projects as described. I used the Internet Application template for the &amp;quot;main&amp;quot; project and the Empty template for the library, both under MVC4.&lt;br /&gt;
&lt;br /&gt;
I got the error described in the original post in this thread.&lt;br /&gt;
&lt;br /&gt;
---- instant update&lt;br /&gt;
&lt;br /&gt;
As I was typing the above, for no reason I ran it again and IT WORKED. I made no changes. The debugger was stopped on Line 15 as described and I hit stop, then I ran it again and it worked.&lt;br /&gt;
&lt;br /&gt;
I don't understand, I am going to delete the projects and start again, to see if this happens again. I will post my results here.&lt;br /&gt;
&lt;br /&gt;
Jacob&lt;br /&gt;
&lt;/div&gt;</description><author>JacobWagner</author><pubDate>Tue, 21 May 2013 14:48:43 GMT</pubDate><guid isPermaLink="false">New Post: Problem when trying to use precompiled views in a separate library 20130521024843P</guid></item><item><title>New Post: Problem when trying to use precompiled views in a separate library</title><link>http://razorgenerator.codeplex.com/discussions/282737</link><description>&lt;div style="line-height: normal;"&gt;Looking through this thread, it has evolved through various different issues, so I'm not actually sure which one you're referring to here. :)&lt;br /&gt;
&lt;br /&gt;
Are you able to get at that issue starting from a new Mvc app to which you add RG.Mvc? It would be good to isolate what may be different about your app. If you have a repro you can share (e.g. in github), that would be ideal.&lt;br /&gt;
&lt;/div&gt;</description><author>davidebbo</author><pubDate>Tue, 21 May 2013 01:35:03 GMT</pubDate><guid isPermaLink="false">New Post: Problem when trying to use precompiled views in a separate library 20130521013503A</guid></item><item><title>New Post: Problem when trying to use precompiled views in a separate library</title><link>http://razorgenerator.codeplex.com/discussions/282737</link><description>&lt;div style="line-height: normal;"&gt;I am not sure what you mean by missing the redirect. I do know that my assemblyBinding tag matches what is recommended three posts above this.&lt;br /&gt;
&lt;br /&gt;
Since my last post I actually copied my app, changed the name, added it to my sln, and set the copy up as a view library. As soon as I added a reference to it I got the error. I am certain that all of the references and config files are identical except the reference to RazorGenerator.Mvc.&lt;br /&gt;
&lt;br /&gt;
Jacob&lt;br /&gt;
&lt;br /&gt;
P.S. thank you for responding so quickly.&lt;br /&gt;
&lt;/div&gt;</description><author>JacobWagner</author><pubDate>Mon, 20 May 2013 22:09:03 GMT</pubDate><guid isPermaLink="false">New Post: Problem when trying to use precompiled views in a separate library 20130520100903P</guid></item><item><title>New Post: Problem when trying to use precompiled views in a separate library</title><link>http://razorgenerator.codeplex.com/discussions/282737</link><description>&lt;div style="line-height: normal;"&gt;And are you sure that you're not missing the MVC4 binding redirect in web.config? With a binding redirect, it's should be impossible for both to be loaded.&lt;br /&gt;
&lt;/div&gt;</description><author>davidebbo</author><pubDate>Mon, 20 May 2013 22:01:05 GMT</pubDate><guid isPermaLink="false">New Post: Problem when trying to use precompiled views in a separate library 20130520100105P</guid></item><item><title>New Post: Problem when trying to use precompiled views in a separate library</title><link>http://razorgenerator.codeplex.com/discussions/282737</link><description>&lt;div style="line-height: normal;"&gt;When I create two fresh MVC4 apps and follow this procedure for them they work perfectly.&lt;br /&gt;
&lt;br /&gt;
However, when I attempt to create a reference to the library from my existing app (the one I want to move a view from) it gives me the above error.&lt;br /&gt;
&lt;br /&gt;
I have checked both the framework and MVC versions and they match.&lt;br /&gt;
&lt;br /&gt;
When I examine &amp;quot;ViewEngines&amp;quot; in the debugger I get the message &amp;quot;The type 'System.Web.Mvc.ViewEngines' exists in both 'System.Web.Mvc.dll' and 'System.Web.Mvc.dll'&amp;quot;&lt;br /&gt;
&lt;br /&gt;
I am not sure what else to do. I guess I can recreate everything, but that would be a lot of work.&lt;br /&gt;
&lt;br /&gt;
Jacob&lt;br /&gt;
&lt;/div&gt;</description><author>JacobWagner</author><pubDate>Mon, 20 May 2013 21:54:13 GMT</pubDate><guid isPermaLink="false">New Post: Problem when trying to use precompiled views in a separate library 20130520095413P</guid></item><item><title>New Post: compilation issue</title><link>http://razorgenerator.codeplex.com/discussions/444328</link><description>&lt;div style="line-height: normal;"&gt;1) Could you try uninstalling the RazorGenerator.Mvc package and see if you are able to compile your project? &lt;br /&gt;
2) Can you see if you have the System.Web.Mvc listed in your web.config?&lt;br /&gt;
3) How is your project referencing the Mvc 4 binary (System.Web.Mvc)?&lt;br /&gt;
&lt;/div&gt;</description><author>pranavkm</author><pubDate>Mon, 20 May 2013 20:48:16 GMT</pubDate><guid isPermaLink="false">New Post: compilation issue 20130520084816P</guid></item><item><title>New Post: compilation issue</title><link>http://razorgenerator.codeplex.com/discussions/444328</link><description>&lt;div style="line-height: normal;"&gt;In the end, there is not much magic about RazorGenerator.Mvc.dll. It's just s standard assembly that depends on Mvc 3 (like Glimpse). So when using Mvc 4, binding redirects are needed.&lt;br /&gt;
&lt;br /&gt;
Not that your build error mentions not finding MVC4 at all, so maybe that's part of the problem.&lt;br /&gt;
&lt;/div&gt;</description><author>davidebbo</author><pubDate>Mon, 20 May 2013 20:37:17 GMT</pubDate><guid isPermaLink="false">New Post: compilation issue 20130520083717P</guid></item></channel></rss>