Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hosting Startup is not working in dotnet core 3.0 Azure App Service (System.MissingMethodException: Method not found) #52

Closed
valeriob opened this issue Oct 25, 2019 · 15 comments
Assignees
Labels
bug Something isn't working FAQ troubleshooting Tracking for troubleshooting

Comments

@valeriob
Copy link

Hi,
i'm using the Microsoft.ApplicationInsights.Profiler.AspNetCore 2.0.0-beta1 in azure App Service with configured runtime netcore 3.0 and the following environment variable
ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=Microsoft.ApplicationInsights.Profiler.AspNetCore
It fails with this exception :

2019-10-25T15:09:06.749908649Z Unhandled exception. System.MissingMethodException: Method not found: 'Microsoft.AspNetCore.Hosting.IHostingEnvironment Microsoft.AspNetCore.Hosting.WebHostBuilderContext.get_HostingEnvironment()'.
2019-10-25T15:09:06.749966649Z at Microsoft.AspNetCore.Hosting.ServiceProfilerInjection.<>c.b__0_0(WebHostBuilderContext hostingContext, IConfigurationBuilder config)
2019-10-25T15:09:06.749973349Z at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
2019-10-25T15:09:06.749978149Z at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
2019-10-25T15:09:06.756355094Z at MyApp.Program.Main(String[] args) in C:\BuildAgent\work\bfbade9ea212e645\MyApp\Program.cs:line 14

Everything works fine if i disable it (by removing the env variable above).
Thanks

@valeriob valeriob changed the title Not working in dotnet core 3.0 Azure App Service Not working in dotnet core 3.0 Azure App Service (System.MissingMethodException: Method not found( Oct 25, 2019
@valeriob valeriob changed the title Not working in dotnet core 3.0 Azure App Service (System.MissingMethodException: Method not found( Not working in dotnet core 3.0 Azure App Service (System.MissingMethodException: Method not found) Oct 25, 2019
@xiaomi7732
Copy link
Member

@valeriob, Thanks for your report. Hosting startup is not supported in 2.0.0-beta1. Please follow the example of Quick Start to enable Profiler.

Also, could you please tell us what is the reason for you to choose to use hosting startup? It will help us decide what's the next priority.

Thanks!

@xiaomi7732 xiaomi7732 changed the title Not working in dotnet core 3.0 Azure App Service (System.MissingMethodException: Method not found) Hosting Startup is not working in dotnet core 3.0 Azure App Service (System.MissingMethodException: Method not found) Oct 25, 2019
@xiaomi7732 xiaomi7732 self-assigned this Oct 25, 2019
@xiaomi7732 xiaomi7732 added bug Something isn't working FAQ labels Oct 25, 2019
@xiaomi7732 xiaomi7732 pinned this issue Oct 25, 2019
@valeriob
Copy link
Author

I like it because it's automatically enabled via env variable on production environment, so it will not run during development, and it's non invasive, can be enabled/disabled in prod without code deploy.

@xiaomi7732
Copy link
Member

xiaomi7732 commented Oct 25, 2019

Thanks @valeriob for your feedback. Just in case you don't know, this environment variable can be used as a kill switch of the profiler:

ServiceProfiler__IsDisabled

Check out the documentation: Configuration References.

@valeriob
Copy link
Author

valeriob commented Nov 8, 2019

I'm trying 2.0.0-beta2, but it does not work with dotnet core 3.0, i get this error during startup :

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Diagnostics.PerformanceCounter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.'

@xiaomi7732
Copy link
Member

@valeriob That is interesting. Let's troubleshoot.
I assume the application failed to start at all, right? Are you running it on Windows or Linux? Could you please run dotnet --info and past the output here?

@valeriob
Copy link
Author

valeriob commented Nov 8, 2019

Hi,
i created a brand new aspnet core 3.0 application, added the nuget package, those 2 lines in configure services
services.AddApplicationInsightsTelemetry(); // Enable Application Insights telemetry
services.AddServiceProfiler(); // Add this line of code to Enable Profiler
and this code in the appsettings.json:
"ApplicationInsights": {
"InstrumentationKey": "replace-with-your-instrumentation-key"
}
i get this that exception.

dotnet --info :
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26

Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33

.NET Core SDKs installed:
2.1.802 [C:\Program Files\dotnet\sdk]
2.2.103 [C:\Program Files\dotnet\sdk]
3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

@xiaomi7732
Copy link
Member

@valeriob, so, you are running it locally on your box, right? I ran it in the same environment and didn't have a problem. If possible, could you please run your app as administrator and give it another shoot? Let's see if that is due to permission issue before we try the fancy fuslogvw.

@valeriob
Copy link
Author

valeriob commented Nov 8, 2019

Yes, i never run as admin.
But i can reproduce it on many machines, in vs F5 both admin and normal user.

@xiaomi7732
Copy link
Member

By 'vs', I think you mean Visual Studio? Could you please share the version number for VS?

To sort out visual studio magics, in the project folder, run:

dotnet run

Does it work?

Also, could you please paste your project file(*.csproj), just want to see project references and that may help us repro the issue here.

@valeriob
Copy link
Author

valeriob commented Nov 9, 2019

Yes, visual studio 16.3.6, and it does not work with dot net run eather.

@xiaomi7732
Copy link
Member

@valeriob I tried the same steps in VS 16.3.6 and it worked for me. There must be something I missed. Let me share my project and you can compare it with yours. At the same time, if you will to, share the project with me and I can take a look at it for you as well.

WebApplication.zip

@xiaomi7732 xiaomi7732 added the troubleshooting Tracking for troubleshooting label Nov 11, 2019
@valeriob
Copy link
Author

Hi xiaomi,
i saw that you added the guide for .netcore 3 exactly after i opened the issue. i diagnosed the problem, and it's due to the dependency required for Microsoft.ApplicationInsights.AspNetCore must be at least 2.8+, while the nuget package requires only Microsoft.ApplicationInsights.AspNetCore (>= 2.3.0).

I suggest to upgrade the nuget package to reflect the real version dependency.
Thanks
Valerio

@xiaomi7732
Copy link
Member

xiaomi7732 commented Nov 12, 2019

@valeriob Oh~ that is why. That makes sense. I'll look into how to get that fixed.

@xiaomi7732
Copy link
Member

Hey @valeriob, just FYI, the hosting startup for .NET Core 3.x is coming soon in version 2.1.0-*.

@valeriob
Copy link
Author

Thanks! i'll keep an eye on that !

@xiaomi7732 xiaomi7732 unpinned this issue Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working FAQ troubleshooting Tracking for troubleshooting
Projects
None yet
Development

No branches or pull requests

2 participants