Bug 18973 - The compile error MT2002 appears when build solution with Async/Await and HTTP rest libs referenced
Summary: The compile error MT2002 appears when build solution with Async/Await and HTT...
Status: RESOLVED FEATURE
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 7.2.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-04-12 17:33 UTC by Ievgen
Modified: 2014-04-15 01:51 UTC (History)
4 users (show)

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


Attachments
The solution is attached to demonstrate the problem. (413.27 KB, application/zip)
2014-04-12 17:33 UTC, Ievgen
Details
About Environment Info (865 bytes, text/plain)
2014-04-13 12:40 UTC, Ievgen
Details
Full Build Log (13.06 KB, text/plain)
2014-04-13 12:41 UTC, Ievgen
Details
The Full Build Log (26.33 KB, text/plain)
2014-04-13 13:47 UTC, Ievgen
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 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:
Status:
RESOLVED FEATURE

Description Ievgen 2014-04-12 17:33:41 UTC
Created attachment 6564 [details]
The solution is attached to demonstrate the problem.

I made a demo solution to demonstrate the bug. I have other bugs to file into
bugzilla so the solution contains several issues to reproduce at once. 

In order to compile it, the NuGet 2.8.1 (means MrWard Version 0.9) Add-In
should be installed into Xamarin.Studio. It should be taken from this URL:

http://mrward.github.com/monodevelop-nuget-addin-repository/4.0-test/main.mrep

as described here: 

http://community.sharpdevelop.net/blogs/mattward/archive/2013/01/07/MonoDevelopNuGetAddin.aspx

Therefore before building the solution all NuGet packages should be restored
for the main and libarary projects.

So the solution as is can be successfully built and run in iPhone Simulator, but when you try to run it on an iPhone it produces compilation error:

Error MT2002: Failed to resolve "System.Void System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(System.String)" reference from "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" (MT2002) (Bugs)

There is a discussion about the same error here: http://forums.xamarin.com/discussion/13213/deploying-to-device-fails-for-ios-project-from-vs2013. But the offered solution there doesn't help in my case.
Comment 1 Ievgen 2014-04-12 17:35:19 UTC
By offered solution that didn't help I meant setting "Copy Local" to False to all System.* referenced libs in portable library and the main project.
Comment 2 Sebastien Pouliot 2014-04-13 11:17:33 UTC
Please add "-v -v -v -v" to your project's configuration (under "mtouch additional arguments"), do a clean and then build again. Attach the full build log to the bug report.

Also include your complete version information about the softwarare you're presently using.

The easiest way to get exact version information is to use the "Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" button and copy/paste the version informations (you can use the "Copy Information" button).
Comment 3 Ievgen 2014-04-13 12:40:36 UTC
Created attachment 6567 [details]
About Environment Info
Comment 4 Ievgen 2014-04-13 12:41:05 UTC
Created attachment 6568 [details]
Full Build Log
Comment 5 Sebastien Pouliot 2014-04-13 13:30:10 UTC
The attached build log did not include the "-v -v -v -v" arguments - but I was able to duplicate the issue.

Copied /Users/sebastienpouliot/Downloads/Bugs-Solution/packages/Microsoft.Bcl.1.1.8/lib/portable-net40+win8/System.Runtime.dll to /Users/sebastienpouliot/Downloads/Bugs-Solution/Bugs/obj/iPhone/Debug/mtouch-cache/Link/System.Runtime.dll

So the System.Runtime.dll facade assembly (shipped with XI) is not being used.

I'm not sure if there are known issues (or specific requirements) for PCL with NuGet. c.c. Martin and Matt
Comment 6 Ievgen 2014-04-13 13:47:33 UTC
Created attachment 6569 [details]
The Full Build Log

Sorry, the last build log indeed was not full. (I set -v-v-v-v for debug mode and switched to release one before building...)
Comment 7 Martin Baulig 2014-04-14 17:01:22 UTC
That's not a bug, you're using an unsupported combination of frameworks and NuGet packages.

Changing this from Profile 158 to 78, then reinstalling all those NuGet packages could help.
Comment 8 Ievgen 2014-04-15 01:51:44 UTC
Hey Martin,

Thanks for your feedback! Indeed I could change profile to 78. Initially I stuck on compilation issues with reflection code due to changes in .net4.5 (so I used profile158) but I just finished a refactoring and I could run my solution with PCL on profile 78 and the mentioned in this bug problem was fixed.

Although it's really confusing that it was working in iPhone Simulator but didn't on real iPhone. I bet this will confuse other people to, so maybe there could be some improvements applied to make the development more consistent.

So overall your advise pretty much helped to move forward, but I couldn't get my thing working after all. It seems that running RestSharp.Portable in PCL on Xamarin is not possible at the moment. Due to the bugs in Xamarin or RestSharp.Portable?

I could file another bug with steps and description of the problem: again it works in Simulator but doesn't work on iPhone. This time the problem with different versions of System.Net.Http that comes as a dependency for RestSharp.Portable NuGet Package referencing Microsoft HTTP Client Libraries. Does it worth it to create a bug or it's a known issue?

People are talking about this at Forums: https://forums.xamarin.com/discussion/14919/sending-http-requests-from-xamarin-portable-class-library

Thanks.