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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:22:16+00:00 2026-06-02T18:22:16+00:00

I cannot figure out a relative path that works for my resource. I’ve tried

  • 0

I cannot figure out a relative path that works for my resource. I’ve tried everything I could think of. The only thing that works is an absolute path that is only correct on my system, but would be incorrect in any deployed version.

As far as I know, this very simple path should work.

public class GreyscaleEffect : ShaderEffect
{
    private static PixelShader _pixelShader = new PixelShader()
        { UriSource = new Uri("/Effects/Greyscale.ps", UriKind.Relative) };

For which I get the error The type initializer for 'FSR.WPF.Utilities.UI. GreyscaleEffect' threw an exception. Inner Exception: Cannot locate resource 'effects/greyscale.ps'.

I’ve also tried the following:

Uri(";component/Effects/Greyscale.ps", UriKind.Relative)
Uri("/;component/Effects/Greyscale.ps", UriKind.Relative)
Uri("/FSR.WPF.Utilities.UI;component/Effects/Greyscale.ps", UriKind.Relative)

Elsewhere (in a xaml file in MUSUI), the following path is used, and it works fine:

<Image Source="/FSR.WPF.Utilities.UI;component/assets/CurrencyFlags/USD.png"

So I can’t figure out why this case, which is so similar, doesn’t work.

Only the following absolute path works:

Uri("C:\TFS\MUS 6.1.x\Mosaic Middleware\FSR.WPF.Utilities\FSR.WPF.Utilities.UI" +
    "\Effects\Greyscale.ps")

I’ve also tried all of the above with every combination of using @ in front of the string, using UriKind.Absolute, and leaving out the second parameter altogether. Nothing works but the absolute path and I’m losing my mind.

Here’s the solution structure. The Main project is MUSUI, at the bottom in bold. This effect class and .ps file are both in the Effects folder which is at the root of a referenced assembly FSR.WPF.Utilities.UI.

enter image description here

Anyways, I know this has to work somehow. Anyone that can figure out the shortest working relative path possible, especially if it doesn’t require hard-coding in the assembly name, gets the prize.

  • 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-06-02T18:22:17+00:00Added an answer on June 2, 2026 at 6:22 pm

    You can’t specify a relative URI, it must be absolute. When you specify a relative URI in XAML, it is actually converted into an absolute URI using IUriContext.BaseUri, but in C# code there is no information about the current location, so you can’t use a relative URI.

    You need to specify the URI by using the pack:// URI scheme:

    UriSource = new Uri("pack://application:,,,/YourAssembly;component/Effects/Greyscale.ps");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot figure out how to plot a vector field with only 1 variable.
I'm having a small problem, that I just cannot figure out. I have a
I cannot figure out why g++ is giving the following errors. I believe that
Cannot figure this out, how to find the translated position of the background relative
I cannot figure out why this is not working. I get the same thing
Cannot figure out, where to change EOF in PyCharm. My scripts start with :
I cannot figure out how to change the title bar icon (the icon in
I cannot figure out a way to disable a container AND its children in
I cannot figure out how to enable per-session instances for my WCF service while
I cannot figure out how to make a C# Windows Form application write to

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.