MissingMethodException Global.asax.cs












2















Because of this blog-post:



https://www.radenkozec.com/8-ways-improve-asp-net-web-api-performance/



I´ve tried to replace JSON.net with ServiceStack.Text as JSON-Serializer in my WebApi.
With this tutorial:



https://www.strathweb.com/2013/01/replace-json-net-with-servicestack-text-in-asp-net-web-api/



Localhost and in debug-mode all went well, until I deployed it to our server, it says:




MissingMethodException



[MissingMethodException: Method not found: "System.Collections.ObjectModel.Collection<System.Net.Http.DelegatingHandler> System.Web.Http.HttpConfiguration.get_MessageHandlers()".]




It happens at Application_Start().



protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);

}


Thats my replacement:



public class ServiceStackTextFormatter : JsonMediaTypeFormatter
{
public ServiceStackTextFormatter()
{
JsConfig.DateHandler = DateHandler.ISO8601;
SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));

SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true));
SupportedEncodings.Add(new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true));
}

public override bool CanReadType(Type type)
{
if (type == null) throw new ArgumentNullException("type");
return true;
}

public override bool CanWriteType(Type type)
{
if (type == null) throw new ArgumentNullException("type");
return true;
}

public override Task<object> ReadFromStreamAsync(Type type, Stream readStream, System.Net.Http.HttpContent content, IFormatterLogger formatterLogger)
{
var task = Task<object>.Factory.StartNew(() => JsonSerializer.DeserializeFromStream(type, readStream));
return task;
}

public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, System.Net.Http.HttpContent content, TransportContext transportContext)
{
var task = Task.Factory.StartNew(() => JsonSerializer.SerializeToStream(value, type, writeStream));
return task;
}
}


And my Register method:



public static void Register(HttpConfiguration config)
{
// see this: https://www.strathweb.com/2013/01/replace-json-net-with-servicestack-text-in-asp-net-web-api/
// and this: https://www.radenkozec.com/8-ways-improve-asp-net-web-api-performance/
// ServiceStackText is much faster than JSON.NET
config.Formatters.RemoveAt(0);
config.Formatters.Insert(0, new ServiceStackTextFormatter());

// add Handler to send data chunked
config.MessageHandlers.Add(new Handler());

// Web API configuration and services
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

// Web API routes
config.MapHttpAttributeRoutes();

config.EnableCors(); // needed to disable this, otherwise we do not get a access-origin-header in the client

config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain"));
config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));

(config.Formatters[0] as ServiceStackTextFormatter).SerializerSettings.TypeNameHandling = TypeNameHandling.Auto;
}









share|improve this question





























    2















    Because of this blog-post:



    https://www.radenkozec.com/8-ways-improve-asp-net-web-api-performance/



    I´ve tried to replace JSON.net with ServiceStack.Text as JSON-Serializer in my WebApi.
    With this tutorial:



    https://www.strathweb.com/2013/01/replace-json-net-with-servicestack-text-in-asp-net-web-api/



    Localhost and in debug-mode all went well, until I deployed it to our server, it says:




    MissingMethodException



    [MissingMethodException: Method not found: "System.Collections.ObjectModel.Collection<System.Net.Http.DelegatingHandler> System.Web.Http.HttpConfiguration.get_MessageHandlers()".]




    It happens at Application_Start().



    protected void Application_Start()
    {
    GlobalConfiguration.Configure(WebApiConfig.Register);

    }


    Thats my replacement:



    public class ServiceStackTextFormatter : JsonMediaTypeFormatter
    {
    public ServiceStackTextFormatter()
    {
    JsConfig.DateHandler = DateHandler.ISO8601;
    SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));

    SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true));
    SupportedEncodings.Add(new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true));
    }

    public override bool CanReadType(Type type)
    {
    if (type == null) throw new ArgumentNullException("type");
    return true;
    }

    public override bool CanWriteType(Type type)
    {
    if (type == null) throw new ArgumentNullException("type");
    return true;
    }

    public override Task<object> ReadFromStreamAsync(Type type, Stream readStream, System.Net.Http.HttpContent content, IFormatterLogger formatterLogger)
    {
    var task = Task<object>.Factory.StartNew(() => JsonSerializer.DeserializeFromStream(type, readStream));
    return task;
    }

    public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, System.Net.Http.HttpContent content, TransportContext transportContext)
    {
    var task = Task.Factory.StartNew(() => JsonSerializer.SerializeToStream(value, type, writeStream));
    return task;
    }
    }


    And my Register method:



    public static void Register(HttpConfiguration config)
    {
    // see this: https://www.strathweb.com/2013/01/replace-json-net-with-servicestack-text-in-asp-net-web-api/
    // and this: https://www.radenkozec.com/8-ways-improve-asp-net-web-api-performance/
    // ServiceStackText is much faster than JSON.NET
    config.Formatters.RemoveAt(0);
    config.Formatters.Insert(0, new ServiceStackTextFormatter());

    // add Handler to send data chunked
    config.MessageHandlers.Add(new Handler());

    // Web API configuration and services
    config.SuppressDefaultHostAuthentication();
    config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

    // Web API routes
    config.MapHttpAttributeRoutes();

    config.EnableCors(); // needed to disable this, otherwise we do not get a access-origin-header in the client

    config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
    config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain"));
    config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));

    (config.Formatters[0] as ServiceStackTextFormatter).SerializerSettings.TypeNameHandling = TypeNameHandling.Auto;
    }









    share|improve this question



























      2












      2








      2


      0






      Because of this blog-post:



      https://www.radenkozec.com/8-ways-improve-asp-net-web-api-performance/



      I´ve tried to replace JSON.net with ServiceStack.Text as JSON-Serializer in my WebApi.
      With this tutorial:



      https://www.strathweb.com/2013/01/replace-json-net-with-servicestack-text-in-asp-net-web-api/



      Localhost and in debug-mode all went well, until I deployed it to our server, it says:




      MissingMethodException



      [MissingMethodException: Method not found: "System.Collections.ObjectModel.Collection<System.Net.Http.DelegatingHandler> System.Web.Http.HttpConfiguration.get_MessageHandlers()".]




      It happens at Application_Start().



      protected void Application_Start()
      {
      GlobalConfiguration.Configure(WebApiConfig.Register);

      }


      Thats my replacement:



      public class ServiceStackTextFormatter : JsonMediaTypeFormatter
      {
      public ServiceStackTextFormatter()
      {
      JsConfig.DateHandler = DateHandler.ISO8601;
      SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));

      SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true));
      SupportedEncodings.Add(new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true));
      }

      public override bool CanReadType(Type type)
      {
      if (type == null) throw new ArgumentNullException("type");
      return true;
      }

      public override bool CanWriteType(Type type)
      {
      if (type == null) throw new ArgumentNullException("type");
      return true;
      }

      public override Task<object> ReadFromStreamAsync(Type type, Stream readStream, System.Net.Http.HttpContent content, IFormatterLogger formatterLogger)
      {
      var task = Task<object>.Factory.StartNew(() => JsonSerializer.DeserializeFromStream(type, readStream));
      return task;
      }

      public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, System.Net.Http.HttpContent content, TransportContext transportContext)
      {
      var task = Task.Factory.StartNew(() => JsonSerializer.SerializeToStream(value, type, writeStream));
      return task;
      }
      }


      And my Register method:



      public static void Register(HttpConfiguration config)
      {
      // see this: https://www.strathweb.com/2013/01/replace-json-net-with-servicestack-text-in-asp-net-web-api/
      // and this: https://www.radenkozec.com/8-ways-improve-asp-net-web-api-performance/
      // ServiceStackText is much faster than JSON.NET
      config.Formatters.RemoveAt(0);
      config.Formatters.Insert(0, new ServiceStackTextFormatter());

      // add Handler to send data chunked
      config.MessageHandlers.Add(new Handler());

      // Web API configuration and services
      config.SuppressDefaultHostAuthentication();
      config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

      // Web API routes
      config.MapHttpAttributeRoutes();

      config.EnableCors(); // needed to disable this, otherwise we do not get a access-origin-header in the client

      config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
      config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain"));
      config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));

      (config.Formatters[0] as ServiceStackTextFormatter).SerializerSettings.TypeNameHandling = TypeNameHandling.Auto;
      }









      share|improve this question
















      Because of this blog-post:



      https://www.radenkozec.com/8-ways-improve-asp-net-web-api-performance/



      I´ve tried to replace JSON.net with ServiceStack.Text as JSON-Serializer in my WebApi.
      With this tutorial:



      https://www.strathweb.com/2013/01/replace-json-net-with-servicestack-text-in-asp-net-web-api/



      Localhost and in debug-mode all went well, until I deployed it to our server, it says:




      MissingMethodException



      [MissingMethodException: Method not found: "System.Collections.ObjectModel.Collection<System.Net.Http.DelegatingHandler> System.Web.Http.HttpConfiguration.get_MessageHandlers()".]




      It happens at Application_Start().



      protected void Application_Start()
      {
      GlobalConfiguration.Configure(WebApiConfig.Register);

      }


      Thats my replacement:



      public class ServiceStackTextFormatter : JsonMediaTypeFormatter
      {
      public ServiceStackTextFormatter()
      {
      JsConfig.DateHandler = DateHandler.ISO8601;
      SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));

      SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true));
      SupportedEncodings.Add(new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true));
      }

      public override bool CanReadType(Type type)
      {
      if (type == null) throw new ArgumentNullException("type");
      return true;
      }

      public override bool CanWriteType(Type type)
      {
      if (type == null) throw new ArgumentNullException("type");
      return true;
      }

      public override Task<object> ReadFromStreamAsync(Type type, Stream readStream, System.Net.Http.HttpContent content, IFormatterLogger formatterLogger)
      {
      var task = Task<object>.Factory.StartNew(() => JsonSerializer.DeserializeFromStream(type, readStream));
      return task;
      }

      public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, System.Net.Http.HttpContent content, TransportContext transportContext)
      {
      var task = Task.Factory.StartNew(() => JsonSerializer.SerializeToStream(value, type, writeStream));
      return task;
      }
      }


      And my Register method:



      public static void Register(HttpConfiguration config)
      {
      // see this: https://www.strathweb.com/2013/01/replace-json-net-with-servicestack-text-in-asp-net-web-api/
      // and this: https://www.radenkozec.com/8-ways-improve-asp-net-web-api-performance/
      // ServiceStackText is much faster than JSON.NET
      config.Formatters.RemoveAt(0);
      config.Formatters.Insert(0, new ServiceStackTextFormatter());

      // add Handler to send data chunked
      config.MessageHandlers.Add(new Handler());

      // Web API configuration and services
      config.SuppressDefaultHostAuthentication();
      config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

      // Web API routes
      config.MapHttpAttributeRoutes();

      config.EnableCors(); // needed to disable this, otherwise we do not get a access-origin-header in the client

      config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
      config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain"));
      config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));

      (config.Formatters[0] as ServiceStackTextFormatter).SerializerSettings.TypeNameHandling = TypeNameHandling.Auto;
      }






      c# asp.net-web-api2 servicestack servicestack-text missingmethodexception






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 27 '18 at 12:54







      Max Mustermann

















      asked Nov 26 '18 at 14:37









      Max MustermannMax Mustermann

      829




      829
























          1 Answer
          1






          active

          oldest

          votes


















          1














          So I made some progress. The problem was not caused by the ServiceStack-JSON-Serializer, it´s caused by my Handler which is:



          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Net.Http;
          using System.Threading;
          using System.Threading.Tasks;
          using System.Web;

          namespace akiliBase.Rest.RestAPI.Models
          {
          public class Handler : DelegatingHandler
          {
          protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
          CancellationToken cancellationToken)
          {
          var response = base.SendAsync(request, cancellationToken);

          response.Result.Headers.TransferEncodingChunked = true; // Here!

          return response;
          }
          }
          }


          So I deleted this line and will aks another question about this.
          Now I get the following error:




          [MissingMethodException: Method not found:
          "System.Collections.ObjectModel.Collection`1
          System.Net.Http.Formatting.MediaTypeFormatter.get_SupportedMediaTypes()".]




          which is caused by the following lines:



          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain"));
          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));


          So it seams in System.Net.Http.Formatting.MediaTypeFormatter the getter for SupportedMediaTypes is missing. I also think the whole problem is caused in Web.config where some wrong assambly´s are referenced or something. So here is my web.config-runtime-tag:



          <runtime>
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
          <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-15.1.0.0" newVersion="15.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="ZedGraph" publicKeyToken="02a83cbd123fcd60" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.1.7.430" newVersion="5.1.7.430" />
          </dependentAssembly>
          </assemblyBinding>







          share|improve this answer
























          • I´m not able to solve this problem. Sorry

            – Max Mustermann
            Nov 27 '18 at 13:58











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53483423%2fmissingmethodexception-global-asax-cs%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          So I made some progress. The problem was not caused by the ServiceStack-JSON-Serializer, it´s caused by my Handler which is:



          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Net.Http;
          using System.Threading;
          using System.Threading.Tasks;
          using System.Web;

          namespace akiliBase.Rest.RestAPI.Models
          {
          public class Handler : DelegatingHandler
          {
          protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
          CancellationToken cancellationToken)
          {
          var response = base.SendAsync(request, cancellationToken);

          response.Result.Headers.TransferEncodingChunked = true; // Here!

          return response;
          }
          }
          }


          So I deleted this line and will aks another question about this.
          Now I get the following error:




          [MissingMethodException: Method not found:
          "System.Collections.ObjectModel.Collection`1
          System.Net.Http.Formatting.MediaTypeFormatter.get_SupportedMediaTypes()".]




          which is caused by the following lines:



          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain"));
          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));


          So it seams in System.Net.Http.Formatting.MediaTypeFormatter the getter for SupportedMediaTypes is missing. I also think the whole problem is caused in Web.config where some wrong assambly´s are referenced or something. So here is my web.config-runtime-tag:



          <runtime>
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
          <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-15.1.0.0" newVersion="15.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="ZedGraph" publicKeyToken="02a83cbd123fcd60" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.1.7.430" newVersion="5.1.7.430" />
          </dependentAssembly>
          </assemblyBinding>







          share|improve this answer
























          • I´m not able to solve this problem. Sorry

            – Max Mustermann
            Nov 27 '18 at 13:58
















          1














          So I made some progress. The problem was not caused by the ServiceStack-JSON-Serializer, it´s caused by my Handler which is:



          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Net.Http;
          using System.Threading;
          using System.Threading.Tasks;
          using System.Web;

          namespace akiliBase.Rest.RestAPI.Models
          {
          public class Handler : DelegatingHandler
          {
          protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
          CancellationToken cancellationToken)
          {
          var response = base.SendAsync(request, cancellationToken);

          response.Result.Headers.TransferEncodingChunked = true; // Here!

          return response;
          }
          }
          }


          So I deleted this line and will aks another question about this.
          Now I get the following error:




          [MissingMethodException: Method not found:
          "System.Collections.ObjectModel.Collection`1
          System.Net.Http.Formatting.MediaTypeFormatter.get_SupportedMediaTypes()".]




          which is caused by the following lines:



          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain"));
          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));


          So it seams in System.Net.Http.Formatting.MediaTypeFormatter the getter for SupportedMediaTypes is missing. I also think the whole problem is caused in Web.config where some wrong assambly´s are referenced or something. So here is my web.config-runtime-tag:



          <runtime>
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
          <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-15.1.0.0" newVersion="15.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="ZedGraph" publicKeyToken="02a83cbd123fcd60" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.1.7.430" newVersion="5.1.7.430" />
          </dependentAssembly>
          </assemblyBinding>







          share|improve this answer
























          • I´m not able to solve this problem. Sorry

            – Max Mustermann
            Nov 27 '18 at 13:58














          1












          1








          1







          So I made some progress. The problem was not caused by the ServiceStack-JSON-Serializer, it´s caused by my Handler which is:



          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Net.Http;
          using System.Threading;
          using System.Threading.Tasks;
          using System.Web;

          namespace akiliBase.Rest.RestAPI.Models
          {
          public class Handler : DelegatingHandler
          {
          protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
          CancellationToken cancellationToken)
          {
          var response = base.SendAsync(request, cancellationToken);

          response.Result.Headers.TransferEncodingChunked = true; // Here!

          return response;
          }
          }
          }


          So I deleted this line and will aks another question about this.
          Now I get the following error:




          [MissingMethodException: Method not found:
          "System.Collections.ObjectModel.Collection`1
          System.Net.Http.Formatting.MediaTypeFormatter.get_SupportedMediaTypes()".]




          which is caused by the following lines:



          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain"));
          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));


          So it seams in System.Net.Http.Formatting.MediaTypeFormatter the getter for SupportedMediaTypes is missing. I also think the whole problem is caused in Web.config where some wrong assambly´s are referenced or something. So here is my web.config-runtime-tag:



          <runtime>
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
          <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-15.1.0.0" newVersion="15.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="ZedGraph" publicKeyToken="02a83cbd123fcd60" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.1.7.430" newVersion="5.1.7.430" />
          </dependentAssembly>
          </assemblyBinding>







          share|improve this answer













          So I made some progress. The problem was not caused by the ServiceStack-JSON-Serializer, it´s caused by my Handler which is:



          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Net.Http;
          using System.Threading;
          using System.Threading.Tasks;
          using System.Web;

          namespace akiliBase.Rest.RestAPI.Models
          {
          public class Handler : DelegatingHandler
          {
          protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
          CancellationToken cancellationToken)
          {
          var response = base.SendAsync(request, cancellationToken);

          response.Result.Headers.TransferEncodingChunked = true; // Here!

          return response;
          }
          }
          }


          So I deleted this line and will aks another question about this.
          Now I get the following error:




          [MissingMethodException: Method not found:
          "System.Collections.ObjectModel.Collection`1
          System.Net.Http.Formatting.MediaTypeFormatter.get_SupportedMediaTypes()".]




          which is caused by the following lines:



          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain"));
          config.Formatters[0].SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));


          So it seams in System.Net.Http.Formatting.MediaTypeFormatter the getter for SupportedMediaTypes is missing. I also think the whole problem is caused in Web.config where some wrong assambly´s are referenced or something. So here is my web.config-runtime-tag:



          <runtime>
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
          <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-15.1.0.0" newVersion="15.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
          <assemblyIdentity name="ZedGraph" publicKeyToken="02a83cbd123fcd60" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.1.7.430" newVersion="5.1.7.430" />
          </dependentAssembly>
          </assemblyBinding>








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 27 '18 at 12:52









          Max MustermannMax Mustermann

          829




          829













          • I´m not able to solve this problem. Sorry

            – Max Mustermann
            Nov 27 '18 at 13:58



















          • I´m not able to solve this problem. Sorry

            – Max Mustermann
            Nov 27 '18 at 13:58

















          I´m not able to solve this problem. Sorry

          – Max Mustermann
          Nov 27 '18 at 13:58





          I´m not able to solve this problem. Sorry

          – Max Mustermann
          Nov 27 '18 at 13:58




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53483423%2fmissingmethodexception-global-asax-cs%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks