Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UWP Phantom Compiler Errors

Tags:

c#

xaml

uwp

I've got a UWP application that gives me phantom XAML compiler errors.

In this example, I'm getting an error on the Win2D control:

           <win2D:CanvasControl x:Name="MapCanvas"
                         RelativePanel.Below="UpButton" RelativePanel.Above="DownButton" RelativePanel.RightOf="LeftButton" RelativePanel.LeftOf="RightButton"
                         Draw="{x:Bind Vm.OnDrawCanvas}" 
                         CreateResources="{x:Bind Vm.OnCreateResources}" 
                         KeyUp="{x:Bind Vm.MapVm.OnKeyReleased}"
                         PointerMoved="{x:Bind Vm.OnPointerMoved}"
                         PointerPressed="{x:Bind Vm.OnPointerPressed}"
                         PointerReleased="{x:Bind Vm.OnPointerReleased}"
                         PointerExited="{x:Bind Vm.OnPointerExited}" 
                         DoubleTapped="{x:Bind Vm.OnDoubleTapped}"
                         />

The namespace for the control is:

xmlns:win2D="using:Microsoft.Graphics.Canvas.UI.Xaml"

The compiler gives the following error:

The name "CanvasControl" does not exist in the namespace "using:Microsoft.Graphics.Canvas.UI.Xaml".

The problem is of course that it does exist. In fact, the program runs fine but the XAML designer won't run because of this phantom error.

What's worse though is that these phantom errors have become real errors since upgrading VS 2015 to Update 3. If I switch between Debug and Release modes, all of my user controls now throw the same error, except that it prevents the application from building. If I cut the XAML out and paste it back in (with no other changes), it builds and runs fine. The biggest problem with this is, I've got user controls in many places and I need to do this for each and every one of them to get it to work.

If anybody has any insights into why this happens and how it can be addressed, I'd be very appreciative.

like image 818
Paul Mouchet Avatar asked Jul 03 '26 00:07

Paul Mouchet


1 Answers

There are a few problems that were being described in this situation.

The primary problem, related with the Win2D issue, was that there were 2 conflicting DLLs being referenced. The second DLL (Microsoft.Graphics.Canvas) was interfering with Win2D. When the reference to the DLL was removed from the project the Win2D errors disappeared.

like image 65
Paul Mouchet Avatar answered Jul 04 '26 13:07

Paul Mouchet