Razer views cannot access types in dlls references by Orchard modules


Ref: http://orchard.codeplex.com/discussions/398946

  • Create a standard .NET class library containing utility classes (for example, a POCO model or an Html Helper extension method)
  • Add this as a file based reference to an Orchard Module and
  • Use a class from this reference dll in a razor view (for example, in a part view for a widget).

@using Cool.Mvc.HtmlHelpers;

@Html.NamedValidationSummary("logon", T("Login was unsuccessful. Please correct the errors and try again.").ToString())

  • Package this module (confirming that the reference .dll was included correctly in the bin folder of the modules content)
  • Deploy this module to a fresh Orchard installation
  • Confirm that you see the reference dll in the app_data\dependencies folder in your new installation
  • Attempt to call the page using the razor view. You receive an error
"Compiler Error Message: CS0234: The type or namespace name 'xxxxxx' does not exist in the namespace 'xxxxxx' (are you missing an assembly reference?)

The workaround is to drop the dll into the root bin folder of the orchard installation.

Desired result:
Orchard should find the reference dll in the dependencies folder when compiling razor views.


sebastienros wrote Oct 16, 2012 at 8:22 PM

It should have been fixed already. Will try to find the reference and analyze what has been fixed.

sebastienros wrote Oct 16, 2012 at 11:20 PM

This should have been fixed in Orchard 1.4.1 with http://orchard.codeplex.com/workitem/18622
What version are you using ?

LordSaul wrote Oct 17, 2012 at 8:40 AM

Hi - I'm using 1.5.1, and they only worked when in the root bin folder, even if they were in the dependencies folder. Given other discussions I think that we are unusual in placing our extensions/models in non orchard-module projects. These dlls are referenced as binary references in the modules, appear in the packages, and make their way safely to the dependencies folder.



sebastienros wrote Oct 17, 2012 at 5:54 PM

Can you provide a small repro, as simple as creating a module and where to put the other dll to repro the issue ?

sebastienros wrote Oct 18, 2012 at 6:44 PM

Pushing to "Future version" as we can't wait for this bug to go RC

Piedone wrote Nov 1, 2012 at 8:56 PM

You need to add the assembly into the root Web.config of your module:

<compilation targetFramework="4.0">
    <add assembly="YourAssembly" /><!--This is needed to work in views-->