2

Her is the code I am trying to run:

Private NSRegistrar As New Bonjour.DNSSDService

Dim txtRecord As New Bonjour.TXTRecord
txtRecord.SetValue("publicKey", "ydy56dy65dy665yv65dvy65")
txtRecord.SetValue("privateKey", "ydy56dy65dy6fvaeva465yv65dvy65")

Console.WriteLine(txtRecord.GetValueForKey("publicKey"))

NSRegistrar = NSRegistrar.Register(0, 0, Environment.MachineName, "_secure._tcp", vbNullString, vbNullString, NSPort, txtRecord, NSEventManager)

Everything works fine, but when I resolve the service on another machine, the TXTRecord contains no values at all. Even the Console.WriteLine returns no value.

Has anyone managed to get TXTRecords successfully working with bonjour in vb.net or have any source code they could share?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Zone12
  • 127
  • 1
  • 10

1 Answers1

0

You have to pass the value as UTF-8 encoded byte array:

txtRecord.SetValue("key", Encoding.UTF8.GetBytes("value"));

I had the same problem too and found the solution in the SDK's source code.