How to fix XDG0062 error in WPF in Visual Studio 2019

HoneyBee 186 Reputation points
2021-11-11T07:20:11.937+00:00

I am using Visual Studio 2019 16.11.6.
(Exactly today I updated to that version.)

Several issues occurred after the update.

  1. XDG0062 "Object reference not set to an instance of an object." occurs

My source code is very concise, but even if this error occurs, there is no problem in building and compiling.

  1. If you set the Background ImageSource of "Page" in the design view, it will not be visible.

Obviously, before the update, the above symptoms did not exist.

But when I build, compile, and run, everything is checked normally.

Developer technologies | Windows Presentation Foundation
0 comments No comments
{count} votes

Accepted answer
  1. Peter Fleischer (former MVP) 19,341 Reputation points
    2021-11-12T05:30:10.667+00:00

    Hi Honey,

    1. create library project for user controls
    2. create user control
    3. compile library assembly (without errors)
    4. build library assembly
    5. in main project add reference to library dll
    6. include user control in MainWindow (or Page)
    7. after you edit user control you must compile (without errors), rebuild library assembly and only then refresh designer view of MainWindow (or Page)
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Peter Fleischer (former MVP) 19,341 Reputation points
    2021-11-11T07:35:35.727+00:00

    Hi Honey,
    if you bind property in Page to property in any assembly you must first compile this assembly and then designer can use value (assembly of code behind or assembly of your project or other assembly like class library) . Before you haven't assembly without errors you can get "Object reference not set to an instance of an object."


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.