1

Well, I tried to implement this function

```

static void DisplayMessage()
{
    string userMessage = string.Format("1000 in hex is {0:x}", 1000);
    System.Windows.MessageBox.Show(userMessage);
}

```

But to compile and use this function i need to add a reference to PresentationFramework. I use Rider, i don't know how to add a reference correctly, because i see this when i want to add a reference.

Rider Adding Reference

Then, I tried to add reference on this file

```

C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\5.0.10\PresentationFramework.dll

```

And now it builds my code but also catches unhandled exeception.

```

using System;

namespace LearningSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            DisplayMessage();
        }

        static void DisplayMessage()
        {
           
            string userMessage = string.Format("1000 in hex is {0:x}", 1000);
            System.Windows.MessageBox.Show(userMessage);
        }
    }
}

```

Unhandled exception. System.IO.FileLoadException: Could not load file or assembl
y 'WindowsBase, Version=5.0.10.0, Culture=neutral, PublicKeyToken=31bf3856ad364e
35'. The located assembly's manifest definition does not match the assembly refe
rence. (0x80131040)
File name: 'WindowsBase, Version=5.0.10.0, Culture=neutral, PublicKeyToken=31bf3
856ad364e35'
   at System.Windows.MessageBox.ShowCore(IntPtr owner, String messageBoxText, St
ring caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult de
faultResult, MessageBoxOptions options)
   at System.Windows.MessageBox.Show(String messageBoxText)
   at LearningSharp.Program.DisplayMessage() in C:\Users\dchal\RiderProjects\Lea
rningSharp\LearningSharp\Program.cs:line 16
   at LearningSharp.Program.Main(String[] args) in C:\Users\dchal\RiderProjects\
LearningSharp\LearningSharp\Program.cs:line 9

Process finished with exit code -532,462,766.

So how make this code work? How to add a reference in Rider? Can I do it simplier than boring finding dll in my files? I've created a solution like this (You may say that i need to use another template, but i want to learn how to add references and make code work properly)

enter image description here

And this is my csproj (i've deleted a references which i tried to add above) enter image description here

1 Answers1

1

A little bit late but I stumbled on this problem as well, I solved it just like @Adam KaczMarski said, right click on the project -> Manage NuGet packages, type PresentationFramework and add it, And I could use System.Windows.Shapes namespace without any further problems!

Niels
  • 306
  • 2
  • 11