Closed maurobernal closed 2 years ago
Hi, this is because in net6.0
template Program.cs
is intended as static initializer, than you cannot use GetType()
because isn't a static method.
Try instead typeof(Program)
.
With
builder.Services.AddBreadcrumbs(typeof(Program));
i have this error:
"cannot convert of System.Type to System.Reflection.Assembly"
i also tried this
builder.Services.AddBreadcrumbs(builder.GetType().Assembly);
That's how it worked
builder.Services.AddBreadcrumbs(typeof(Program).Assembly);
Yes, I realized that I have not explained very well. My intent was to substitute GetType()
with typeof(Program)
, not to use instead of GetType().Assembly
.
En Net 5.0, en StartUp.cs
En Net 6.0 in Program.cs
I have this error with GetType():
An object reference is required for the non-static field, method, or property 'object.GetType()'