Bug 58813 - Error deploying to iPhone when using Xamaring.Auth package
Summary: Error deploying to iPhone when using Xamaring.Auth package
Status: VERIFIED DUPLICATE of bug 58834
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 10.12 (d15-3)
Hardware: PC Windows
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
: 58762 58796 58840 ()
Depends on:
Blocks: 58834
  Show dependency tree
Reported: 2017-08-16 13:23 UTC by Paul Vrugt
Modified: 2017-08-28 05:53 UTC (History)
12 users (show)

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

build logs (5.33 MB, text/plain)
2017-08-16 22:36 UTC, mikebroughton
Version Info (8.12 KB, text/plain)
2017-08-16 22:36 UTC, mikebroughton
Pauls build log (4.14 MB, text/plain)
2017-08-18 07:04 UTC, Paul Vrugt
Paul's version info (4.98 KB, text/plain)
2017-08-18 07:05 UTC, Paul Vrugt

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 Paul Vrugt 2017-08-16 13:23:23 UTC

I'm reporting this bug after reading "https://developer.xamarin.com/guides/ios/advanced_topics/linker/". It stated there that "If your application only works with -nolink, please submit a bug report.", so that's what I'm doing. 

We have an issue when using the "Link framework SDKs only" option when building our xamarin.forms app for IOS. I've pinpointed the issue to the reference of the "Xamarin.Auth" nuget package. Once we remove this, the application builds fine again. With the nuget package installed, our project only builds using the "Don't link" option. The error that is shown during build is:

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(748,3): error : Error processing the method 'System.Void Xamarin.Auth.Authenticator::remove_Completed(System.EventHandler`1<Xamarin.Auth.AuthenticatorCompletedEventArgs>)' in the assembly 'Xamarin.Auth.dll': Value cannot be null.

We used the fix for 58789 to get the actual error from mtouch. Without this fix, the error report an "unexpected error".

What can we do to fix this?
Comment 1 Alex Soto [MSFT] 2017-08-16 16:39:48 UTC
Please include your full build logs, crash reports (if any), all your version information and the most important thing, a test case (to reproduce).

To get full build logs just set the log verbosity to diagnostic at the following locations:
- On Visual Studio for Mac: Preferences > Projects > Build
- On Visual Studio for Windows: Tools > Options > Projects and Solutions > Build and Run

On Visual Studio Windows you also want to add `-v -v -v -v` to the mtouch additional arguments by right-clicking the project in the solution explorer and selecting `Properties`.
Note: this is done automatically on Visual Studio for Mac when the log verbosity is set to diagnostic.

The easiest way to get exact version information:
- On Visual Studio for Mac: "Visual Studio" menu, "About Visual Studio" item, "Show Details" button.
- On Visual Studio for Windows: "Help menu", "About Microsoft Visual Studio" item.
Then copy/paste the version information (you can use the "Copy Information" button).
Comment 2 Alex Soto [MSFT] 2017-08-16 22:06:55 UTC
*** Bug 58796 has been marked as a duplicate of this bug. ***
Comment 3 mikebroughton 2017-08-16 22:36:05 UTC
Created attachment 24256 [details]
build logs
Comment 4 mikebroughton 2017-08-16 22:36:50 UTC
Created attachment 24257 [details]
Version Info
Comment 5 mikebroughton 2017-08-17 00:11:15 UTC
Seems to work when rolled back to Xamarin.Auth version

Fails as soon as I try any 1.5 version.
Comment 6 Sebastien Pouliot 2017-08-17 01:30:48 UTC
Thanks for the report and the additional logs! 

This seems to be related, at least in some cases, to invalid (or out of sync) debug symbols. That would explain why switching versions of Xamarin.Auth fix the issue.

If that's the case then deleting the Xamarin.Auth.pdb file should solve the build issue.

c.c. Bill from the component team wrt Xamarin.Auth packaging. Any idea of the toolchain (versions) used to build/publish the two different versions mentioned in comment #5 ?
Comment 7 Alex Soto [MSFT] 2017-08-17 01:52:49 UTC
Adding Mel to the discussion :)
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2017-08-17 04:15:47 UTC
## Bookkeeping note (mostly for the Xamarin engineering and QA teams)

In an effort to provide a small and self-contained test case that the Xamarin QA team will be able to use in verifying any proposed workarounds or fixes for this issue, I did some experimentation with a couple of the NuGet packages associated with these errors (Xamarin.Auth and Couchbase.Lite).  My simple test case construction approach was sufficient to replicate the issue with Couchbase.Lite (see Bug 58834).  Somehow the same simple approach didn't yet allow me to replicate the issue with the "Xamarin.Auth" NuGet package.  It would have been more convenient if it had because then I could have provided the additional testing information directly on this bug report, but I strongly suspect the results from the Couchbase.Lite test case will apply to the Xamarin.Auth scenario as well, so the additional version testing on that bug report might be helpful in establishing details about the source code history of the bug.

### Tentative verification of the workaround of deleting the debugging symbols:

My small test case for "Couchbase.Lite" in Bug 58834 did indeed demonstrate the property that deleting the debug symbols for the assembly mentioned in the exception message allowed the build to complete successfully.
Comment 9 Paul Vrugt 2017-08-17 07:07:13 UTC
I've tested the removal of the pdb files of the xamarin.auth, but the build still fails. I've removed all pdb files from the xamarin.auth folder in the packages folder of our solution, and cleaned the entire solution. Rebuilding results in the same error.

I CAN confirm that reverting xamarin.auth to fixes the issue.

Since "mikebroughton@outlook.com" already attached the build logs, please let me know if you need any more input from me.
Comment 10 Sebastien Pouliot 2017-08-17 13:15:43 UTC
@Paul your build logs, after the deletion, should be different from your original ones (or the ones @Mike provided).
Could you please attach them to the bug report ? thanks!

@Brendan thanks for your assistance! The additional logs might explain why you cannot duplicate this.
Comment 11 Bill Holmes 2017-08-17 15:01:43 UTC
Here is the build info I can find from Jenkins.

For 1.5.0
      System Information      
Operating System:      MacOS
OS Version:            10.12.4

Xamarin.Android:       7.2.0

XCode Version:         8.3
CocoaPods Version:     1.0.1

      System Information      
Operating System:      MacOS
OS Version:            10.11.6

Xamarin.Android:       7.1.0

XCode Version:         8.2.1
CocoaPods Version:     1.0.1
Comment 12 John Hardman 2017-08-17 16:26:13 UTC
I applied the patch from comment 4 of https://bugzilla.xamarin.com/show_bug.cgi?id=58789, downgraded the Xamarin.Auth version used in my iOS build to (thankfully, I had already arranged my Xamarin.Auth related code such that I can use different versions for different platforms), and turned off linking. That combination got things working again for me.
Comment 13 Brendan Zagaeski (Xamarin Team, assistant) 2017-08-17 18:52:47 UTC
While we're waiting on the new logs from Paul for the condition mentioned in Comment 10 (hitting the error when the debug symbols are absent), I'll surface the top of the exception message from the earlier logs in Comment 3 for quicker reference and easier Bugzilla searchability of the exception message:

> C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(748,3): error : Error processing the method 'System.Void Xamarin.Auth.Account::.ctor(System.String,System.Collections.Generic.IDictionary`2<System.String,System.String>)' in the assembly 'Xamarin.Auth.dll': Value cannot be null.
>   Parameter name: instruction
>   --- inner exception
>   Mono.Linker.MarkException: Error processing method: 'System.Void Xamarin.Auth.Account::.ctor(System.String,System.Collections.Generic.IDictionary`2<System.String,System.String>)' in assembly: 'Xamarin.Auth.dll' ---> System.ArgumentNullException: Value cannot be null.
>   Parameter name: instruction
>     at Mono.Cecil.Cil.InstructionOffset..ctor (Mono.Cecil.Cil.Instruction instruction) [0x00003] in <311724b4987d46ff81eafbc5bdc70a4e>:0 
>     at Mono.Cecil.Cil.CodeReader.ReadScope (Mono.Cecil.Cil.ScopeDebugInformation scope) [0x00015] in <311724b4987d46ff81eafbc5bdc70a4e>:0 
>     at Mono.Cecil.Cil.CodeReader.ReadScopes (Mono.Collections.Generic.Collection`1[T] scopes) [0x0000c] in <311724b4987d46ff81eafbc5bdc70a4e>:0 
>     at Mono.Cecil.Cil.CodeReader.ReadScope (Mono.Cecil.Cil.ScopeDebugInformation scope) [0x000af] in <311724b4987d46ff81eafbc5bdc70a4e>:0 
>     at Mono.Cecil.Cil.CodeReader.ReadScopes (Mono.Collections.Generic.Collection`1[T] scopes) [0x0000c] in <311724b4987d46ff81eafbc5bdc70a4e>:0 
>     at Mono.Cecil.Cil.CodeReader.ReadScope (Mono.Cecil.Cil.ScopeDebugInformation scope) [0x000af] in <311724b4987d46ff81eafbc5bdc70a4e>:0 
>     at Mono.Cecil.Cil.CodeReader.ReadDebugInfo () [0x0002a] in <311724b4987d46ff81eafbc5bdc70a4e>:0 
>     at Mono.Cecil.Cil.CodeReader.ReadMethodBody () [0x00091] in <311724b4987d46ff81eafbc5bdc70a4e>:0 
>     at Mono.Cecil.Cil.CodeReader.ReadMethodBody (Mono.Cecil.MethodDefinition method) [0x00014] in <311724b4987d46ff81eafbc5bdc70a4e>:0 
>     at Mono.Cecil.MetadataReader.ReadMethodBody (Mono.Cecil.MethodDefinition method) [0x00000] in <311724b4987d46ff81eafbc5bdc70a4e>:0
Comment 14 Brendan Zagaeski (Xamarin Team, assistant) 2017-08-17 18:54:32 UTC
*** Bug 58840 has been marked as a duplicate of this bug. ***
Comment 15 Paul Vrugt 2017-08-18 07:04:54 UTC
Created attachment 24291 [details]
Pauls build log

This is the diagnostic output of the IOS build of our project
Comment 16 Paul Vrugt 2017-08-18 07:05:39 UTC
Created attachment 24292 [details]
Paul's version info

This is Paul's visual studio 2017 version info
Comment 17 Paul Vrugt 2017-08-18 07:06:59 UTC
The build log is the build of the IOS version of our project, build with xamarin.auth version with all pdb files removed from the package, and linker behavior set to "link framework sdks only"
Comment 18 Brendan Zagaeski (Xamarin Team, assistant) 2017-08-18 16:56:58 UTC
*** Bug 58762 has been marked as a duplicate of this bug. ***
Comment 19 Brendan Zagaeski (Xamarin Team, assistant) 2017-08-18 17:19:16 UTC
Many thanks for the new log files.  It looks like there is one lingering debugger symbols file for the Xamarin.Auth package that I suspect might be the culprit:


## Additional update

Based on some follow-up investigation of the test case in Bug 58834 (from Comment 8), it appears that the underlying problem is in some sense a "version mismatch" where a fix for a bug in Mono.Cecil [1] has not yet been integrated as expected into Xamarin.iOS.  The source code change to bring that fix into Xamarin.iOS is now underway (as recorded by the pull requests on Bug 58834).

I will also check with the team about the quickest way to share a Xamarin.iOS installer package that includes the candidate fix with users (once an appropriate package has been built).

[1] https://github.com/mono/cecil/commit/16d23978e7084c910b47f84092a5c546d880ae48
Comment 20 Brendan Zagaeski (Xamarin Team, assistant) 2017-08-18 23:37:02 UTC
An experimental installer package with the candidate fix for the MT0000 issue as well as the follow-up MT2102 errors is now available.

For any user who might like to try that experimental version, see Bug 58834, Comment 10 for the download link and information about installing and uninstalling it.
Comment 22 Brendan Zagaeski (Xamarin Team, assistant) 2017-08-24 15:50:08 UTC
## Status update for any users watching this issue

A candidate fix that resolves closely related Bug 58834 has now been published to the Stable and Beta updater channels in Visual Studio for Mac as part of Xamarin.iOS in the Xamarin 15.3.2 Servicing Release [1].

[1] https://releases.xamarin.com/stable-release-15-3-2/

Based on the similarity of the symptoms in this bug compared to Bug 58834 (as mentioned briefly in Comment 8), I will tentatively mark this bug as a duplicate for tidiness and tallying at this time.  But Paul, if by chance you still see this issue after updating your Mac to the new Xamarin.iOS version, please do reopen this bug once more with the latest diagnostic `-v -v -v -v` verbose build output.  Thanks in advance!

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