1

I have an issue refrerencing an assembly in a view for MVC. This namespace is part of a dll I have as part of the project, it works fine but if I use anything derectly from it inside a view it gives the below:

An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.

/Views/User/Tasks.cshtml

The type 'TaskType' is defined in an assembly that is not referenced. You must add a reference to assembly 'HRServiceCalls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

If I then ref the assembly in _ViewImports.cshtml I get the below.

An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.

/Views/_ViewImports.cshtml

The type or namespace name 'HRServiceCalls' could not be found (are you missing a using directive or an assembly reference?)

@using HRServiceCalls

I even added the ref to web config to no avail.

<system.web>
    <compilation debug="true">
      <assemblies>
        <add assembly="HRServiceCalls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
      </assemblies>
    </compilation>
  </system.web>

Can anyone point out what I need to do to get this ref working in views. The models and controllers have no issue with it.

xmojmr
  • 8,073
  • 5
  • 31
  • 54
Monolithcode
  • 598
  • 8
  • 19

1 Answers1

0

The Views folder has it's own web.config file so make sure you add it there if you want to use it.

Of course there is the question do you actually need that reference there or would it be enough to use it in the controller and simply send the data to the view as the view model?

Andrei Dragotoniu
  • 6,155
  • 3
  • 18
  • 32