Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 474k

Object reference is not non static member

Oct 10 2019 3:16 AM
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;
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.Threading.Tasks;  
  6. using System.Configuration;  
  7. using Microsoft.Azure.ServiceBus;  
  8. using Microsoft.ServiceBus.Messaging;  
  9. namespace ACTS083ConsoleApplication  
  10. {  
  11. class Program  
  12. {  
  13. string ConnectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];  
  14. EventHubClient client = EventHubClient.CreateFromConnectionString(ConnectionString, "pbidata");  
  15. static void Main(string[] args)  
  16. {  
  17. Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(2019, 1, 1))).TotalSeconds;  
  18. Random r = new Random();  
  19. int currentValue = r.Next(0, 100);  
  20. string postData = String.Format("[{{\"ts\":{0},\"value\":{1}}]", unixTimestamp, currentValue);  
  21. client.Send(new EventData(Encoding.UTF8.GetBytes(postData)));  
  22. Console.WriteLine("Message sent. Press Enter to Continue");  
  23. Console.ReadLine();  
  24. }  
  25. }  
  26. }  

Answers (1)