Bug 26149 - PCL library project fails with compiler error CS0738
Summary: PCL library project fails with compiler error CS0738
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.20.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Martin Baulig
Depends on:
Reported: 2015-01-19 04:24 UTC by Prashant Cholachagudda
Modified: 2016-11-11 09:59 UTC (History)
3 users (show)

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

Test case (682.95 KB, application/zip)
2015-01-19 04:24 UTC, Prashant Cholachagudda

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 or GitHub 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 Prashant Cholachagudda 2015-01-19 04:24:10 UTC
Created attachment 9394 [details]
Test case

Customer is trying to have an interface with events in it to be implemented a concrete class inside a Xamarin project. This code works well on a regular C# project but when using Xamarin it is presenting this error:

## Compilation Errors:    
error CS0738: 'MobileDeviceManager' does not implement interface member 'IMobileDeviceManager.MyEvent'.

Additions\MobileDeviceManager.cs(16,18,16,37): error CS0012: The type 'System.Enum' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Additions\MobileDeviceManager.cs(16,18,16,37): error CS0012: The type 'System.EventHandler' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Additions\MobileDeviceManager.cs(16,18,16,37): error CS0738: 'GertecBinding.MobileDeviceManager' does not implement interface member 'ClassLibrary2.IMobileDeviceManager.Chupa'. 'GertecBinding.MobileDeviceManager.Chupa' cannot implement 'ClassLibrary2.IMobileDeviceManager.Chupa' because it does not have the matching return type of 'System.EventHandler'.

They do have an implementation of the event and the exactly same code in regular C#.

## Steps to reproduce:
1. Load attached project in Xamarin Studio
2. Compile/Build
Comment 2 Ram Chandra 2015-01-19 06:58:19 UTC
I have checked this issue and with the help of attached project I am able to reproduce this issue.

Screencast: http://www.screencast.com/t/phYDo8I4G2

Build Output: https://gist.github.com/RamChBachkheti/d0e8956246f11d499cc3
IDE logs: https://gist.github.com/RamChBachkheti/6870876c1f020edddd06

Additional info: I have checked the same application on OS X and observed that attached project is build and deployed successfully in OS X

Please let me know if I can provide more info to this issue.

Environment Info:

=== Xamarin Studio ===

Version 5.7 (build 661)
Installation UUID: b6495454-eed9-49ee-a97b-abf8a686d664
 Microsoft .NET 4.0.30319.34003
 GTK+ 2.24.22 (MS-Windows theme)
 GTK# 2.12.26

=== Xamarin.Android ===

Version: 4.20.0 (Trial Edition)
Android SDK: D:\SDK\AndroidSDK
 Supported Android versions:
  1.6    (API level 4)
  2.1    (API level 7)
  2.2    (API level 8)
  2.3    (API level 10)
  3.1    (API level 12)
  4.0    (API level 14)
  4.0.3  (API level 15)
  4.1    (API level 16)
  4.2    (API level 17)
  4.3    (API level 18)
  4.4    (API level 19)
  4.4.87 (API level 20)
  5.0    (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.7.0_71
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode)

=== Build Information ===

Release ID: 507000661
Git revision: b70bab61da996da29045ea8ee8aed1a6faedbe78
Build date: 2015-01-05 11:27:37-05
Xamarin addins: 82f6c71490562d6cd125a09287f441902fdac3d7

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 3 Jonathan Pryor 2015-01-19 17:26:08 UTC
What's funny is that I can't repro this on OS X. The primary difference is with the _GetAdditionalResourcesFromAssemblies target:


On my working build, the Assemblies output includes:

> /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/Facades/System.Runtime.dll

In fact, *all* of my assembly references are resolved from the Xamarin.Android framework, as opposed to the Build Output in Comment #2, e.g.

> C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll

This is rather puzzling to me. :-(

@Ram: Does this directory:

> C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0

contain a Facades directory with System.Runtime.dll?

Is it possible to get Diagnostic build output?
Comment 5 Jonathan Pryor 2015-01-20 11:45:40 UTC
Martin: Thoughts?

What's odd is that the diagnostic build output in Comment #4 does *not* invoke the ImplicitlyExpandDesignTimeFacades target, and the $(ResolveReferencesDependsOn) property doesn't include it either:


>ResolveReferencesDependsOn = 
>      BeforeResolveReferences;
>      AssignProjectConfiguration;
>      ResolveProjectReferences;
>      ResolveNativeReferences;
>      ResolveAssemblyReferences;
>      ResolveComReferences;
>      AfterResolveReferences
>    ;
>      ResolveTestReferences
>    ;
>            ImplicitlyExpandTargetFramework;
Comment 6 Martin Baulig 2015-01-21 18:41:16 UTC
Oh well - so many sleepless nights because of that!  There's some kind of advanced dark magic involved in this, but unfortunately I don't remember exactly how that worked :-(

What we should do is run the diagnostics output with a working test case - keep using the same PCL Profiles, but remove stuff until it compiles while still using System.Runtime.dll.  Then add one of the types back to make it fail again and compare the build output.  Is the compiler invocation still the same?

You should never see
anywhere when building Xamarin.Android.

Ping me on Slack tomorrow and we can look at this together.
Comment 7 Martin Baulig 2016-11-11 09:59:36 UTC
Closing ancient bugs, please reopen if you're still having this problem.