Search code examples
visual-studio-2010visual-studio-2012global-asaxassembly-resolution

Using Assembly Reference in Global.asax?


I have an app that our offshore developers are trying to update. The code built with no issues a year ago. Now when they checkout the code and try to build it they get a reference error in Global.asax:

Error   1   The type or namespace name 'HartSourceLib' could not be   found (are you missing a using directive or an assembly reference?)   c:\Users\rs02130\Desktop\bip\BIProductionSupport\Global.asax    24  9   BIProductionSupport

There is a reference in the Project References pointing to the HartSourceLib DLL. The DLL is present in the referenced location and is the same DLL used in the original build. I'm not familiar with the use of external references in Global.asax. We've tried Using, <% Assembly %> and <% Import NameSpace %> and none have resolved the problem. Here's a sample of Global.asax:

enter image description here

Are we missing something in Global.asax? If not what could be causing the reference issue?

Notes: They're using VS2010 and the 3.5 Framework. I converted the Solution to VS2012 and the 4.5 Framework. Neither works.


Solution

  • Make sure the namespace is correct.

    then Add

    <%@ Import Namespace="HartSourceLib" %> at the start of the code below the 
    <%@ Application Language="C#" %>
    

    After that, make sure HartSourceLib exist in web.config file, then mark HartSourceLib file to be copied to output folder on the file properties.

    Finally clean your project and build.

    I hope that solve your issue.