So you created a class with public constructor taking your injected object as parameter - if you didn't also provide a default constructor with no arguments (which most times you shouldn't if you are using DI) you can't instanciate your class with out an instance of the injected object type - thats the sense of DI. Are you shure you understand the concept?. If you really need to construct an instance without the injected object you could provide a default constructor and and do DI in this case with a property, but write your class in a way that it can handle null-references on the injected object/Interface.
Example: if you want to inject a logger and provide a way to not inject it (by calling a default constructor) you have to check for null reference on the logger-object every time you want to use it inside the class...
Although SA is correct in general (would help if you show some code) it's obviouse what you do wrong (nothing - you just didn't use DI as you should)
So here is an example what I mean:
namespace DependencyInjection
{
class Program
{
static void Main(string[] args)
{
var a = new CompilerWillWriteDefaultConstructor();
var interfaceimplementation = new ImplementsInterface();
var b = new ClassWithOwnConstructorCompilerWontWriteDefaultConstructor(interfaceimplementation);
}
}
interface InterfaceToInject { };
class ImplementsInterface : InterfaceToInject { }
class ClassWithOwnConstructorCompilerWontWriteDefaultConstructor
{
public ClassWithOwnConstructorCompilerWontWriteDefaultConstructor(InterfaceToInject obj)
{
}
}
class CompilerWillWriteDefaultConstructor{}
}