7

I have 2 projects:

  • ConstrainedScheduleInterfaces
  • ConstrainedSchedule that has a folder (Testing) with my class that need the reference, here's the code:

Tests.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 
using NUnit.Framework;
using Ninject;
using ConstrainedScheduleInterfaces;

namespace ConstrainedSchedule.Testing
{
    internal static class Configuration
    {
      ...........
    }
}

I added the reference to the ConstrainedSchedule project, but the using ConstrainedScheduleInterfaces; is marked red as not found. Both the project has destination framework set .NET Framework 4.5 Any help? Thanks

4
  • 1
    not using .NET Framework 4.5 Client Profile? Commented Jan 3, 2014 at 16:52
  • Have you added the Constrained Interfaces to your References folder in the Testing Project? Commented Jan 3, 2014 at 16:53
  • Here up is not clear, I had already added the reference clicking on the ConstrainedSchedule project Commented Jan 3, 2014 at 16:59
  • @TMcKeown Starting with the .NET Framework 4.5, the Client Profile has been discontinued and only the full redistributable package is available. Commented Jan 3, 2014 at 17:10

5 Answers 5

20

Does the project contain a reference to the other project? You can't just add the namespace, the project itself needs an assembly reference to the other project which has that namespace.

In Visual Studio, open the Solution Explorer. Right-click on the ConstrainedSchedule project and select something along the lines of "Add Reference." In the dialog, select project references (depending on the version of Visual Studio it may be a tab or some other interface indicating projects as part of the solution). Select the ConstrainedScheduleInterfaces project and add the reference.

More information here.

Sign up to request clarification or add additional context in comments.

3 Comments

Yeah, I had already added the reference on the ConstrainedSchedule project. I make sure that the other project haven't the reference to the other. Ah, I have VS2012.
@Kay90: Additionally, is there an actual namespace called ConstrainedScheduleInterfaces? The project may be called that, but that doesn't guarantee such a namespace exists. Are you able to reference the type name by fully-qualifying it? What is its fully-qualified name?
Ah! Thanks!!! In the ConstrainedScheduleInterfaces files I found that the namespace had another name! Thank you very much!
8

For other people who have this problem, who have already added the reference to the dll and have made sure you have the right namespace at the top, I've found another thing that can cause this.

Select-click the file in visual studio and choose properties. In the Advanced part of properties, look for Build Action. Change it to compile if it's not already on that, and try to build again.

1 Comment

This was my problem. For some reason, when I added a couple of class files, they got marked as "content" and I did not realize it. Was driving me nuts.
3

There might be another reason: different target frameworks. My main project had ".NET Framework 4.7.2" and the referenced project (linked from another solution) had ".NET Framework 4.5.1".

Select the project properties and change the target framework.

Comments

2

I was having this issue after renaming a project and namespace due to a naming conflict.

Basically my main project had a reference to a project I made called Common, but then I needed to reference another project called Common that another dev had written. After renaming my project something like SpecificCommon, I was able to have references to both Common and SpecificCommon in my main project. However, all references to SpecificCommon namespace were now broken.

At first I thought this was some problem with the namespace refactor, but it turns out that it was because SpecificCommon and Common both still had the same assembly name (Common.dll). Changing the assembly name in SpecificCommon's properties and rebuilding solved the issue for me.

1 Comment

This was it for me, I had two projects with different names as references but they both output the same assembly name Common.dll. Wouldn't have thought to check that.
0

I ran into this problem because the class file where I defined the new class and namespace was Tests vs Tests.cs renamed to include .cs and everything worked perfectly. VisualStudio was not helping, because in the class it figured out what I was doing and did not give any errors.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.