Click here to Skip to main content
15,889,483 members
Home / Discussions / C#
   

C#

 
GeneralRe: Can a button in a simple html-document somehow call a (clientside) C# method? Pin
jsc426-Sep-20 11:31
professionaljsc426-Sep-20 11:31 
AnswerRe: Can a button in a simple html-document somehow call a (clientside) C# method? Pin
Luc Pattyn5-Sep-20 9:29
sitebuilderLuc Pattyn5-Sep-20 9:29 
QuestionSimple C# question - Begginer's lesson, please aid. Pin
Member 149309634-Sep-20 13:32
Member 149309634-Sep-20 13:32 
AnswerRe: Simple C# question - Begginer's lesson, please aid. Pin
Mycroft Holmes4-Sep-20 15:19
professionalMycroft Holmes4-Sep-20 15:19 
GeneralRe: Simple C# question - Begginer's lesson, please aid. Pin
Member 149309634-Sep-20 15:21
Member 149309634-Sep-20 15:21 
GeneralRe: Simple C# question - Begginer's lesson, please aid. Pin
Mycroft Holmes4-Sep-20 15:57
professionalMycroft Holmes4-Sep-20 15:57 
GeneralRe: Simple C# question - Begginer's lesson, please aid. Pin
Member 149309634-Sep-20 16:56
Member 149309634-Sep-20 16:56 
AnswerRe: Simple C# question - Begginer's lesson, please aid. Pin
OriginalGriff4-Sep-20 20:07
mveOriginalGriff4-Sep-20 20:07 
AnswerRe: Simple C# question - Begginer's lesson, please aid. Pin
Eddy Vluggen5-Sep-20 5:27
professionalEddy Vluggen5-Sep-20 5:27 
QuestionRunning Function from Task.Run with Cancellation Token gives infinite loop Pin
Exoskeletor4-Sep-20 12:41
Exoskeletor4-Sep-20 12:41 
AnswerRe: Running Function from Task.Run with Cancellation Token gives infinite loop Pin
Gerry Schmitz5-Sep-20 4:31
mveGerry Schmitz5-Sep-20 4:31 
GeneralRe: Running Function from Task.Run with Cancellation Token gives infinite loop Pin
Exoskeletor5-Sep-20 8:25
Exoskeletor5-Sep-20 8:25 
GeneralRe: Running Function from Task.Run with Cancellation Token gives infinite loop Pin
Gerry Schmitz5-Sep-20 9:05
mveGerry Schmitz5-Sep-20 9:05 
GeneralRe: Running Function from Task.Run with Cancellation Token gives infinite loop Pin
Exoskeletor5-Sep-20 10:17
Exoskeletor5-Sep-20 10:17 
GeneralRe: Running Function from Task.Run with Cancellation Token gives infinite loop Pin
Gerry Schmitz5-Sep-20 10:38
mveGerry Schmitz5-Sep-20 10:38 
GeneralRe: Running Function from Task.Run with Cancellation Token gives infinite loop Pin
Exoskeletor5-Sep-20 10:58
Exoskeletor5-Sep-20 10:58 
Question.Net Core Windows App, using database repositories Pin
jkirkerx4-Sep-20 11:53
professionaljkirkerx4-Sep-20 11:53 
AnswerRe: .Net Core Windows App, using database repositories Pin
Mycroft Holmes4-Sep-20 12:07
professionalMycroft Holmes4-Sep-20 12:07 
GeneralRe: .Net Core Windows App, using database repositories Pin
jkirkerx4-Sep-20 13:45
professionaljkirkerx4-Sep-20 13:45 
GeneralRe: .Net Core Windows App, using database repositories Pin
Mycroft Holmes4-Sep-20 15:14
professionalMycroft Holmes4-Sep-20 15:14 
GeneralRe: .Net Core Windows App, using database repositories Pin
Gerry Schmitz5-Sep-20 4:40
mveGerry Schmitz5-Sep-20 4:40 
GeneralRe: .Net Core Windows App, using database repositories Pin
jkirkerx5-Sep-20 7:32
professionaljkirkerx5-Sep-20 7:32 
GeneralRe: .Net Core Windows App, using database repositories Pin
Gerry Schmitz5-Sep-20 8:46
mveGerry Schmitz5-Sep-20 8:46 
AnswerRe: .Net Core Windows App, using database repositories Pin
Richard Deeming6-Sep-20 22:30
mveRichard Deeming6-Sep-20 22:30 
Your question seems to be whether you should continue to use DI in a Windows application, or whether you should fall back to tightly-coupled classes.

Stick with DI. It will make your code easier to test. You just need to add the boilerplate code for registering the services yourself if the project template doesn't already include it.

Add a reference to Microsoft.Extensions.DependencyInjection, and modify the Main method to build and populate the service provider.
C#
using Microsoft.Extensions.DependencyInjection;

static class Program
{
    public static IServiceProvider ServiceProvider { get; private set; }
    
    private static void ConfigureServices(IServiceCollection services)
    {
        ...
    }
    
    static void Main()
    {
        var services = new ServiceCollection();
        ConfigureServices(services);
        ServiceProvider = services.BuildServiceProvider();
        ...
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: .Net Core Windows App, using database repositories Pin
jkirkerx7-Sep-20 6:58
professionaljkirkerx7-Sep-20 6:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.