Hi Team
I need some help here below with my code, the code is trying to use servicebus message in order to receive output from power bi desktop. But i am getting the following error on this object reference;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Configuration;
- using Microsoft.Azure.ServiceBus;
- using Microsoft.ServiceBus.Messaging;
- namespace ACTS083ConsoleApplication
- {
- class Program
- {
- string ConnectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
- EventHubClient client = EventHubClient.CreateFromConnectionString(ConnectionString, "pbidata");
- static void Main(string[] args)
- {
- Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(2019, 1, 1))).TotalSeconds;
- Random r = new Random();
- int currentValue = r.Next(0, 100);
- string postData = String.Format("[{{\"ts\":{0},\"value\":{1}}]", unixTimestamp, currentValue);
- client.Send(new EventData(Encoding.UTF8.GetBytes(postData)));
- Console.WriteLine("Message sent. Press Enter to Continue");
- Console.ReadLine();
- }
- }
- }