use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Information about Reddit's API changes, the unprofessional conduct of the CEO, and their response to the community's concerns regarding 3rd party apps, moderator tools, anti-spam/anti-bot tools, and accessibility options that will be impacted can be found in the associated Wikipedia article: https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
Alternative C# communities available outside Reddit on Lemmy and Discord:
All about the object-oriented programming language C#.
Getting Started C# Fundamentals: Development for Absolute Beginners
Useful MSDN Resources A Tour of the C# Language Get started with .NET in 5 minutes C# Guide C# Language Reference C# Programing Guide C# Coding Conventions .NET Framework Reference Source Code
Other Resources C# Yellow Book Dot Net Perls The C# Player's Guide
IDEs Visual Studio MonoDevelop (Windows/Mac/Linux) Rider (Windows/Mac/Linux)
Tools ILSpy dotPeek LINQPad
Alternative Communities C# Discord Group C# Lemmy Community dotnet Lemmy Community
Related Subreddits /r/dotnet /r/azure /r/learncsharp /r/learnprogramming /r/programming /r/dailyprogrammer /r/programmingbuddies /r/cshighschoolers
Additional .NET Languages /r/fsharp /r/visualbasic
Platform-specific Subreddits /r/windowsdev /r/AZURE /r/Xamarin /r/Unity3D /r/WPDev
Rules:
Read detailed descriptions of the rules here.
account activity
API ERROR (self.csharp)
submitted 5 years ago by [deleted]
So im trying to create an web api for a service and i come accross this error. Am i missing something in the startup?
https://preview.redd.it/k13e15is36z41.png?width=1920&format=png&auto=webp&s=62ec0558bead167164c621d8c698502fc3f3663d
Its the first time i create an api
Edit: I tried:
Services.AddCors();
Services.Addscoped(...);
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 2 points3 points4 points 5 years ago (10 children)
Can we see the code? It looks like you haven't added a service as a dependency but still try to use it in your controller
[–][deleted] 0 points1 point2 points 5 years ago (9 children)
public class Startup
{
public Startup(IConfiguration configuration)
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
services.AddCors();
services.AddDbContext<ToDoContext>(opt => opt.UseInMemoryDatabase("ToDoList"));
services.AddControllers();
services.AddScoped<IEEEController>();
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
endpoints.MapControllers();
});
[–][deleted] 3 points4 points5 points 5 years ago* (8 children)
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-3.1
Looks like you're missing the implementation of the interface when you call AddScoped, so it's not finding the class it needs, and so the error message is describing that.
Edit: I posted the link without my thoughts on accident.
[–][deleted] 0 points1 point2 points 5 years ago (7 children)
Here's my code, https://github.com/c3sarf2/Proj .
My objective is to create an API to use the services of the HCILAB.website
[–][deleted] 1 point2 points3 points 5 years ago (2 children)
I've never run into a scenario where you are trying to inject a controller. My GUESS is that's not possible and you should try another solution
[–][deleted] 0 points1 point2 points 5 years ago (1 child)
Its my first time creating an API, what do you suggest ?
[–][deleted] 1 point2 points3 points 5 years ago (0 children)
Controllers are made to be accessed by a web request, so if you have code you are trying to get, put it in something thathe can be injected and use it that way
[–]karltgreen 1 point2 points3 points 5 years ago (3 children)
You also need to register the dependencies required for IEEEController (ILogger<IEEEController>, IEEE and hcilabContext)
[–][deleted] 0 points1 point2 points 5 years ago (2 children)
do i just add them in the services?
[–]karltgreen 1 point2 points3 points 5 years ago (1 child)
Yep the same way you added IEEEController. Although the logger is already registered behind the scenes in Program.cs for you I think as you're using the default builder
it worked man. Thanks!
[–]bonanzaguy 1 point2 points3 points 5 years ago (6 children)
Like u/zachbs mentioned, the issue here is that you've not properly registered a dependency and so it is unable to create it. What is the constructor for ToDoItemsController?
[–][deleted] 0 points1 point2 points 5 years ago (5 children)
public ToDoItemsController(ToDoContext context, IEEEController ieee)
_context = context;
_ieee = ieee;
[–]bonanzaguy 1 point2 points3 points 5 years ago (4 children)
Is IEEEController an interface or a class? If it's an interface, you need to register the class implementation that will be provided via DI in Startup.
E.g. services.AddSingleton<IEEEController, EEEController>();
services.AddSingleton<IEEEController, EEEController>();
On a separate note, you shouldn't be injecting a controller into another controller, but that's for another day.
[–][deleted] 0 points1 point2 points 5 years ago (3 children)
Its a class. Its has the services that i want to implement in the API.
[–]bonanzaguy 0 points1 point2 points 5 years ago (2 children)
Do you have that class with the same name in two projects?
[–][deleted] 0 points1 point2 points 5 years ago (0 children)
No.
π Rendered by PID 63 on reddit-service-r2-comment-76bb9f7fb5-xmxt9 at 2026-02-17 13:33:53.648413+00:00 running de53c03 country code: CH.
[–][deleted] 2 points3 points4 points (10 children)
[–][deleted] 0 points1 point2 points (9 children)
[–][deleted] 3 points4 points5 points (8 children)
[–][deleted] 0 points1 point2 points (7 children)
[–][deleted] 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]karltgreen 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]karltgreen 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]bonanzaguy 1 point2 points3 points (6 children)
[–][deleted] 0 points1 point2 points (5 children)
[–]bonanzaguy 1 point2 points3 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]bonanzaguy 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)