내 클래스 라이브러리를 참조 할 수없는 이유는 무엇입니까?
Visual Studio 2008에 웹 사이트와 클래스 라이브러리가 포함 된 솔루션이 있습니다.
그런 다음 클래스 라이브러리를 참조해야하는 솔루션 외부에 다른 웹 사이트 프로젝트가 있습니다. Bin 폴더 또는 프로젝트를 마우스 오른쪽 단추로 클릭하고 참조 추가를 선택한 다음 클래스 라이브러리 프로젝트를 선택하면 클래스 라이브러리에 필요한 15 개 정도의 DLL이 웹 사이트 bin 폴더에 추가되지만 .cs 파일은 using 문을 인식하지 못합니다.
using MyLibrary.MyFolder;
해결할 수 없다고 말하고 ReSharper는 사용하지 않기 때문에 안전하게 제거 할 수 있다고 말합니다.
ReSharper는 참조가 필요하다는 것을 인식하고 "참조 MyLibrary 및 MyFolder 사용"을 제안합니다. 이미 가지고있는 참조를 추가하도록 제안하는 이유를 잘 모르겠습니다. 제안을 할 때 오류가 발생합니다.
"모듈을 참조하지 못했습니다. 아마도 참조는 프로젝트간에 순환 종속성을 생성 할 것입니다."
웹 사이트 속성 페이지로 이동하여 모든 참조를 제거하고 다시 추가하려고 시도했지만 동일한 오류가 발생합니다. 이것이 작동하지 않는 이유가 무엇입니까?
또한 새 솔루션의 프로젝트가 포함하려는 프로젝트와 호환되는 프레임 워크에 대해 실행되는지 확인합니다. 3.5 프로젝트에 4.0 프로젝트에 대한 참조를 포함하려고했습니다.
이 문제를 해결하는 방법을 찾았습니다 (적어도 나를 위해). 왜 효과가 있었는지 모르겠지만 효과가있었습니다. (같은 문제가있는 두 번째 웹 사이트에 대해 방금 시도했으며 다음 솔루션도 효과가있었습니다).
나는 프로젝트를 정상적으로 정리하고 다시 빌드하고 모든 Visual Studio 인스턴스를 종료하고 다시 시작하고 컴퓨터를 다시 시작하려고 시도했습니다.
실제로 작동 한 것은 Visual Studio에서 프로젝트를 열고 열려있는 모든 탭을 닫은 다음 종료하는 것입니다.
나는 그것이 중요하지 않다고 생각했기 때문에 탭을 열어 놓기 전에 (그리고 내가 사용하는 탭을 거의 닫지 않았습니다).
한 가지 가능성은 클래스 라이브러리의 대상 .NET Framework 버전이 프로젝트의 버전보다 높다는 것입니다.
비슷한 문제가 발생했습니다. 모든 참조가 Resharper에 의해 도청 될 것입니다. 저에게 도움이 된 해결책은 Resharper 캐시를 지우고 VS를 다시 시작하는 것입니다.
tools-> options-> resharper-> options-> general-> 캐시 지우기 버튼을 클릭하고 VS를 다시 시작하십시오.
나는 VS가 때때로 구축하고 때로는 구축하지 않는 유사한 문제가있었습니다. 몇 번의 검색과 시도 후에 다른 라이브러리 ( 'FileManager')에서 동일한 이름을 가진 클래스에 대한 모호한 참조가 있음을 발견했습니다. 빌드하지 않을 프로젝트는 솔루션의 모든 모듈을 참조하는 단위 테스트였습니다. 특정 모듈에 대한 참조를 적용하면 나를 위해 일을 분류했습니다.
내 요점은 ReSharper 또는 VS를 비난하는 것보다 실제로 어떤 종류의 순환 참조가 없는지 다시 확인하는 것이 좋습니다. 종종 다른 모듈에서 동일한 이름을 가진 클래스는 혼동을 일으킬 수 있으며 종종 잘못된 디자인의 증상입니다 (제 경우와 같이).
ReSharper와 비슷한 문제인 것 같습니다.
http://www.jetbrains.net/devnet/thread/275827
빌드를 강제하는 스레드의 한 사용자에 따르면 첫 번째 빌드 후 문제 (CTRL + Shift + B)를 수정합니다.
ReSharper의 경우 특히 문제가있는 것 같습니다. 경고 및 가능한 잘못된 오류에 관계없이 빌드를 시도해 보셨습니까?
둘 다 동일한 솔루션에 있기 때문에 DLL에 대한 참조를 추가하는 대신 클래스 라이브러리 프로젝트 자체에 대한 참조를 추가하십시오 (참조 추가 대화 상자에는 이에 대한 탭이 있습니다).
아, 다른 솔루션입니다. 그것을 놓쳤다. 프로젝트에 대한 참조를 추가하는 대신 클래스 라이브러리의 컴파일 된 DLL에 대한 참조를 추가해보십시오. 참조 추가 대화 상자에는이를 수행하는 찾아보기 탭이 있습니다.
동일한 솔루션에있는 프로젝트에 대한 어셈블리를 참조하는 경우 \ bin \ Debug (또는 \ bin \ Release) 폴더에서 dll을 검색하는 대신 ( "Projects"탭 사용) 프로젝트 참조를 추가합니다 ( "찾아보기"탭). 아래 스크린 샷을 참조하십시오. 외부 어셈블리로 간주되는 경우에만 어셈블리 / dll 파일을 찾습니다.

내 프로젝트의 * .csproj.user (resharper 파일)를 삭제 한 다음 모든 탭을 닫고 다시 엽니 다. 그 후 내 프로젝트를 컴파일 할 수 있었고 resharper 경고가 없었습니다.
나는이 문제가 있었다. 알아내는 데 몇 년이 걸렸습니다. 제 어깨 너머로 도와 줄 사람들이있었습니다. Visual Studio를 다시 빌드하고 정리하고 다시 시작했지만 문제가 해결되지 않았습니다. 참조를 제거하고 다시 추가했습니다 ...
아무 소용이 없습니다 ....까지!
내 문제에 대한 해결책은 내 클래스 선언의 철자가 잘못 되었다는 것입니다.
나를 가혹하게 판단하기 전에 왜 그것이 어리석지 않았는지, 그리고 가장 똑똑한 프로그래머조차도이 실수를 저지를 수 있었던 이유를 설명해 드리겠습니다.
실수는 이름의 초기에 있었기 때문에 입력을 시작했을 때 intellisense 클래스 목록에 나타나지 않았습니다.
예 :
클래스 이름 : Message.cs
선언:
public class Massage
{
//code here
}
한 눈에 작은 글꼴로 Massage는 Message와 동일하게 보입니다.
M을 입력하면 너무 많은 클래스가 나열되었으므로 잘못 입력 된 버전에는 나타나지 않는 e를 입력했습니다. 이로 인해 컴파일러가 해당 클래스를 선택하지 않는다는 인상을 받았습니다.
동일한 버전의 asp.net이 사용되고 있는지 확인한 후. 프로젝트를 제거했습니다. 솔루션을 정리하고 프로젝트를 다시 추가했습니다. 이것이 나를 위해 일한 것입니다.
I had a similar issue in VS 2010, when creating a test project for an MVC 2 application. The symptoms were identical.
The message from ReSharper was somewhat misleading. For a moment I completely ignored ReSharper and did it the "manual VS way":
- I cleaned the solution.
- I manually added the reference to the MVC project.
- I manually added the using directives.
- ctrl-shift-b
At this stage I got a compilation error: I should have referenced the System.Web.Mvc assembly in my test project (sigh). Adding this reference causes the project to compile. The ReSharper issues remain, but the ReSharper test runner works.
When I restart VS, the ReSharper errors are gone too. I'm not sure if the restart is required - simply closing the .cs file might be enough.
From now on, when I see the ReSharper message
Failed to reference module. Probably, reference will produce circular dependencies between projects.
I'll read
Failed to reference module. Probably, reference will produce circular dependencies between projects, or you are missing some references to dependencies of the reference's dependencies.
Another possible fix that just worked for me:
If you have Assembly A, which references Assembly B, both of which reference a non-project (external) assembly X, and Assembly B's code will not recognize that you have referenced X, then try the following steps in order:
- Drop reference to X from BOTH A and B
- Recreate reference to X in B
- Recreate reference to X in A
Apparently, VS will not recognize a reference to an external assembly in a project that is a dependency of another project that already references the external. By setting up the references again from the ground up, you overcome this. It's just very odd.
I faced this problem, and I solved it by closing visual studio, reopening visual studio, cleaning and rebuilding the solution. This worked for me.
If using TFS, performing a Get latest (recursive) doesn't always work. Instead, I force a get latest by clicking Source control => Get specific version then clicking both boxes. This tends to work.
If it still doesn't work then deleting the suo file (usually found in the same place as the solution) forces visual studio to get all the files from the source (and subsequently rebuild the suo file).
If that doesn't work then try closing all your open files and closing Visual studio. When you next open Visual studio it should be fixed. There is a resharper bug that is resolved this way.
I had stumbled upon a similar issue recently. I am working in Visual Studio 2015 with Resharper Ultimate 2016.1.2. I was trying to add a new class to my code base while trying to reference a class from another assembly but Resharper would throw an error for that package.
With some help of a co-worker, I figured out that the referenced class existed in the global namespace and wasn't accessible from the new class since it was hidden by another entity of same name that existed in current namespace.
Adding a 'global::' keyword before the required namespace helped me to reference the class I was actually looking for. More details on this can be found on the page listed below:
https://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx
If both projects are contained within the same solution, it will be more apropiate if you add the reference for the project you need, not its compiled dll.
Unfortunately the only thing that worked for me was completely deleting and recreating the class library project, after having temporarily copied the class files in it elsewhere. Only then would the ASP.Net web project recognise the using statements that referred to the class library project. This was with Visual Studio 2010, not using ReSharper.
I had similar issue. What worked for me is that I had added wrong Class Library from visual studio. I added by using the search feature of visual studio.
What I needed to do was Add New Project > Visual C# > Class Library. And this newly added class library is the right one and can now be added as reference to any project.
You may forget to add reference the class library which you needed to import.
Right click the class library which you want to import in (which contains multiple imported class libraries), -->Add->Reference(Select Projects->Solution->select the class library which you want to import from->OK)
참고URL : https://stackoverflow.com/questions/2231731/why-cant-i-reference-my-class-library
'Programing' 카테고리의 다른 글
| UIImage 색상 변경 (0) | 2020.09.13 |
|---|---|
| div (부트 스트랩)에 맞게 조정 및 이미지 크기 (0) | 2020.09.13 |
| 텍스트 상자에 빈 값이 있는지 확인 (0) | 2020.09.13 |
| 직렬화 가능한 객체를 파일에 저장 / 복원하는 방법은 무엇입니까? (0) | 2020.09.13 |
| Android : CheckBox 크기를 변경하는 방법은 무엇입니까? (0) | 2020.09.13 |

