2
Vote

Razer views cannot access types in dlls references by Orchard modules

description

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

Scenario:
  • 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.

comments

sebastienros wrote Oct 16, 2012 at 7: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 10: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 7: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.

cheers,

Paul

sebastienros wrote Oct 17, 2012 at 4: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 5:44 PM

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

Piedone wrote Nov 1, 2012 at 7:56 PM

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

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