Bug 6987 - error MT2002: Can not resolve reference when building for iPhone
Summary: error MT2002: Can not resolve reference when building for iPhone
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 5.3.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2012-09-07 09:22 UTC by Bob Reck
Modified: 2012-09-07 13:17 UTC (History)
2 users (show)

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


Attachments
Build output with --linkskip=IOSTChart -v -v -v in additional monotouch arguments (31.57 KB, text/rtf)
2012-09-07 09:22 UTC, Bob Reck
Details
hotfix (3.45 MB, application/octet-stream)
2012-09-07 11:24 UTC, Sebastien Pouliot
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 FIXED

Description Bob Reck 2012-09-07 09:22:56 UTC
Created attachment 2473 [details]
Build output with --linkskip=IOSTChart -v -v -v in additional monotouch arguments

I am getting a strange error when building my app for debug deployment to my test device. This does not happen when compiling for the simulator. 

The specific error is: error MT2002: Can not resolve reference: 
System.Void MonoTouch.Foundation.NSTimer::.ctor() I've searched for this and found a bunch of similar error MT2002's but nothing has resolved this issue. 

I am running the MonoDevelop 3.0.4.5 and MonoTouch 5.4.0. 

I have posted about this to the MonoTouch forums. Sebastien was trying to help me and suggested that it was a 3rd party DLL that was causing the problem.  I have one (IOSTChart.dll) from Steema for charting purposes. Sebastien had suggested that I use the "--linkskip=IOSTChart" in the additional monotouch arguments field. Trying that did not remove the build error.

The only other references I have are: 
IOSTChart
monotouch
System
System.Core
System.Json
System.Xml
System.Xml.Linq 

Sebastien requested that I submit this bug report and include the build output (attached). 

Please let me know if you need more information to make sense of this. Thank you! 
Bob
Comment 1 Sebastien Pouliot 2012-09-07 10:25:39 UTC
IOSTChart does refer to the broken NSTimer ctor. Sadly "linkskip" won't be enough (you can remove it from your options) as, by default, the linker will need to process the IOSTChart assembly anyway.

Two things you can try (quickly):

1. Use "Link all assemblies". That will "likely" remove the code that use the invalid NSTimer. However if your application use (even indirectly) reflection you might run into other issues.

2. Use "Don't link". That will not run the linker but your application will be *much* larger (and will take more time to compile and upload to devices).

In the meantime I'll re-introduce the broken .ctor in a way that people can't use in (in new code) but make it available (as a symbol) for existing assembly binaries. I'll attach an hotfix (with instructions) once I tested it.
Comment 2 Sebastien Pouliot 2012-09-07 11:23:12 UTC
Fixed
master: c396ab596f14889438a4526d1c022707fd1ac4bc
monotouch-5.4-series: 6f74748b37404f6ab464f785029ec48f06de5737
Comment 3 Sebastien Pouliot 2012-09-07 11:24:47 UTC
Created attachment 2476 [details]
hotfix

To use the attached assembly (on top of MonoTouch 5.4.0) do:

1) backup your /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll and /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll.mdb files

2) copy the attached file to /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll

3) remove the /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll.mdb symbols (they won't match anymore)

4) clean, rebuild and test your application

Once you update to 5.4.1 the fix will be part of MonoTouch and this won't be required anymore.
Comment 4 Bob Reck 2012-09-07 12:12:46 UTC
Thank you Sebastien. Will let you know the results when I have this hotfix in place.
Bob
Comment 5 Bob Reck 2012-09-07 12:19:36 UTC
Ok, I feel like a complete tool, but can you give me some instruction on how to find those files? I'm a windows user who is still very much a Mac newbie.  Sorry and thanks!
Bob
Comment 6 Bob Reck 2012-09-07 12:47:38 UTC
Nevermind... found it. Thanks.
Comment 7 Bob Reck 2012-09-07 12:59:15 UTC
YES! It works! Thank you Sebastien!
Comment 8 Sebastien Pouliot 2012-09-07 13:17:57 UTC
Sorry it was lunch time - but I'm glad you got it working. Have fun!