views:

170

answers:

4

I'm reworking someone else's code, where they had a helper class with way to much code that shouldn't be there (data access, business logic, everything had slowly been shoved in there).

I've moved the relevant code into the appropriate pre-existing classes and created a separate, brand new helper class in the appropriate project, but all my references to this class simply don't work.

Here's a simple view of how my class looks (names slightly changed);

namespace Company.Web.Application.Reporting 

{
    public class ReportHelper
    {
    here I have a bunch of methods
    }
}

and here is how it is being referenced;

using Company.Web.Application.Reporting;

namespace Company.Web.Application.App.Reports
{
    public partial class PlansReports : PageBase
    {
        //This is the problem part
        private ReportHelper Helper = new ReportHelper(); 
        heaps of other code with no problems here...
    }
}

My problem is that the I get the following error, everywhere that I try to access my new helper.

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

All my using statements are there, I have the appropriate references in each relevant project, yet this still persists. At this point I am totally stuck, I just need to get this referencing issue sorted out so I can ensure all my helper methods work correctly.

Any help is greatly appreciated,

Pat.

A: 

Is your ReportHelper in a separate project or DLL? If so have you added this project/dll as a reference? (In your solution explorer under References, check your project/dll is there.

JLWarlow
Patrick Ottery
A: 

Have you built Company.Web.Application.Reporting so that the type would be known? That would be my idea along with ensuring that the dependencies are set up properly.

JB King
A: 

It sounds like you know what you are doing and everything looks right, so it has to be something simple. Are you trying to access changes in ReportHelper that haven't been compiled into the dll? I would try rebuilding the reference assembly; every time you make changes to that assembly, it needs to be rebuilt.

Also verify you are adding the correct assembly (e.g. Debug vs. Release) to your project. It doesn't matter which type, but you don't want compile new changes into the Debug dll, and keep adding the old version of the Release dll.

Jess
A: 

OK, I found the problem (actually a colleague did)

This original Helper class was contained in the app_code folder of my main project, which as I have just learned, handles compiling differently to all other folders in a project. Code in here is compiled at run time, rather than during the build. When I created my new classes, they were in the app_code folder because I used code rush to extract the class to a new file, which kept it in the same location...after which I moved them to their "sensible" location. Unfortunately they still had the build action of "Content" inherited from their previous presence in the app_code folder. So, on the new class file, I simply changed its build action to "Compile" and now all is well with the world.

Cheers,

Pat.

Patrick Ottery
Blimey - odd setup! Glad you got it working in the end :-)
JLWarlow