이름 <…>이 네임 스페이스 clr-namespace <…>에 없습니다.
잘 컴파일하는 데 사용되었지만 더 이상 그렇지 않은 작은 WPF 응용 프로그램이 있습니다. 나는 그것이 어느 시점에서 건물을 멈췄는지 말할 수 없습니다. 언젠가는 잘 작동했지만 다음날은 그렇지 않습니다.
프로젝트 구조는 다음과 같습니다

. 표준 .net dll 이외의 다른 프로젝트 또는 외부 참조는 없습니다.
문제가 발생한 사용자 컨트롤은 다음과 같습니다.
<UserControl x:Class="TimeRecorder.HistoryUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:TimeRecorder.ViewModel"
xmlns:framework="clr-namespace:TimeRecorder.Framework"
mc:Ignorable="d" Height="Auto" Width="Auto" Padding="5">
<UserControl.Resources>
<local:HistoryViewModel x:Key="ViewModel"/>
<framework:BoolToColorConverter x:Key="ColorConverter"/>
</UserControl.Resources>
<StackPanel DataContext="{StaticResource ViewModel}">
그리고 내가 얻는 오류는 다음과 같습니다. 
이것은 스크린 샷에있는 하나의 파일이 아니라이 프로젝트의 모든 사용자 컨트롤 / 창 파일에 xaml에서 유사한 방식으로 추가하는 모든 참조입니다.
그래서 파일이 있고, 파일의 네임 스페이스가 정확하고, xaml 파일의 네임 스페이스 / 클래스 이름이 (내 이해로는) 정확합니다. xaml을 입력하면 intellisense가 표시되므로 파일을 정상적으로 찾지 만 컴파일 할 때는 찾지 못합니다.
다른 게시물에서 이에 대한 가장 일반적인 솔루션은 .net 프레임 워크 버전입니다. 현재 메인 및 테스트 프로젝트 모두에 대해 .Net Framework 4로 설정되어 있습니다. 클라이언트 프로필이 아닌 정식 버전입니다.
내가 엉망이라고 생각하는 것은 다음과 같습니다 . 구성 관리자에서 두 프로젝트 모두 플랫폼이 Any CPU로 설정되어 있지만이 문제를 해결하려고 할 때 메인 프로젝트가 x86으로 설정되고 테스트 프로젝트가 Any로 설정되어 있음을 알았습니다. CPU. 그래서 구성 관리자의 기본 프로젝트에 대해 모든 CPU를 수동으로 추가했습니다. 그러나 나는 내가 이것을 올바르게했는지 또는 그것을해야하는지에 대해 솔직히 모른다. 추가 질문으로 구성 관리자를 기본 상태로 재설정 할 수있는 방법이 있습니까? 이것이 주요 문제에 대해 말할 것이 있습니까? 주 프로젝트가 항상 x86으로 설정되었는지 여부 또는 어떻게 든 x86으로 변경 한 다음 깨 졌는지 모르겠습니다. 언급했듯이이 프로젝트는 잠시 동안 잘 컴파일되었습니다.
어떤 제안? 코드에 대한 더 자세한 질문에 답해 드리겠습니다.
이런 일이 발생할 때마다 저는 Visual Studio를 다시 시작하고 솔루션을 다시 빌드했는데 제대로 작동했습니다. 이유를 말할 수 없습니다.
"Does not exist in the namespace"메시지 외에도 디자이너로부터 x64 및 ARM 타겟에 대한 창을 표시 할 수 없다는 메시지도 받았습니다.
방금 빌드를 x86 모드로 전환하고 다시 빌드 솔루션을 수행 한 다음 x64 모드로 다시 전환 한 다음 다시 빌드하면 [둘 다] 문제가 해결된다는 것을 알았습니다.
x64 솔루션을 재 구축하기 만해도 아무 일도 일어나지 않았습니다.
이것이 Visual Studio 2012 (업데이트 3)에서 저에게 효과적이었습니다.
- Visual Studio 다시 시작
- 네임 스페이스 선언에 현재 어셈블리 추가
xmlns:framework="clr-namespace:TimeRecorder.Framework;assembly=MyAssembly Build->Build Solution
도움이 된 것은 (특히이 오류가에서 발생하는 경우 App.xaml) 문제를 일으키는 참조 를 주석 처리하고 다시 빌드 한 다음 주석 해제하는 것입니다. 이것이 하는 일은 전체 프로젝트가 오류에서 빌드를 중지하는 대신 실제로 빌드 할 수 있도록하는 것입니다.
내가 수집 할 수있는 바에 따르면 앱은 특정 순서로 파일을 빌드하려고 시도하고 있으므로 App.xaml참조에있는 다른 클래스 파일 오류가 있을 때 오류를 일으키는 파일이 올바르게 컴파일되지 않았으므로 그 이유는 해당 네임 스페이스에서 파일을 찾을 수 없습니다.
솔루션을 다시 빌드하십시오 (때로는 정리 한 다음 빌드가 더 잘 작동 함). 그런 다음 오류 목록을보고 맨 아래로 스크롤하면 어셈블리 컴파일을 허용하지 않는 오류를 나타낼 가능성이 큽니다. XAML 컴파일러는 새 어셈블리가 아닌 캐시 된 버전의 어셈블리를 사용하는 것 같습니다. 구축을 의미합니다.
비슷한 문제가있었습니다. 제 경우에는 다음을 수행해야했습니다.
- xaml에서 참조 마크 업을 제거합니다 (이 예에서는
<local:HistoryViewModel x:Key="ViewModel"/>). - 클래스를 빌드하십시오 (이 예제 파일에는
HistoryViewModelclass 가 포함되어 있습니다 ) - 빌드되면 xaml에 참조 마크 업을 추가합니다.
- 다시 짓다
위의 방법이 저에게 효과적이었습니다.
나를 위해 일한 것 :-디버그에서 릴리스로 솔루션 구성 전환-릴리스에서 디버그로 구성 전환
어떤 솔루션도 나를 위해 일하지 않았습니다. 이 방법으로 수정했습니다.
- 참조에서 라이브러리의 dll을 제거하십시오.
- dll 파일 대신 라이브러리의 소스 코드 다운로드
- 새 dll 파일을 얻기 위해 라이브러리의 프로젝트를 빌드하십시오.
- 주 프로젝트의 참조에 새 dll 파일을 추가합니다.
".Net Framework 4.5"의 대상 프레임 워크 내 응용 프로그램을 ".Net Framework 4.6"으로 변경했고 작동했습니다!
이 문제가 원을 그리며 돌아가는 데 몇 시간이 걸렸습니다. 별도의 사용자 컨트롤 dll을 프로젝트로 이동하여 참조 된 dll이 아닌 프로젝트에서 컴파일되었습니다. 이로 인해 전체 프로젝트가 망가 졌기 때문에 모든 네임 스페이스, 경로 및 파일 이름을 꼼꼼하게 확인했습니다. x86과 AnyCPU 사이에서 obj 파일을 삭제하고 릴리스와 디버그 사이를 변경했습니다. 모두 저장을 열면 여전히 기쁨이 없습니다.
Remember having a similar problem before previously, the error flagged in VS2013 was not directly related to where I had to modify the XAML but by using
x:Name="myControl"
on all controls, instead of
Name="myControl"
fixed it.
Here's a weird example of a similar thing:
<UserControl x:Class="Gtl.Ui.Controls.WaitControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:Gtl.Ui.Controls"
mc:Ignorable="d"
d:DesignHeight="120" d:DesignWidth="120"
Background="Transparent">
...
</UserControl>
will compile (VS2013).
<UserControl x:Class="Gtl.Ui.Controls.WaitControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:Gtl.Ui.Controls"
mc:Ignorable="d"
d:DesignHeight="120" d:DesignWidth="120"
Background="Transparent"
IsVisibleChanged=onIsVisibleChanged>
...
</UserControl>
produces the error "type Ui not found in Gtl.Ui.Gtl" (and I assure you the handler method exists in the code-behind). The work-around is to add the handler in the class constructor, but c'mon Microsoft, wtf is going on?
I faced the same issue when i was trying to call the namespace in xaml. was showing that class is not available in the namespace. I searched a lot. Finally i found this issue was with VS. I am using VS 2013. I tried below steps:
- Build-->Configuration Manager--> Active Solution Platform --> Changed to x64 and x86 and Any CPU.
- Closed the VS and opened again.
Change
xmlns:VM="clr-namespace:MyFirstAppViewModel"to
xmlns:VM="clr-namespace:MyFirstAppViewModel;assembly=ViewModel"
- i would recommend to Rename
x:Key="ViewModel"maybe there is a glitch - and if you type
local:does VS show youHistoryViewModel? - also check if your
Classispublic
Ran into this issue today with Visual Studio 2017 Community Edition. Tried all the suggestions here (reset VS 2017, changed from x64 to x32 and back again etc etc) and from other sources to no avail. Intellisense knows everything is there but I was getting the same error everytime.
Anyway, my fix turned out to be very simple ... aren't they always when you have spent a couple of hours on the problem!
Basically, I did the following ...
- Remove offending code from xaml file (just 3 lines in my case)
- Build project so you get a successful build
- At this point the layout magically appeared in the designer window which was a good sign!
- Reinserted the code I removed in point 1. including the xmlns: entry
- At this point you shouldn't get any blue squiggles ... hopefully
- Build the project again
It's seem that by getting a successful build, it must reset 'something' within VS and/or the assembly. Once you have a successful build try inserting your code again.
Hope this helps someone out :)
This error usually occurs when project was not build successfully during the last build.
Step-1) First remove all the error causing code from the XAML or .cs file and build & start the project by pressing F5.
Step-2) Add add your error causing code in XAML one by one.
Just run code analysis from Build menu
I found that running the command "Run Code Analysis" re-builds everything and almost always fixes the problem (right click project > Analyze > Run Code Analysis). This also generally re-builds the resource files also so that strings, etc. can be found.
Tried all solutions on this thread but none worked. It turned out to be cause by the solution configuration. My WPF app was set to build for X64 because of some native dependencies that require it but the solution configuration was still set to AnyCPU for the project. Creating a new X64 configuration for the project in the solution configuration manager allowed the XAML designer to finally recognize my type and namespace.
This is a recurring problem for me. One of the time I found the solution looking into the Warning tab. It was a .NET framework version issue and it stated the following:
Warning 9 The primary reference "myDll" could not be resolved because it was built against the ".NETFramework,Version=v4.5.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0".
There is a glitch with their buffering of the objects layouts. If anything gets renamed or moved, it gets lost. What generally works for me is to create a completely new class and copy in all the old code, get it working on the new class, then remove the original class. Sometimes after you get it up and running with the new class name, you can try renaming it back to the original name (but usually not)
I was using xmlns:local="using:MyRootNamespace.ChildNamespace" at the header of the .xaml , and i turned it into xmlns:local="clr-namespace:MyRootNamespace.ChildNamespace" ... well, I just let intellisense do the job, and it worked.
문제는 x86 대상을 만들 때 특정 프로젝트의 출력 경로가 bin \ x86 \ Debug로 설정된다는 것입니다. Expression blend가 전혀 좋아하지 않는 것 같습니다. bin \ Debug의 내용에만 관심이있는 것 같습니다.
예를 들어 x86 프로젝트의 출력 경로를 bin \ debug로 변경했다면 제대로 작동 할 것이라고 확신합니다. 글쎄, 어쨌든 나를 위해 작동합니다 :)
추가하는 .dll 파일의 대상 프레임 워크는 앱의 대상 프레임 워크와 동일해야합니다.
참고 URL : https://stackoverflow.com/questions/15051121/the-name-does-not-exist-in-the-namespace-clr-namespace
'Nice programing' 카테고리의 다른 글
| 특정 whatsapp 연락처에 대한 웹 링크 (0) | 2020.11.09 |
|---|---|
| 타임 스탬프를 업데이트하지 않고 항목 업데이트 (0) | 2020.11.09 |
| Javascript parse float가 내 쉼표 뒤의 소수를 무시합니다. (0) | 2020.11.09 |
| Xcode 빌드 경고-대상 무결성-프로비저닝 프로파일이 ProjectnameTests 대상에 대해서만 만료됩니다. (0) | 2020.11.09 |
| Excel VBA에서 문자열을 URL 인코딩하려면 어떻게해야합니까? (0) | 2020.11.09 |