I started work on a JmDNS bindings for Xamarin.Android. I managed to get the binding to build but I can not reference it from within my code. https://github.com/ytn3rd/monodroid-bindings/tree/master/JmDNSFirst issue I had was there was no IDNSListener class to reference. So I added a partial interface in there for it. I have the function it needs void updateRecord(DNSCache dnsCache, long now, DNSEntry record); commented out as it would complain on not being able to reference DNSCache or DNSEntry. (I believe I removed DNSCache and thats why)Not sure if some of the things I have done were bad, just removing nodes to get it to compile. For instnace. I added this to remove to following errors.Issue is from the Java.Util.IMapEntry class. I thought correct action would be to create my own parital SubEntryType and then override the string Key property but it would not pick it up. My next attempt was to do this. Which would resolve that error, but would then cause an error withstatic IntPtr n_GetKey (IntPtr jnienv, IntPtr native__this){ global::Javax.Jmdns.Impl.JmDNSImpl.SubTypeEntry __this = global::Java.Lang.Object.GetObject<global::Javax.Jmdns.Impl.JmDNSImpl.SubTypeEntry> (jnienv, native__this, JniHandleOwnership.DoNotTransfer); return JNIEnv.NewString (__this.Key);}namespace Javax.Jmdns.Impl{ public partial class SubTypeEntry { static IntPtr n_GetKey (IntPtr jnienv, IntPtr native__this) { global::Javax.Jmdns.Impl.JmDNSImpl.SubTypeEntry __this = global::Java.Lang.Object.GetObject<global::Javax.Jmdns.Impl.JmDNSImpl.SubTypeEntry> (jnienv, native__this, JniHandleOwnership.DoNotTransfer); return JNIEnv.NewString(__this.Key.ToString()); } }}But again, it does not want to pick this new method up.I removed javax.jmdns.impl.DNSCache because of same errors with Key/Value as above and,Which I seemed to have fixed with Even though it is what it was already returning. public override global::System.Collections.Generic.ICollection EntrySet ()Anyway, any help would be appreciated to get this awesome library up and running :) 解决方案 I was able to build it the binding project correctly. To build it correct please try with the following approach.1.Rebuild the jar file from the jmdns-3.4.1 source. Make the DNSListener interface public. Remove the test packages. Then export the source to get the updated jar file.2.Update the jar file created from step 1. Make sure to update the build action to EmbededJar.3.EnumMethods.xml<enum-method-mappings> <mapping jni-class="javax/jmdns/impl/DNSCache"> <method jni-name="entrySet" parameter="return" clr-enum-type="System.Collections.ICollection" /> </mapping> <mapping jni-class="javax/jmdns/impl/DNSCache._CacheEntry"> <method jni-name="getKey" parameter="return" clr-enum-type="Java.Lang.Object" /> </mapping> <mapping jni-class="javax/jmdns/impl/DNSCache._CacheEntry"> <method jni-name="getValue" parameter="return" clr-enum-type="Java.Lang.Object" /> </mapping> <mapping jni-class="javax/jmdns/impl/JmDNSImpl.ServiceTypeEntry.SubTypeEntry"> <method jni-name="getKey" parameter="return" clr-enum-type="Java.Lang.Object" /> </mapping> <mapping jni-class="javax/jmdns/impl/JmDNSImpl.ServiceTypeEntry.SubTypeEntry"> <method jni-name="getValue" parameter="return" clr-enum-type="Java.Lang.Object" /> </mapping> <mapping jni-class="javax/jmdns/impl/JmDNSImpl.ServiceTypeEntry"> <method jni-name="entrySet" parameter="return" clr-enum-type="System.Collections.ICollection" /> </mapping></enum-method-mappings>4.In your sample app you have to add one more permission as android.permission.ACCESS_WIFI_STATE.5.Also all the network operation should be performed from a background thread and notify UI in Main thread. So update your MainActivity class accordingly.Hope this will help you to create the build correctly. The working copy of the sample code is uploaded here https://github.com/Hitangshu/JmDNS_Xamarin_Library 这篇关于Xamarin.Android JmDNS 绑定问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-03 18:13