MozillaZine

Native messaging app using VB

Talk about add-ons and extension development.
scsnake
 
Posts: 1
Joined: March 18th, 2017, 8:40 pm

Post Posted March 18th, 2017, 8:55 pm

I'm trying to use a VB form application as native app to communicate with firefox extension. Referring to this stackoverflow post, the codes in VB are:

Code: Select all
Private Sub StdOut(ByVal s As String)
        Dim std = Console.OpenStandardOutput()
        Dim arr = System.Text.Encoding.Unicode.GetBytes(s)
        Dim len = arr.Length
        For i = 0 To 24 Step 8
            std.WriteByte(CByte((len >> i) And &HFF))
        Next i

        std.Write(arr, 0, len)
        std.Flush()
End Sub


I use "[1]" as the test string but the browser console in Firefox always shows:
JSON.parse: unexpected character at line 1 column 2 of the JSON data NativeMessaging.jsm:283
_startRead/this.readPromise< resource://gre/modules/NativeMessaging.jsm:283:11
JSON.parse: unexpected character at line 1 column 2 of the JSON data subprocess_common.jsm:479
readJSON/< resource://gre/modules/subprocess/subpr ... jsm:479:16


Is there anything wrong in the VB codes? Does anyone have experience in writing VB as native app for firefox extension? (I think there's no problem in the extension side and manifest.json of app.)

Environment:
Win 7 (32-bit), Firefox Developer (52.0a2), Microsoft Visual Basic 2008 Express

isaacschemm
 
Posts: 182
Joined: January 20th, 2015, 12:29 pm

Post Posted April 3rd, 2017, 11:34 am

It looks like maybe the extension is expecting JSON, and whatever string you're passing in as "s" might not be valid JSON.

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 1 guest