System.IO.IOException in PresentationFramework.dll when creating a user control in WPF

I have a UserControl user element that is on the Assembly assembly. I have a WPF application that creates UserControl program code. I have already added a link to the Assembly. However, at runtime, I get ff. an exception:

Cannot locate resource 'usercontrol.xaml'.
   at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
   at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
   at System.IO.Packaging.PackagePart.GetStream()
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   ...

I changed the build action for UserControl.xaml to EmbeddedResource, but this caused compilation problems, so I returned it to the default settings. I tried this in .NET 3 and 4 to no avail. Does anyone have an idea?

+5
source share
2 answers

. , .

, DLL- "Abc", UserControl "MyControl". InitializeComponent MyControl Abc.dll Uri "/Acc;Component/MyControl.xaml".

"Abc", . , "MyControl.xaml", , .

, :

  • Abc.dll Def.dll
  • ( -) Abc.dll
  • Def.dll( Abc.dll)
  • Abc.dll, MyControl

, MyControl Def.dll, xaml Abc.dll Def.dll.

, :

  • .g.cs obj, xaml. , ( zip ). . , , .

  • DLL

  • (, ),

, XAML, , , .g.cs .

, NET Reflector .dll, :

  • Uri InitializeComponent()?
  • .baml ?

, , , , .

+6

WPF "Windows". , "App.Xaml" :

StartupUri = "Windows\MainWindow.xaml"

0

All Articles