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 163839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:38:16+00:00 2026-05-11T11:38:16+00:00

I have found some evidence that this is possible, self.scene = Canvas() Application.LoadComponent(self.scene, Uri(‘app.xaml’,

  • 0

I have found some evidence that this is possible,

self.scene = Canvas() Application.LoadComponent(self.scene, Uri('app.xaml', UriKind.Relative)) 

but my code is failing:

class Program {     [STAThread]     static void Main(string[] args)     {         Canvas scene = new Canvas();         Application.LoadComponent(scene, new Uri('app.xaml', UriKind.Relative));     } } 

I am using the same app.xaml with ‘Build Action: None’, and ‘Copy always’.

<Canvas     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'     x:Class='System.Windows.Controls.Canvas'     x:Name='ball_design' >      <Canvas x:Name='workaround_canvas' >          <TextBlock x:Name='fps' Canvas.Left='10' Canvas.Top='10' Height='40' Canvas.ZIndex='10000' Text='-- fps' />     <Canvas x:Name='wpfe_ball_0' Width='52' Height='52' Canvas.Left='0' Canvas.Top='30'>       <!-- Layer 3/<Group>/<Path> -->       <Path Opacity='0.900000' StrokeThickness='2.000000' Stroke='#ffa6d000' StrokeMiterLimit='1.000000' Fill='#ffcbff00' Data='F1 M 51.000000,26.000000 C 51.000000,39.806641 39.807129,51.000000 26.000000,51.000000 C 12.192871,51.000000 1.000000,39.806641 1.000000,26.000000 C 1.000000,12.193359 12.192871,1.000000 26.000000,1.000000 C 39.807129,1.000000 51.000000,12.193359 51.000000,26.000000 Z'/>        <!-- Layer 3/<Group>/<Path> -->       <Path Opacity='0.740000' Data='F1 M 43.143066,13.087891 C 50.602051,22.888672 49.009766,36.642578 39.590332,43.812500 C 30.170898,50.980469 16.489258,48.842773 9.032715,39.042969 C 1.573242,29.240234 3.166016,15.486328 12.584961,8.316406 C 22.003906,1.149414 35.685547,3.285156 43.143066,13.087891 Z'>         <Path.Fill>           <RadialGradientBrush MappingMode='Absolute' GradientOrigin='156.791016,170.453125' Center='156.791016,170.453125' RadiusX='53.626404' RadiusY='53.626404'>             <RadialGradientBrush.GradientStops>               <GradientStop Offset='0.000000' Color='#ffffffff'/>               <GradientStop Offset='0.361685' Color='#fff5f7dd'/>               <GradientStop Offset='0.415730' Color='#ffebf0bc'/>               <GradientStop Offset='1.000000' Color='#ffcbff00'/>             </RadialGradientBrush.GradientStops>             <RadialGradientBrush.Transform>               <MatrixTransform Matrix='1.190000,0.165000,-0.165000,-1.281300,-113.414185,241.757843' />             </RadialGradientBrush.Transform>           </RadialGradientBrush>         </Path.Fill>       </Path>        <!-- Layer 3/<Group>/<Path> -->       <Path Fill='#ffffffff' Data='F1 M 23.100586,9.477539 C 24.741699,11.634766 23.116211,15.630859 19.470703,18.404297 C 15.825684,21.178711 11.540039,21.678711 9.899414,19.522461 C 8.258301,17.365234 9.883789,13.369141 13.529297,10.594727 C 17.174316,7.821289 21.459961,7.321289 23.100586,9.477539 Z'/>     </Canvas>     <TextBlock x:Name='dbgwin' FontSize='10' Canvas.Top='10' Canvas.Left='250' Height='500' Width='200' Text='IronPython DLR' />    </Canvas> </Canvas> 

I get IOException: Cannot locate resource ‘app.xaml’.

What is a solution?

  • 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. 2026-05-11T11:38:16+00:00Added an answer on May 11, 2026 at 11:38 am

    It seems that external XAML file can’t be loaded by LoadComponent.

    I checked the source code:

        public static void LoadComponent(Object component, Uri resourceLocator)      {         ...          // Passed a relative Uri here.         // needs to resolve it to Pack://Application.         //..\..\ in the relative Uri will get stripped when creating the new Uri and resolving to the          //PackAppBaseUri, i.e. only relative Uri within the appbase are created here         Uri currentUri = new Uri(BaseUriHelper.PackAppBaseUri, resourceLocator);           ...     } 

    So the resourceLocator SHOULD be a relative path. And it will be treated under application:/// authority.

    MSDN

    WPF supports two authorities: application:/// and siteoforigin:///. The application:/// authority identifies application data files that are known at compile time, including resource and content files. The siteoforigin:/// authority identifies site of origin files.

    Possible data files are:

    • Packages and parts are analogous to applications and files, where an application (package) can include one or more files (parts), including:

    • Resource files that are compiled into the local assembly.

    • Resource files that are compiled into a referenced assembly.

    • Resource files that are compiled into a referencing assembly.

    • Content files.

    • Site of origin files.

    The first 4 files are accessible with application://, but I am looking for external files, so the only option is ‘Content file’.

    So I turned app.xaml into content file (details are here)

    1. Build Action to Content
    2. Copy to Output Directory to Copy always
    3. [assembly: AssemblyAssociatedContentFile(‘app.xaml’)]

    As result such exception was thrown: ‘application/xaml+xml’ ContentType is not valid.

        public static void LoadComponent(Object component, Uri resourceLocator)      {         ...              if (!MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(contentType))              {                 throw new Exception(SR.Get(SRID.ContentTypeNotSupported, contentType));              }         ...     } 

    So the LoadComponent expects ‘application/baml+xml’ instead of ‘application/xaml+xml’.

    I don’t know a way to store xaml as external file in ‘application/baml+xml’, so assume the task has no solution.

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

Sidebar

Related Questions

No related questions found

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.