Bug 34610 - Add System.Diagnostics.Tracing.EventSource.WriteEvent(int, object[])
Summary: Add System.Diagnostics.Tracing.EventSource.WriteEvent(int, object[])
Status: RESOLVED DUPLICATE of bug 27337
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 4.2.0 (C6)
Hardware: PC Windows
: --- enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-10-06 17:45 UTC by Jon Douglas [MSFT]
Modified: 2015-12-02 02:16 UTC (History)
5 users (show)

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


Attachments
Reproduction (5.09 MB, application/x-zip-compressed)
2015-10-06 17:47 UTC, Jon Douglas [MSFT]
Details


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:
Status:
RESOLVED DUPLICATE of bug 27337

Description Jon Douglas [MSFT] 2015-10-06 17:45:55 UTC
*Description

Given a PCL NuGet library that is compiled against a newer version of mscorlib.dll(4.0) - https://www.nuget.org/packages/System.Threading.Tasks.Dataflow/

Trying to reference that PCL project in another project(This case Xamarin.Android), given our mscorlib.dll in Xamarin.Android is older(2.0.5), there tends to be a linker error regarding System.Diagnostics.Tracing.EventSource and a missing overload.

The Class `System.Diagnostics.Tracing.EventSource` has an overload:

protected void WriteEvent(
    int eventId,
    params object[] args
)

https://msdn.microsoft.com/en-us/library/system.threading.tasks.dataflow(v=vs.110).aspx

However inside of the mscorlib.dll inside Xamarin.Android, there is no same overload for that method and thus I assume is why the XA2006 is thrown:

2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018: Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item 'System.Void System.Diagnostics.Tracing.EventSource::WriteEvent(System.Int32,System.Object[])' (defined in 'System.Threading.Tasks.Dataflow, Version=4.5.25.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') from 'System.Threading.Tasks.Dataflow, Version=4.5.25.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void System.Diagnostics.Tracing.EventSource::WriteEvent(System.Int32,System.Object[])
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessQueue()
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.Process()
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Mono.Linker.Pipeline.Process(LinkContext context)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute()
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    --- End of inner exception stack trace ---
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Xamarin.Android.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute()
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1295,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Investigating further, this seems to be an issue with the default PCL profile that the System.Threading.Tasks.Dataflow.dll is then referenced to in the PCL projects .csproj:

Default:

    <Reference Include="System.Threading.Tasks.Dataflow, Version=4.5.25.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Threading.Tasks.Dataflow.4.5.25\lib\portable-net45+win8+wpa81\System.Threading.Tasks.Dataflow.dll</HintPath>
      <Private>True</Private>
    </Reference>

This reference includes the problematic class and it's overload that's not found. However inside the other profile, we see that it does not have this problematic class and it's overload and therefore can be used a workaround in this case:

Linker Fix:

    <Reference Include="System.Threading.Tasks.Dataflow, Version=4.5.25.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Threading.Tasks.Dataflow.4.5.25\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Dataflow.dll</HintPath>
      <Private>True</Private>
    </Reference>

So it seems that the `portable-net45+win8+wpa81`library in `System.Threading.Tasks.Dataflow` is not compatible with Xamarin Android. Secondly this is the default behavior of adding this package into either a PCL or Android project.

*Reproduction

The reproduction's PCL profile version is: <TargetFrameworkProfile>Profile7</TargetFrameworkProfile>

However this still happens if you simply add this package to your Xamarin.Android project.

Instructions:

1) Create a File->New Android Application

2) Add the NuGet package: https://www.nuget.org/packages/System.Threading.Tasks.Dataflow/

3) Set the Configuration to Release or change linking to `Sdk Assemblies Only`

4) Apply the reference workaround above to not run into the linker issue.

*Version Information

Xamarin.Android 5.1.6.7
Comment 1 Jon Douglas [MSFT] 2015-10-06 17:47:40 UTC
Created attachment 13212 [details]
Reproduction
Comment 2 Jonathan Pryor 2015-10-06 19:49:04 UTC
Two things to note here:

1. System.Diagnostics.Tracing.EventSource isn't part of microsoft/referencesource.

2. Mono's existing EventSource implementation *doesn't do anything*:

https://github.com/mono/mono/blob/master/mcs/class/corlib/System.Diagnostics.Tracing/EventSource.cs

It is thus somewhat dubious to have this type in the first place, as all code which expects it to actually do something will be woefully disappointed.

If/when we do provide the EventSource.WriteEvent(int, object[]) overload, we should provide the others as well:

https://msdn.microsoft.com/en-us/library/system.diagnostics.tracing.eventsource.writeevent(v=vs.110).aspx
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2015-10-14 23:56:06 UTC
It turns out this is essentially a duplicate of an older bug (Bug 27337) against the Mono class libraries. The older bug asks for a _few_ additional overloads rather than just _one_, but it does cover this particular overload, and it seems it will be just as easy to add a few empty overloads as it is would be to add 1.

I have also now updated that older bug with some more notes and context related to Comment 2.

I will accordingly mark this bug as a duplicate.

*** This bug has been marked as a duplicate of bug 27337 ***