I am getting the below error when I tired to refer the "Microsoft.ApplicationInsights" in SharePoint layouts aspx page which doesn't has a code behind page.
An error occurred during the compilation of the requested file, or one of its dependencies. The type or namespace name 'TelemetryClient' could not be found (are you missing a using directive or an assembly reference?)
Tried the below methods
<%@ Assembly Name="Microsoft.ApplicationInsights, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"%>
and also
<%@ Import Namespace="Microsoft.ApplicationInsights" %>
Below the piece of inline C# code in aspx page where I am trying to crate TelemetryClient object to log data into Azure
.....
TelemetryClient telemetryClient = new TelemetryClient();
telemetryClient.InstrumentationKey = instKey;
telemetryClient.TrackException(ex, sp_coid);
.....
<%@ Import Namespace="Microsoft.ApplicationInsights" %>
is the right way to include namespace but still if you are getting error then have you taken/added reference of that dll Microsoft.ApplicationInsights
in your project? (or) probably install from NuGet