1

Ironically, the problem DI is trying to solve, is exactly the problem that has been created in the project. Are there any resources for using the framework where i'm capable of picking and choosing which features I want to use/enable and those i want to omit?

It's very hard to manage dependencies and develop a modular and well-structured application without using dependency injection techniques.

Which i strongly disagree with; and believe to be the opposite, as there are plenty of cases where it's common without DI than with it.

Currently, i'm stuck on trying to use the project by calling all of the classes manually, as the DI is broken and constantly prone to errors, with vague or unhelpful exceptions being thrown and preventing app from executing. I'm unable to properly and thoroughly debug it, and that isnt the kind of assistance i'm seeking.

Strictly the question being posed is, i want to use the framework without using dependency injection, are there solutions; if yes, can you provide them in the form of step-by-step, or copy-paste? Can i use the framework without it, or am i tasked with writing my own because it's unable to keep it's functions modular?

My solution so far, is i'm attempting to restructure, the entire framework to remove the DI logic from the foundation of the framework (it's coupled inside [root] functions instead of beside them?); but i'm not sure if there are ways around it, and if possible to just strictly not use it if i dont want it enabled.

I've already created a repository class that's based on interface, then i've made some changes to a few manager classes that use the repository... but then there's stores, other managers (repetitive layers stacked inside each other), cache (not sure why it's layered into foundation), UoW (dont need this, cant null it out), publishers (dont know how to pull this one out), and a whole bunch of other, logic inside logic, that dont need to be structured the way the project is layered. The whole thing feels more like a Jenga tower, than a flexible framework where isolation of responsibilities is at core of development practice.


EDIT

Related StackOverFlow Problems:
AspNet Core3 Identity configuration

What i've attempted:
Multiple Identities in ASP.NET Core 2.0
ASP.NET Identity without Entity Framework
How to resolve generic interface to generic implementation when using dependency injection?
How to implement Unit Of Work pattern with Dapper? (used this to make Abp.UoW interface nullable, but there's still other areas of forced UoW logic in-between functions in core layers of framework)

Basically, any search results containing "without dbcontext", "without entityframework", "without dependency injection", "using dapper", that all contained "asp identity" were search queries i was using.

Before modification and after modifications (attempts at using my own app services and domain model) all yielded

An error occurred while starting the application. AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Identity...

which is basically dependency injection breaking, and not being clear as to what the issue is, besides... "you cant use this class that inherits interface/abstract class that's referenced throughout framework and by DI." So i prefer not to use DI, and work around it, since solutions arent reliable to resolving my issues.

Same errors with default asp identity or custom abp identity

Different attempts at using identity, whether custom or by microsoft tutorials, all bring same results

currently rewriting startup to use manual instance singleton variables... tons of errors, and weird framework structure that still needs rewrite and edits

Steven
  • 166,672
  • 24
  • 332
  • 435
user3681384
  • 105
  • 9
  • How did you write your code *before* you 'had' to apply DI and what prevents you from using this coding style again? – Steven Dec 17 '20 at 08:25
  • Even if you remove DI from ABP, AspNet Core also completely depends on the DI. How will you handle it? – hikalkan Dec 17 '20 at 09:38
  • @Steven before MVC, i was using WebPages/Razor, which is now obsolete in NetCore, so i'm using MVVM/Razor, and i'm basically instantiating everything i want/need on startup into a singleton variable. – user3681384 Dec 17 '20 at 09:43
  • @hikalkan Idk about aspnet core, i'm just trying to get Identity services, nothing else matters to me. I just want to log in, log out, and match user to database (without entity framework)... whatever other stuff crammed into aspnet core, shouldnt be an issue i need to address as webpages was fine without all of that bloat. – user3681384 Dec 17 '20 at 09:43
  • @user3681384, so you want to instantiate everything on startup. But what is preventing you from doing this? Can you update your question and show what you tried and where you're stuck? – Steven Dec 17 '20 at 09:46
  • @Steven images have caption, will need to hover for context... but i have lots of problems with DI, and lets just say... it's really made me an advocate for not wanting to have anything to deal with it. – user3681384 Dec 17 '20 at 10:32

1 Answers1

3

I hope I don't sound to pedantic, but your "without DI example" is still an example of DI. You apply constructor injection, which is a form of DI. What I understand is that you want to apply Pure DI instead of using the built-in DI Container. There are advantages of using Pure DI of using a DI Container, which is, for instance, described in:

Now for the bad news...

When working with ASP.NET Core (and most of the framework that depends on the .NET Core DI Container), you can never completely replace that DI Container with a Pure DI option. That shouldn't be a problem, however. Just think of ASP.NET Core's Container as its configuration system. Consider the simplistic configuration system of ASP.NET (classic) MVC; its configuration system consisted just of a large dictionary. Although you were able to replace services in the dictionary, you couldn't remove the dictionary all together. It was just too embedded with the system. The same holds with ASP.NET Core's configuration system. The whole framework completely depends on its existence. And chances are slim that Boilerplate allows you to work without it.

But there's some good news...

Even though you can't remove the built-in configuration system, you can choose to apply Pure DI to your own application components and if you wish, you could even go back to the old school tightly coupled code base if you really want (which I can see from your examples you don't, fortunately).

How to do this with ASP.NET Boilerplate exactly I can't tell, unfortunately. But the freely available code samples of my book do demonstrate this concept using ASP.NET Core MVC here and especially here.

Steven
  • 166,672
  • 24
  • 332
  • 435
  • 1
    thank you for detailed response, will need to take some time to consume information provided, and implement solution into application project. I'm vote up on response, as it's strong with examples and resources; but will select as answer after i find success in reply (with the information being focused on how to get around obstacle i'm facing). I'll comment again if i have trouble digesting anything, if you dont mind. – user3681384 Dec 17 '20 at 14:21