Bug 27337 - Missing overloads of EventSource.WriteEvent
Summary: Missing overloads of EventSource.WriteEvent
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 3.12.0
Hardware: PC Linux
: High normal
Target Milestone: (C7)
Assignee: Brendan Zagaeski (Xamarin Team, assistant)
: 34610 ()
Depends on:
Blocks: 34890
  Show dependency tree
Reported: 2015-02-23 21:43 UTC by Takuya Sakurai
Modified: 2016-05-19 16:12 UTC (History)
11 users (show)

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

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 GitHub or 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 Takuya Sakurai 2015-02-23 21:43:51 UTC
In MSDN, System.Diagnostics.Tracing.EventSource.WriteEvent has 14 overloads, but Mono implemented only 4.

This causes the following error:
Missing method System.Diagnostics.Tracing.EventSource::WriteEvent(int,object[]) in assembly /usr/local/lib/mono/4.5/mscorlib.dll, referenced in assembly /home/azyobuzin/foobar.dll
Error:  System.Reflection.TargetInvocationException
  Exception has been thrown by the target of an invocation.

My provisional fix is here:

Mono JIT compiler version 3.12.0 ((detached/de2f33f 2015年  2月 24日 火曜日 01:39:43 JST)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2015-10-14 23:47:13 UTC
## Additional context for the Mono developer team

Although at first glance it might seem odd to add _empty_ method overloads that contain no implementation, adding these empty overloads will be helpful in a few scenarios. In addition to preventing the error mentioned in comment 0, these overloads will allow Xamarin.iOS and Xamarin.Android customers to use the linker with applications that reference the default version of the "Microsoft TPL Dataflow" NuGet package (see [1]). Apparently the code paths in the Microsoft TPL Dataflow library that reference "System.Diagnostics.Tracing" are rarely used (or fail silently and do not break the primary intended behaviors of the library).

In short, I think it would be helpful to add these empty overloads. To help keep this bug narrowly focused, I have also filed a separate enhancement request (Bug 34890) to track any additional work that the Mono team might eventually do to implement _non-empty_ methods in the "System.Diagnostics.Tracing" namespace.

[1] https://kb.xamarin.com/customer/portal/articles/2161671-how-can-i-resolve-the-problems-related-to-system-diagnostics-tracing-for-the-microsoft-tpl-dataflow-nuget-package-


## Related Xamarin.Android and Xamarin.iOS linker errors (for reference)

### Linker error message on Xamarin.Android

> Error executing task LinkAssemblies: error XA2006: Reference to metadata item
> 'System.Void
> System.Diagnostics.Tracing.EventSource::WriteEvent(System.Int32,System.Object[])'
> (defined in 'System.Threading.Tasks.Dataflow, Version=,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') from
> 'System.Threading.Tasks.Dataflow, Version=, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a' could not be resolved.

### Linker error message on Xamarin.iOS

> MTOUCH: error MT2002: Failed to resolve "System.Void
> System.Diagnostics.Tracing.EventSource::WriteEvent(System.Int32,System.Object[])"
> reference from "System.Diagnostics.Tracing, Version=, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a"
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2015-10-14 23:56:06 UTC
*** Bug 34610 has been marked as a duplicate of this bug. ***
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2016-01-29 01:33:58 UTC
## Status update for any users CC'd on the bug

These empty overloads have now been added in the "master" branch of Mono:


### Those new changes are _not_ yet included in Xamarin.iOS or Xamarin.Android

The latest "Cycle 6 – Service Release 1" builds of Xamarin.iOS or Xamarin.Android are based on Mono commit 996df3c. That commit still uses the older version of `EventSource` [1]. The new code in the "master" branch will in theory be included into Xamarin.Android and Xamarin.iOS the next time they are "branched from master," which would by default happen for the upcoming "Cycle 7" feature release. The (very rough) initial estimate is that the first previews for Cycle 7 might be available in February.

[1] https://github.com/mono/mono/blob/996df3cb3b06afacf75adabfc63223b3e2471498/mcs/class/corlib/System.Diagnostics.Tracing/EventSource.cs
Comment 6 PJ 2016-03-02 19:59:20 UTC
This will make it into C7 as per comment 5, but not C6SR2. Updating milestone.
Comment 7 Alexander Köplinger [MSFT] 2016-03-03 17:14:40 UTC
I verified the commit is in the C7 branch (mono-4.4.0-branch) now.
Comment 8 Abhishek 2016-05-16 18:30:35 UTC
I have checked this issue with latest C7 build:

And observing the same reported behavior mention on bug description.
System.Diagnostics.Tracing.EventSource.WriteEvent has 14 overloads, but Mono implemented only 4.

Here is the screencast for the same: http://www.screencast.com/t/64vnpAhl8i

Hence reopening this issue.

Comment 9 Alexander Köplinger [MSFT] 2016-05-16 18:39:47 UTC
It looks like the contracts (reference assemblies) weren't updated when the commit was merged, that's why you're seeing the missing overloads in the Assembly Browser. They should be there at runtime.

@Marek: what's the process for regenerating the reference assemblies?
Comment 10 Marek Safar 2016-05-19 15:15:36 UTC
We fixed that for .net 4.6 which is our default target framework. Please test with that.

The api was not updated for previous version 4.0 & 4.5 and won't be that late in the cycle especially when the new code does nothing.
Comment 11 Abhishek 2016-05-19 16:12:29 UTC
I have checked this issue with latest C7 build:

I have checked this after changing the target framework .net framework 4.6. Now I am able to see all overloads of System.Diagnostics.Tracing.EventSource.WriteEvent.

Here is the screencast for the same: http://www.screencast.com/t/DmfkjV2lSci

Hence closing this issue.