当前位置: 首页 > 工具软件 > JmDNS > 使用案例 >

android jmdns,c# – Xamarin.Android JmDNS绑定问题

慕嘉茂
2023-12-01

我开始研究Xamarin.

Android的JmDNS绑定.我设法获得了构建的绑定,但我无法从我的代码中引用它.

https://github.com/ytn3rd/monodroid-bindings/tree/master/JmDNS

我遇到的第一个问题是没有IDNSListener类可供参考.所以我在那里添加了一个部分界面.我有它需要的函数void updateRecord(DNSCache dnsCache,现在很久,DNSEntry记录);注释掉,因为它会抱怨无法引用DNSCache或DNSEntry. (我相信我删除了DNSCache,这就是为什么)

不确定我做的一些事情是不是很糟糕,只是删除节点以使其编译.对于instnace.

我添加了这个以删除以下错误.

E:\Users\brads_000\Documents\GitHub\ytn3rd\monodroid-bindings\JmDNS\bindings\obj\Debug\generated\src\Javax.Jmdns.Impl.JmDNSImpl.cs(24,24):

Error CS0738: ‘Javax.Jmdns.Impl.JmDNSImpl.SubTypeEntry’ does not

implement interface member ‘Java.Util.IMapEntry.Key’.

‘Javax.Jmdns.Impl.JmDNSImpl.SubTypeEntry.Key’ cannot implement

‘Java.Util.IMapEntry.Key’ because it does not have the matching return

type of ‘Java.Lang.Object’. (CS0738) (JmDNS-Bindings)

E:\Users\brads_000\Documents\GitHub\ytn3rd\monodroid-bindings\JmDNS\bindings\obj\Debug\generated\src\Javax.Jmdns.Impl.JmDNSImpl.cs(24,24):

Error CS0738: ‘Javax.Jmdns.Impl.JmDNSImpl.SubTypeEntry’ does not

implement interface member ‘Java.Util.IMapEntry.Value’.

‘Javax.Jmdns.Impl.JmDNSImpl.SubTypeEntry.Value’ cannot implement

‘Java.Util.IMapEntry.Value’ because it does not have the matching

return type of ‘Java.Lang.Object’. (CS0738) (JmDNS-Bindings)

问题来自Java.Util.IMapEntry类.我认为正确的操作是创建我自己的parital SubEntryType然后覆盖字符串Key属性但它不会捡起它.我的下一次尝试就是这样做.

Java.Lang.Object

哪个会解决该错误,但会导致错误

E:\Users\brads_000\Documents\GitHub\ytn3rd\monodroid-bindings\JmDNS\bindings\obj\Debug\generated\src\Javax.Jmdns.Impl.JmDNSImpl.cs(12,12):

Error CS1502: The best overloaded method match for

‘Android.Runtime.JNIEnv.NewString(string)’ has some invalid arguments

(CS1502) (JmDNS-Bindings)

static IntPtr n_GetKey (IntPtr jnienv, IntPtr native__this)

{

global::Javax.Jmdns.Impl.JmDNSImpl.SubTypeEntry __this = global::Java.Lang.Object.GetObject<: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<:javax.jmdns.impl.jmdnsimpl.subtypeentry> (jnienv, native__this, JniHandleOwnership.DoNotTransfer);

return JNIEnv.NewString(__this.Key.ToString());

}

}

}

但同样,它不想选择这种新方法.

我删除了javax.jmdns.impl.DNSCache因为与上面的键/值相同的错误,

E:\Users\brads_000\Documents\GitHub\ytn3rd\monodroid-bindings\JmDNS\bindings\obj\Debug\generated\src\Javax.Jmdns.Impl.DNSCache.cs(95,95):

Error CS0508: ‘Javax.Jmdns.Impl.DNSCache.EntrySet()’: return type must

be ‘System.Collections.ICollection’ to match overridden member

‘Java.Util.AbstractMap.EntrySet()’ (CS0508) (JmDNS-Bindings)

我似乎已经解决了这个问题

System.Collections.ICollection

即使它已经回归了.

public override global :: System.Collections.Generic.ICollection EntrySet()

无论如何,任何帮助将不胜感激,以获得这个真棒库和运行:)

 类似资料: