Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

676
Vistas
Can not instantiate proxy of class: System.Net.HttpWebRequest. Could not find a parameterless constructor

I am upgrading my C# function app from .net 3.1 to 6.0`.

When I run my test cases, I found that, 1 of my test case failed with the below error.

Castle.DynamicProxy.InvalidProxyConstructorArgumentsException : Can not instantiate proxy of class: System.Net.HttpWebRequest. Could not find a parameterless constructor.

Basically, I am trying to mock HttpWebRequest and below is my piece of code for that.

var httpWebRequest = new Mock<HttpWebRequest>();

It is working fine in .Net 3.1. I am using Moq version 4.16.1 in both the projects.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Both HttpWebRequest constructors are obsolete and should not be used. You have to use the static function "Create" to create a new instance of the HttpWebRequest class:

HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://www.contoso.com/");

To solve your issue, use the HttpClient class instead. This class has a parameterless constructor.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda