2

When trying to compile my .Dll I have managed to get all my references and errors figured out except for these two(which i have multiple of).

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

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

I am using System.ComponentModel and System.ComponentModel.DataAnnotations. Forgive me as im very fuzzy with all of this and I am just making a minor change to this project. I do not understand what reference I am missing to cause these errors, im also sure the problem is caused by my inexperience. Any help is appreciated, Thank you.

A small portion of the code:

using PatientTracker.Entities.Validation;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Xml.Serialization;

namespace PatientTracker.Entities
{
  [Serializable]
  public abstract class EntityBaseCore : IEntity, INotifyPropertyChanged, IDataErrorInfo, IDeserializationCallback, INotifyPropertyChanging
  {
    [Display(AutoGenerateField = false)]
    [NonSerialized]
    protected bool bindingIsNew = true;
    [Display(AutoGenerateField = false)]
    [NonSerialized]
    private bool isEntityTracked;
    [Display(AutoGenerateField = false)]
    [NonSerialized]
    private bool suppressEntityEvents;
    private string entityHashCode;
    [NonSerialized]
    private object tag;
    [NonSerialized]
    private ValidationRules _validationRules;

    [Display(AutoGenerateField = false)]
    public abstract string TableName { get; }

    [Display(AutoGenerateField = false)]
    public abstract string[] TableColumns { get; }

    [Browsable(false)]
    [Display(AutoGenerateField = false)]
    public virtual bool IsDeleted
    {
      get
      {
        return this.EntityState == EntityState.Deleted;
      }
    }
Jester
  • 56,577
  • 4
  • 81
  • 125
Justin Reid
  • 21
  • 1
  • 3
  • can you show the code that is causing these errors – Jonesopolis Mar 01 '16 at 20:19
  • I can show a small portion, which should be enough. – Justin Reid Mar 01 '16 at 20:22
  • NOTE: I also have not made any changes to this code at all. – Justin Reid Mar 01 '16 at 20:26
  • 1
    You're most likely missing a reference to `System.ComponentModel.DataAnnotations.dll` assembly. Right click on the `References` node in Solution Explorer and choose `Add Reference...`, select the `Assemblies` tab and locate the `System.ComponentModel.DataAnnotations.dll` assembly in the list and ensure that it is checked. The recompile. – William Mar 01 '16 at 20:28
  • Interesting.. So System.ComponentModel.DataAnnotations was in my references but for consistency per your recommendation I removed it and added it as a reference again. Now there is a yellow exclamation point over it, and I have 236 more errors when I attempted to recompile.. clearly something isn't right here. – Justin Reid Mar 01 '16 at 20:43
  • I have the following errors that pertain to System.ComponentModel.DataAnnotations -"Could not resolve assembly System.ComponentModel.DataAnnotations, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL. The target framework required by this assembly (3.5) is higher than the project target framework. If this reference is required by your code, you may get compilation errors" -"The referenced component 'System.ComponentModel.DataAnnotations' could not be found." – Justin Reid Mar 01 '16 at 20:45
  • _"The target framework required by this assembly (3.5) is higher than the project target framework"_ - seems clear enough to me. Your project is targeting an older framework version. – CodeCaster Mar 01 '16 at 20:49
  • Doesn't make any sense but ill try compiling on my local machine. The server only give me options 2.0, 3.0, and 3.5 which im using 3.5. the server has 4.5.1 installed. Appreciate your suggestions. – Justin Reid Mar 01 '16 at 20:54
  • Take a look in the following menu in Visual Studio: Project > [your project name] Properties. Then choose "Application" on the left an check the "Target Framework" setting. You might not be targeting the right version of .NET in your solution. – darth_phoenixx Mar 01 '16 at 21:28

1 Answers1

1

I right clicked on display and used resolve using assembly name as given above and it worked fine. removing and adding assembly didnt.

user236575
  • 95
  • 1
  • 3