Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Interface without Default Constructor Error

$
0
0

I'm passing an interface to a controller action

public IActionResult PrepareTransfer(IInstrument instrument) {

In my DI container I have

services.AddTransient<IInstrumentInstrument>();

Right now both IInstrument and Instrument are just empty, so the default constructor on Instrument should be available

public class Instrument : IInstrument{}
public interface IInstrument{}

When I run the app I get the following error:

ArgumentException: Type 'G3.Instruments.IInstrument' does not have a default constructor Parameter name: type


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>