当我在某个非UI
程序集中添加一个类并在UI xaml
中的某些assembly
中使用它时会出现以下错误:
Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '22' and line position '55
内部例外:
Could not load file or assembly 'XXX, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.":"XXX, PublicKeyToken=null
堆栈跟踪:
at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Pouyansoft.SellEngineering.MVVM.WPF.Letters.View.SelectLetterTemplateView.InitializeComponent() in d:\NirooTeamProject\NirooTransTeamProject\SellEngineering\Pouyansoft.SellEngineering.MVVM.WPF.Letters\View\SelectLetterTemplateView.xaml:line 1
at Pouyansoft.SellEngineering.MVVM.WPF.Letters.View.SelectLetterTemplateView..ctor() in D:\NirooTeamProject\NirooTransTeamProject\SellEngineering\Pouyansoft.SellEngineering.MVVM.WPF.Letters\View\SelectLetterTemplateView.xaml.cs:line 23
有趣的是,如果我只是在Code Behind
中的某处创建了所提及对象的单个实例,那么它就能正常工作。