Bug 58450 - "Ensure event failed" error when generating a click handler in codebehind from XAML.
Summary: "Ensure event failed" error when generating a click handler in codebehind fro...
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Xamarin.Forms ()
Version: 4.6.0 (15.3)
Hardware: PC Windows
: --- major
Target Milestone: 15.5
Assignee: Bugzilla
Depends on:
Reported: 2017-07-28 03:52 UTC by Pierce Boggan [MSFT]
Modified: 2018-01-14 15:26 UTC (History)
10 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:

IDE Logs (14.41 KB, application/x-zip-compressed)
2017-07-28 03:53 UTC, Pierce Boggan [MSFT]

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Pierce Boggan [MSFT] 2017-07-28 03:52:43 UTC
# Steps to reproduce
1. Open a Xamarin.Forms app (in this case, I did File -> New Project -> Cross-Platform -> Cross-Platform App).
2. Open a xaml file and add a button.
3. Attempt to generate a click handler for that button.

# Expected behavior
Click handler is generated without error.

# Actual behavior
Click handler throws an error "Ensure event failed". Attempting to create this event the second time succeeds.

Screencast: https://www.screencast.com/t/83GDpcPlg

# Supplemental info (logs, images, videos)
Environment Information: https://gist.github.com/pierceboggan/b19b77773aba683649587ceed6f794ac
Logs attached.
Comment 1 Pierce Boggan [MSFT] 2017-07-28 03:53:23 UTC
Created attachment 23859 [details]
IDE Logs
Comment 2 Prashant [MSFT] 2017-07-28 06:52:14 UTC
 I can confirm using the latest Visual Studio 2017 Preview version 15.3 I am able to reproduce this issue. Marking this report as CONFIRMED.

# Version information

Microsoft Visual Studio Enterprise 2017 Preview
Version 15.3.0 Preview 6.0
Microsoft .NET Framework
Version 4.7.02046

Installed Version: Enterprise

Visual Basic 2017   00369-60000-00001-AA758
Microsoft Visual Basic 2017

Visual C# 2017   00369-60000-00001-AA758
Microsoft Visual C# 2017

Visual F# 4.1   00369-60000-00001-AA758
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package   8.8.00712.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.30718.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   1.0
Provides languages services for ASP.NET Core Razor.

ASP.NET Template Engine 2017   15.0.30718.0
ASP.NET Template Engine 2017

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JavaScript UWP Project System   2.0
JavaScript UWP Project System

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   4.6.8-pre (ec7034f)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   4.3.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

TypeScript tools for Visual Studio

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Universal Windows Apps   15.0.26720.02
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin (306f76a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK (0cd0214)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK (bf350ba)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Comment 3 urs_ammann 2017-08-23 19:50:00 UTC
Are there any news with this issue? Its frustrating to make every event handler by hand.
Comment 4 Pierce Boggan [MSFT] 2017-08-29 18:18:13 UTC
We're currently looking into the issue. It appears it might be a generic issue with XAML editing that we need to pass on to that team, as it is appearing in UWP and WPF projects as well.
Comment 5 Vikki 2017-09-05 09:37:51 UTC
For me this starts happening for some reason. Previously when this problem appeared, I updated xamarin, restarted vs and somehow it went away. Now it again came.
Comment 6 Vikki 2017-09-05 09:44:48 UTC
This time it went away just by restarting VS.
Comment 7 Pierce Boggan [MSFT] 2017-09-15 21:05:09 UTC
This is a confirmed issue in the Visual Studio DTE. We've alerted that team of the issue, and they are investigating a fix.

Comment 8 Éder Costa 2018-01-14 15:26:19 UTC
Hi People,

I've declared some delegates before class in code behind and then the error happened. After changing the delegates after class, the error stopped.