Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 984347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:00:06+00:00 2026-05-16T05:00:06+00:00

I have a user control UserControl which is in an assembly Assembly. I have

  • 0

I have a user control UserControl which is in an assembly Assembly. I have a WPF application which instantiates UserControl in a programmatic way. I have already added a reference to Assembly. However, during runtime I get the ff. 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 put it back to the default Page setting. I have tried this in .NET 3 and 4 to no avail. Anyone have any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:00:06+00:00Added an answer on May 16, 2026 at 5:00 am

    The most common cause of this is if you rename an assembly. I’ll explain that scenario, then give some other possibilities.

    Assume you have a DLL project “Abc” containing UserControl “MyControl”. The generated InitializeComponent for MyControl in Abc.dll will contain the Uri “/Abc;Component/MyControl.xaml”.

    At runtime, the assembly name “Abc” is extracted and the loaded assemblies are searched for an assembly by that name. If such an assembly is found but it does not have a “MyControl.xaml” resource, you get the error you posted in the question.

    So here is the scenario:

    • You rename the Abc.dll file to Def.dll
    • You (or someone) creates a different Abc.dll file
    • In your project you reference Def.dll (which was compiled as Abc.dll)
    • Your project also directly or indirectly references Abc.dll so it is loaded when MyControl is instantiated

    Now when you instantiate MyControl from Def.dll, it looks for its xaml in the Abc.dll assembly instead of the Def.dll assembly.

    Some other scenarios in which this can happen:

    • You have a stale .g.cs file in your obj directory that has the wrong name for the xaml file. This can happen if you changed the source code without updating the date (which can happen during a checkout from a source control system or an unzip of a zip file or many other ways). Cleaning and rebuilding the solution will fix this. Since your comment says you tried this, this does not apply to you.

    • You are manually editing resource names in the .dll file after it has been compiled

    • You have loaded two assemblies with the same name (yes, this is possible), and the resource loader found the wrong one

    Note that any change to the path to the XAML file, such as renaming or moving it, can cause this problem if the .g.cs file doesn’t match the path in the resources.

    To diagnose your problem further I recommend you download a copy of NET Reflector and look at your .dll file to see:

    1. What Uri does the InitializeComponent() specify?
    2. Is there a .baml file with the same name?

    You can also examine the call stack at the point where the exception is thrown to make sure the resource manager being used has a reference to the expected assembly, not some other assembly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF user control defined in an application assembly. I'm trying to
I have a WPF UserControl, which I use in a WinForms Control within an
I am using an ASP.Net Web Application project. I have a user control which
I have user control named DateTimeUC which has two textboxes on its markup: <asp:TextBox
I have a ASP.NET user control which hosts a 'HtmlImage'. The src attribute is
I have UserControl which contains a TextBox and a Button control. The Button opens
I have a complex WPF UserControl made of other ContentControl templates which contain sets
i have a user control that descends from UserControl. When dropped onto the form
I have a user control .Is there some way to get the page in
I'm working on a user control right now in which I have a path

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.