Bug 16485 - DNSService and Linker
Summary: DNSService and Linker
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 7.0.4.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: 7.0.6
Assignee: Sebastien Pouliot
URL:
: 16610 ()
Depends on:
Blocks:
 
Reported: 2013-11-27 18:18 UTC by Vincent Bellet
Modified: 2013-12-13 09:00 UTC (History)
4 users (show)

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

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:
VERIFIED FIXED

Description Vincent Bellet 2013-11-27 18:18:49 UTC
hey,

as discussed in the forum, I have a bug that prevent me to use DNSService Invoked functions. It failed at the build.

http://forums.xamarin.com/discussion/comment/36269#Comment_36269

** Download this project :

http://s3.amazonaws.com/Tapstic-Temp/TestInvoke.zip

Select a device in the Target Combobox and build.

** here the build log file (with -v -v -v -v)

http://s3.amazonaws.com/Tapstic-Temp/build.log

**Version Information:

=== Xamarin Studio ===

Version 4.2.2 (build 2)
Installation UUID: bbd2f527-0e9d-4269-b235-0e0fd0c9de82
Runtime:
	Mono 3.2.5 ((no/964e8f0)
	GTK+ 2.24.20 theme: Raleigh
	GTK# (2.12.0.0)
	Package version: 302050000

=== Apple Developer Tools ===

Xcode 5.0.1 (3335.23)
Build 5A2053

=== Xamarin.Mac ===

Xamarin.Mac: 1.6.27

=== Xamarin.Android ===

Version: 4.10.1 (Business Edition)
Android SDK: /Users/vbellet/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		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)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Xamarin.iOS ===

Version: 7.0.4.209 (Business Edition)
Hash: 23a0827
Branch: 
Build date: 2013-11-11 16:04:00-0500

=== Build Information ===

Release ID: 402020002
Git revision: c5f82958ae7d9af652b44b87ceff777b3ad19b91
Build date: 2013-11-19 15:35:40+0000
Xamarin addins: a4044fee09138f6fd031a9944b7caaeb51e57e80

=== Operating System ===

Mac OS X 10.9.0
Darwin vbellet-MacPro.local 13.0.0 Darwin Kernel Version 13.0.0
    Thu Sep 19 22:22:27 PDT 2013
    root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
Comment 1 Sebastien Pouliot 2013-11-27 20:45:13 UTC
Thanks, I can duplicate it. Not sure why adding the previous file did not trigger it (something else must have satisfied the condition).

Anyway the workaround is to explicitly implement ICustomMarshaler, i.e.

	class UTF8Marshaler : ICustomMarshaler {
		private string cookie;
		private int nativeDataSize = 0;
		public UTF8Marshaler (string cookie)
		{
			this.cookie = cookie;
		}
		#region ICustomMarshaler implementation
		void ICustomMarshaler.CleanUpManagedData (object ManagedObj)
		{
		}
		void ICustomMarshaler.CleanUpNativeData (IntPtr pNativeData)
		{
			if (pNativeData == IntPtr.Zero) return;
			Marshal.FreeHGlobal(pNativeData);
		}
		int ICustomMarshaler.GetNativeDataSize ()
		{
			return nativeDataSize;
		}
		IntPtr ICustomMarshaler.MarshalManagedToNative (object ManagedObj)
		{
			String inString = (String)ManagedObj;
			if (inString == null)
				return IntPtr.Zero;
			byte[] utf8bytes = Encoding.UTF8.GetBytes(inString);
			nativeDataSize = utf8bytes.Length + 1;
			IntPtr ptr = Marshal.AllocHGlobal(nativeDataSize);
			Marshal.Copy(utf8bytes, 0, ptr, utf8bytes.Length);
			Marshal.WriteByte(ptr, utf8bytes.Length, 0);			
			return ptr;
		}
		object ICustomMarshaler.MarshalNativeToManaged (IntPtr pNativeData)
		{
			if (pNativeData == IntPtr.Zero)
				return null;
			List<byte> bytes = new List<byte>();
			byte readbyte;
			int i = 0;
			while ((readbyte = Marshal.ReadByte(pNativeData, i)) != 0)
			{
				bytes.Add(readbyte);
				i++;
			}
			return Encoding.UTF8.GetString(bytes.ToArray());
		}
		#endregion
	}
Comment 2 Sebastien Pouliot 2013-11-27 21:16:10 UTC
Fixed in master 2a603476b68eb16fa820cc9b42b4093168aa56b5

Thanks again for the test case!
Comment 3 Sebastien Pouliot 2013-11-27 21:38:33 UTC
QA: unit test added in master b217ff9bd412f18af36d32f3bc694fdcb546d59a
Comment 4 Vincent Bellet 2013-11-27 21:58:00 UTC
ha! I should have tried that as it changed recently (Interface implementation) ...

That indeed fix the problem!

I will test again to change back to the old code when the bug will arrive to me (I am in the beta channel)
Comment 5 Sebastien Pouliot 2013-12-05 17:36:47 UTC
*** Bug 16610 has been marked as a duplicate of this bug. ***
Comment 6 PJ 2013-12-11 18:46:00 UTC
This fix is planned to be released with Xamarin.iOS 7.0.6, which should hit the beta channel before December 23rd.
Comment 7 Prashant manu 2013-12-13 09:00:02 UTC
I have checked this issue with following builds:

Maverick and ML
X.S 4.2.2(build 2)
Mono 3.2.6
X.iOS 7.0.6-164

I am successfully able to deploy and launch application on device.
Changing the status to Verified.