bilpor
bilpor

Reputation: 3889

Porting .NetCore VS2015 to VS2017 Referencing issue

After porting a .net core web solution from vs2015 to vs2017 I receive the following error at runtime, and am having difficulty finding the missing reference.

'IHtmlHelper' does not contain a definition for 'ApplicationInsightsJavaScript' and no extension method 'ApplicationInsightsJavaScript' accepting a first argument of type 'IHtmlHelper' could be found (are you missing a using directive or an assembly reference?) @Html.ApplicationInsightsJavaScript(TelemetryConfiguration)

I have made a reference to Microsoft.ApplicationInsights(2.2.0) and Microsoft.ApplicationInsights.AspNetCore(2.0.0)

Upvotes: 0

Views: 303

Answers (1)

strux
strux

Reputation: 11

I had same problem. Was also updating 2015 to 2017. But my issue started appearing after updating ApplicationInsights to 2.0.0.

I solved it by replacing in _ViewImports.cshtml: @inject Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration TelemetryConfiguration with: @inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet

And replacing in _Layout.cshtml: @Html.ApplicationInsightsJavaScript(TelemetryConfiguration) with: @Html.Raw(JavaScriptSnippet.FullScript)

Hope it helps

Upvotes: 1

Related Questions