Error publishing app with dotnet fullframework APM

Hello, I have a fullframework webapi and when adding the packages Elastic.APM Elastic.APM.AspNetFullFramework and Elastic.APM.EntityFramework6 and deploying to IIS on Windows 2012 I get the error below. On the development machine the error does not occur. Can you help me?

Server Error

Method not found: 'System.Collections.ObjectModel.Collection`1<System.Net.Http.DelegatingHandler> System.Web.Http.HttpConfiguration.get_MessageHandlers()'. body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } @media screen and (max-width: 639px) { pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; } } @media screen and (max-width: 479px) { pre { width: 280px; } }

Server Error in '/test' Application.

Method not found: 'System.Collections.ObjectModel.Collection`1<System.Net.Http.DelegatingHandler> System.Web.Http.HttpConfiguration.get_MessageHandlers()'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MissingMethodException: Method not found: 'System.Collections.ObjectModel.Collection`1<System.Net.Http.DelegatingHandler> System.Web.Http.HttpConfiguration.get_MessageHandlers()'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[MissingMethodException: Method not found: 'System.Collections.ObjectModel.Collection1<System.Net.Http.DelegatingHandler> System.Web.Http.HttpConfiguration.get_MessageHandlers()'.]
Api.Startup.ConfigureWebApi(HttpConfiguration config) in C:\test\Startup.cs:94
Api.Startup.Configuration(IAppBuilder app) in C:\test\Startup.cs:41

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments) +128
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture) +146
Owin.Loader.<>c__DisplayClass12.b__b(IAppBuilder builder) +93
Owin.Loader.<>c__DisplayClass1.b__0(IAppBuilder builder) +209
Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action1 startup) +843 Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action1 startup) +51
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +101
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +137
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +172
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo handlers) +618
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +402
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +343

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +712`

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0

Hi @viniciusvelasco,

My first guess is that on your Windows 2012 machine you have different dlls compared to your dev machine.

One suspect could be the System.Net.Http dll. Could you maybe try adding an assembly redirect for this dll as suggested here: https://stackoverflow.com/a/40439614/1783306

Additionally, is this only happening when you add the agent, or do you have the same problem without the agent, too?

1 Like

Hi @GregKalapos

Only occurred when adding the agent, it happened, because now adding to System.Net.Http in the project packages and it worked. Thank you for helping me. :pray: :+1::+1::+1:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.