this과 비슷한 상황이 있습니다. 그러나 사용자는 런타임에 플러그인이 호스트 응용 프로그램의 정적 리소스를 활용할 수있는 방법을 유창하게 생각합니다. 그것이 저의 걸림돌입니다.호스트 응용 프로그램의 리소스를 사용하는 WPF 응용 프로그램 플러그인
호스트 "K"를 호출 할 수있게합니다. 지금은 KResources.xaml이라는 리소스 사전을 만들었습니다.이 리소스 사전에서는 모든 응용 프로그램 리소스가 보관됩니다 (app.xaml은이 사전을 병합하고 하루 만에 호출합니다).
내 플러그인에서 KResources 사전을 사용해야하는 뷰 V를 만들고 있습니다.
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/K;component/Resources/KResources.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
필자는 다음과 같은 구문 시도 : 이것은 내가 현재 노력하고있어입니다
<ResourceDictionary
Source="pack://application:,,,/K;component/Resources/KResources.xaml" />
컴파일이 잘 어울리는 내 V.xaml 파일이 자원을 인식을,하지만 난 런타임에 예외가 이 뷰가 생성 될 때
System.Windows.Markup.XamlParseException occurred
HResult=-2146233087
LineNumber=19
LinePosition=8
Message='The invocation of the constructor on type 'K.UI.Infrastructure.CaliburnBootstrapper' that matches the specified binding constraints threw an exception.' Line number '19' and line position '8'.
Source=PresentationFramework
StackTrace:
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
InnerException:
HResult=-2147024809
Message=An item with the same key has already been added.
Source=mscorlib
StackTrace:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Caliburn.Micro.AssemblySourceCache.<Install>b__4(Type t)
at Caliburn.Micro.EnumerableExtensions.Apply[T](IEnumerable`1 enumerable, Action`1 action)
at Caliburn.Micro.AssemblySourceCache.<Install>b__0(Object s, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Caliburn.Micro.BindableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Caliburn.Micro.BindableCollection`1.<>c__DisplayClasse.<AddRange>b__d()
at Caliburn.Micro.XamlPlatformProvider.OnUIThread(Action action)
at Caliburn.Micro.BindableCollection`1.AddRange(IEnumerable`1 items)
at Caliburn.Micro.BootstrapperBase.StartRuntime()
at Caliburn.Micro.BootstrapperBase.Initialize()
at K.UI.Infrastructure.CaliburnBootstrapper..ctor() in C:\Dev\K\source\K.UI\Infrastructure\CaliburnBootstrapper.cs:line 44
라인 메시지는 동일한 키 항목 = 이미 첨가되었다.가 돋보입니다.
어떤 통찰력이라도 대단히 감사하겠습니다. 미리 감사드립니다!
당신이 모두 사전에 같은 키 이름을 사용하여 요소가 수행
이이 질문에 같은 시점에서 나에게 잎? 19 번 라인에 뭐가 들어 있니? –
줄 19 WpfXamlLoader 클래스 내의 줄을 참조하십시오 생각합니다. 참조 : http://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/Markup/WpfXamlLoader.cs 동일한 이름으로 정의 된 키에 대해 프로젝트를 신속하게 감사 할 것입니다. 제안 해 주셔서 감사합니다! 끝나면 다시 말하겠습니다. – 780farva
OK 가능한 한 철저히 솔루션을 빗어 냈습니다 (메모 패드 ++ 및 regexr.com에 대한 외침). 몇 개의 중복 키를 찾았지만 충돌이 없어야한다는 등의 범위가있었습니다. 어쨌든 이름 복제본을 제거했지만 런타임시 동일하지만 도움이되지 않는 예외와 여전히 싸우고 있습니다. – 780farva