2014-09-30 1 views
1

저는 ASP.Net 응용 프로그램을 만들고 있습니다. 이 중 하나의 경우, 내가 특정 모델이 자신의 폴더에 저장 한 :Visual Studio 2013에서 새 모델에 대한 참조를 인식하지 못합니까?

Models

내 CustomControls 중 하나에 내 Models/Default/ 폴더에 대한 참조가 있습니다 using Project.Models.Default을; 내가 Years_Of_Service의 내 기본 모델로 내 CustomControl YearsOfService에 대한 참조를 만들려고 그러나, 비주얼 스튜디오 (2013) 내 Models/Default/ 폴더 중 하나를 내 Years_Of_Service 또는 Years_Of_Service_Data 모델을 따기되지 않습니다

Code2

사람을 왜 이런 일이 일어나고 있는지 아이디어가 있으십니까?

편집 :

Years_Of_Service.cs :

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 

namespace PROJECT.Models 
{ 
    public class YearsOfService 
    { 
     public string Year { get; set; } 
     public decimal ServiceCredited { get; set; } 
     public decimal Salary { get; set; } 
     public string CoveredEmployer { get; set; } 
    } 
} 

Years_Of_Service_Data.cs : 해당 파일에 포함 된

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 

namespace PROJECT.Models 
{ 
    public class YearsOfServiceData 
    { 
     public List<YearsOfService> YearsOfService { get; set; } 
    } 
} 
+1

해당 파일의 내용은 무엇입니까? 내부의 클래스가 올바른 네임 스페이스 (예 : XXXX.Models.Default)에 있습니까? – DavidG

+1

우리에게 단서를주기 위해'Years_Of_Service.cs'의 내용을 보여주세요! – Belogix

+0

이 웹 응용 프로그램 프로젝트 또는 웹 사이트 프로젝트입니까? –

답변

1

당신과 같은 자신의 네임 스페이스로 참조 현재이

namespace PROJECT.Models.Default 

그래서 결국 이 :

namespace PROJECT.Models.Default 
{ 
    public class YearsOfServiceData 
    { 
     public List<YearsOfService> YearsOfService { get; set; } 
    } 
} 

마지막으로, 파일 이름과 클래스 이름을 동일하게 유지하면 매우 혼란 스러울 수 있습니다! 따라서 Years_Of_Service_Data 또는 YearsOfServiceData 중 하나를 파일 및 클래스 이름으로 지정하십시오.

+0

도움 Belogix에 감사드립니다. 내가 생각하는 차이점은 "YearsOfServiceData"의 이름을 "Years_Of_Service_Data"로 변경했지만 VS2013은 어떤 이유로 든 내 참조를 변경하지 않았다는 것입니다. –

1

클래스는 잘못된 네임 스페이스 (namespace) 상에있다 . 이 같은 올바른 지정

namespace PROJECT.Models 

하지만이 또한이 같은 Default이 포함되어야합니다 : 또는

namespace XXXX.Models.Default 
{ 
    public class YearsOfService 
    { 
     //Snip 
    } 
} 

XXXX.Models.YearsOfService

관련 문제