Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: RazorHosting IDE intellisense

$
0
0
Re: RazorHosting IDE intellisense
.NET Development
Re: RazorHosting IDE intellisense
May. 15, 2013
05:41 am
3SA0C7T3HShow this entire thread in new window
Gratar Image based on email address
From:Rick Strahl
To:Richard Norris
You definitely don't need any of the MVC stuff because Razor doesn't use MVC in any way.

Also this:

<pages pageBaseType="System.Web.Mvc.WebViewPage">

should point to your template base class to get the basic type info for the base page.

Otherwise you can always specify the explict class in using the Inherits clause inside of the page to force the Intellisense to kick in.

+++ Rick ---


Hi Rick,

Ok, I couldn't leave it alone <g>

I've managed to get it working perfectly, the fix was the following web.config file:

<?xmlversion="1.0"?><configuration><configSections><sectionGroupname="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"><sectionname="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /><sectionname="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /></sectionGroup></configSections><runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentityname="Westwind.RazorHosting" culture="neutral" /><codeBaseversion="1.1.0.0"href="C:\Local Development\Visual Studio 2012 Solutions\MySolution\MyProject\Libraries\Westwind.RazorHosting.dll" /></dependentAssembly></assemblyBinding></runtime><system.web.webPages.razor><host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /><pages pageBaseType="System.Web.Mvc.WebViewPage"><namespaces><add namespace="System.Web.Mvc" /><add namespace="System.Web.Mvc.Ajax" /><add namespace="System.Web.Mvc.Html" /><add namespace="System.Web.Routing" /></namespaces></pages></system.web.webPages.razor><system.web><compilation targetFramework="4.0"><assemblies><add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/><add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /><add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /><add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /><add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /><add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /><add assembly="Westwind.RazorHosting, Version=1.1.0.0, Culture=neutral" /></assemblies><buildProviders><add extension=".cshtml"type="System.Web.WebPages.Razor.RazorBuildProvider, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></buildProviders></compilation></system.web></configuration>

I had to add a runtime assembly binding to a local copy of the Westwind.RazorHosting dll. This binding only works if the assembly is located somewhere under the appbase directory where the web.config resides. I could have also added the namespace to save on typing in the templates, but essentially it now works. The other namespace that is visible is just because it is within the project, as the Westwind.RazorHosting.dll is not installed in the GAC I had to create the local binding. Lastly I took the time to ensure the other assembly references were using the latest versions as my last web.config was referencing older versions. I don't know if I need all the MVC stuff, almost certainly not, but it allows me to use the context as the model it seems. Just need to test the execution, make sure there is no errors but much happier now I'm somewhere I want to be with this ;)

Thanks

Richard


The Github code is quite a bit newer and a little easier to use yet. More stable too, and it uses the latest Razor 2.0 runtimes which have many improvements in the parser and also in Intellisense support.

You'll definitely want to use that rather than the code posted with the article whcih is pretty old. I've been meaning to update this at some point but I just can't find the time.

The GitHub code has tons of examples and quite a few sample tests that should be useful in figuring out how to use it.

+++ Rick ---



Hi Rick,

Many thanks for your reply.

I'm not sure about the version, I never downloaded the source from GitHub, I guess this is my next step.

I'll go and download that and read the documentation and see where I get.

Many Thanks

Regards

Richard

Are you using the latest version of tihs stuff from GitHub? If not go grab that...

https://github.com/RickStrahl/Westwind.RazorHosting

I think the problem is the dependencies of System.Web.Razor - you need to make sure the right version is used which requires some additional configuration entries. The samples in the GitHub code should have the correct dependencies.

As to dependencies - look at the dependencies in the Westwind.RazorHosting assembly. One of those is probably required as well.

+++ Rick ---


Hi all,

I'm following Rick's fantastic article on Razor hosting and I love the work he has put into supporting the use of it more appropriately. I've included the project in one of my solutions in an attempt to use the StringHostContainer to render my templates. It all seems to work like a charm apart from the fact I am struggling with getting the intelli-sense to work with the templates.

I managed to get some of the intelli-sense working by adding a web.config file. I am able to reference an external assembly of mine and the intelli-sense can see the CustomContext OK now but without the inherits statement which means it doesn't know what Context is. The problem is I cannot the IDE to load and see the RazorHosting assembly in order to see this, trying to include the namespace results in an IDE warning. The IDE complains about not being able to find or load it or one of its dependencies. I checked I included the RazorHosting assembly in the project and made it copy local, then I added the System.Web.Razor assembly and did the same but then the error for the RazorHosting assembly changed to the System.Web.Razor assembly instead. What are its dependencies? What do I need in my web.config file? I just don't know? Below is my web.config, it is essentially thrown together, I have no idea how MVC stuff should be configured, I've hacked in the assembly references (not full names) is this my problem? I'm assuming I am missing other assembly references from this file and my project. Here is the web config:

<?xmlversion="1.0"?><configuration><configSections><sectionGroupname="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"><sectionname="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /><sectionname="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /></sectionGroup></configSections><system.web.webPages.razor><host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /><pages pageBaseType="System.Web.Mvc.WebViewPage"><namespaces><add namespace="System.Web.Mvc" /><add namespace="System.Web.Mvc.Ajax" /><add namespace="System.Web.Mvc.Html" /><add namespace="System.Web.Routing" /><add namespace="RazorHosting" /><add namespace="InternalResourceHttpServer" /></namespaces></pages></system.web.webPages.razor><system.web><compilation targetFramework="4.0"><assemblies><add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/><add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /><add assembly ="System.Web.Razor" /><add assembly="RazorHosting" /><add assembly="InternalResourceHttpServer" /></assemblies></compilation></system.web></configuration>

Here are my project references:

InternalResourceHttpServer
Microsoft.CSharp
RazorHosting
System
System.Core
System.Data
System.Data.DataSetExtensions
System.Web.Razor
System.Xml
System.Xml.Linq

Just going over this now, I'm certain I'm missing some ASP.NET assemblies here, just not sure which ones? Its not critical to have the intellisense as the templates appear to work but it would be nice to have it functioning correctly. Any advice would be greatly appreciated.

TIA

Richard










Rick Strahl
West Wind Technologies


from Maui, Hawaii

Making waves on the Web


Viewing all articles
Browse latest Browse all 10393

Trending Articles