2012-03-16 3 views
3

C#의 리소스 사전 소스를 프로젝트 내의 폴더 위치로 설정하려고 시도했지만 위의 오류가 발생합니다.잘못된 URI : URI의 형식을 확인할 수 없습니다. - C#

누군가가 문제를 알려주시겠습니까?

을 Heres 코드 :

myResourceDictionary.Source = new Uri("../Resources/Styles/Shared.xaml"); 

당신이 더 이상 정보가 필요하면 알려 주시기 바랍니다.

+0

파일 경로이므로/대신 \를 사용하십시오. – jrummell

답변

8

당신은 심지어 UriKind.Relative 인수를 통과 한 후 나는 같은 문제로 실행 유지 UriKind.Relative

myResourceDictionary.Source = new Uri("../Resources/Styles/Shared.xaml", UriKind.Relative); 
1

을 사용해야합니다. 이상한 비트는 URI를 XAML에 일부 페이지가 @Magnus 제안 된 방법을 사용하여 작업하는 것이 었습니다 -하지만 그들 중 대부분은 던질 것이다 :

The format of the URI could not be determined

예외.

마지막으로, 내 문제를 100 % 해결 한 WPF 응용 프로그램의 경우 Pack Uris을 읽었습니다.

// ResourceFile is in the Root of the Application 
myResourceDictionary.Source = 
    new Uri("pack://application:,,,/ResourceFile.xaml", UriKind.RelativeOrAbsolute); 

또는

// ResourceFile is in the Subfolder of the Application 
myResourceDictionary.Source = 
    new Uri("pack://application:,,,/SubFolder/ResourceFile.xaml", UriKind.RelativeOrAbsolute); 

희망이 내가 직면했던 것과 동일한 문제로 어려움을 겪고있는 사람을 도움 :

나는 다음과 같은 URL을 사용하기 시작했다.

관련 문제