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?

A Vyom
  • 105
  • 1
  • 8
  • 1
    Does this answer your question? [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) –  May 16 '20 at 10:17
  • @MickyD I have already tried methods in that question but it was of no use – A Vyom May 16 '20 at 10:42

0 Answers0