1

How to add assembly reference for c# class file while converting from website to web application

I recently converted a VS project of mine from a website to a web application. When I did so, upon trying to view the site, I get the following error:

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

FunFactory is a class file in App_Code - what do I need to do to get this class recognized by my web application?

antinescience
  • 2,339
  • 23
  • 31

3 Answers3

1

it's App_Code problem I believe (based on what I know from your post)

Check this one out for some general discussion
ASP.NET web site can't see .cs file in App_Code folder

and specifically this one for conversion issues.
App_Code folder issues


And this one describes the problem in some more details
http://vishaljoshi.blogspot.com/2009/07/appcode-folder-doesnt-work-with-web.html

What should one do if there are isolated code files which need to be added to WAPs?

You can add code files under any folder call it “CodeFolder”, “Controllers” or anything that makes sense in your project… Just avoid putting them under “App_Code” unless you specifically want the server side compilation behavior…

Community
  • 1
  • 1
NSGaga-mostly-inactive
  • 14,052
  • 3
  • 41
  • 51
0

In Visual Studio, you can right click on the project and go down the context menu to "Add Reference". What you'll see after that does depend on your version of VS, but you'll likely get a set of tabs indicating what references you can add.

The other way to go about it is to do:

<Reference Include="[name]">
    <HintPath>[path]</HintPath>
</Reference>

Or if it's a project...

<ProjectReference Include="[path]">
  <Project>[project-GUID]</Project>
  <Name>[name]>
</ProjectReference>

Good luck.

Edit: If you're trying to use a reference in AppCode, you'll need to do:

using [namespace];

...at the top of pages where you'd want to use it.

antinescience
  • 2,339
  • 23
  • 31
-1

In Solution Explorer, right click on References, select "Add Reference"

Michael Ross
  • 572
  • 4
  • 7