sovan sovan -3 years ago 148
ASP.NET (C#) Question

Microsoft.ApplicationInsights Error: InstrumentationKey cannot be empty

I was trying to use Microsoft.ApplicationInsights, and I installed the same through nuget. but when I am trying to use

_telemetryClient.TrackException(ex, new Dictionary<string, string>
{"Id", id.ToString()}
}, null);

I am getting an error saying:
InstrumentationKey cannot be empty.

I have already gone through the URL but I can't see any Update menu available for the config file in my VS(Note: I am using VS 2012 Pro).

I have also tried updating the config file with the instrumentation key

<ComponentID>{Instrumentation Key}</ComponentID>

But, that didn't work too.


Answer Source

I still haven't found any solution in configuration level. However, We can provide the Instrumentation Key while initializing the TelemetryClient object:

var telemetryClient = new TelemetryClient(new TelemetryConfiguration()
                                InstrumentationKey = "Key"

Please don't hesitate to post an answer how can we provide the Instrumentation key through config.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download