How to solve System.NullReferenceException when Transmitting iBeacon using windows-beacon-library

0

I want to transmit iBeacon from windows PC and I found this library https://github.com/AltBeacon/windows-beacon-library in C#. I don't have any knowledge about this language. I am trying to run this code in Visual Studio C# console application

using System;
using Altbeacon.Beacon;

namespace TransBeacon
{
    class Program
    {
        static void Main(string[] args)
        {
            BeaconTransmitter beaconTransmitter = new BeaconTransmitter(new BeaconParser().SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
            Beacon beacon = new Beacon.Builder()
                .SetTxPower(-59)
                .SetManufacturer(0x004c)
                .SetId1("f2873bb6-39e1-11ea-a137-2e728ce88125")
                .SetId2("25")
                .SetId3("2").Build();
            beaconTransmitter.StartAdvertising(beacon);
            Console.ReadLine();
        }
    }
}

I am facing following error

System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=WindowsBeaconLibrary StackTrace: at Altbeacon.Logger.getContext() at Altbeacon.Logger.Log(String level, String line) at Altbeacon.Logger.Error(String line) at Altbeacon.Beacon.BeaconTransmitter.d__8.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

This exception was originally thrown at this call stack: Altbeacon.Logger.getContext() Altbeacon.Logger.Log(string, string) Altbeacon.Logger.Error(string) Altbeacon.Beacon.BeaconTransmitter.OnPublisherStatusChanged(Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementPublisher, Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementPublisherStatusChangedEventArgs) System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

What is the proper method to implement this code?

c#
windows
bluetooth
ibeacon
asked on Stack Overflow May 16, 2020 by A Vyom • edited May 16, 2020 by MickyD

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0