I have two projects: one is an MVC4 application, and the other is an output type class library.
I want to make the second project (class library) a layer for understanding.
The code compiles and the server is working fine.
public static void SaveMetric(string title, double value, string azureKey, Dictionary<string, string> properties = null) { try { TelemetryClient telemetry = new TelemetryClient(); telemetry.InstrumentationKey = azureKey; telemetry.TrackMetric(title, value, properties); } catch (Exception ex) { var a = ""; } }
The problem starts when I call the telemetry.TrackMetric function. This code returns an error:
"The reference to the object is not installed in the instance of the object." (System.NullReferenceException exception).
Can I use Microsoft Insights in a class library project? And if so, what am I doing wrong?
source share