Eple
Eple
CC#
Created by Eple on 8/14/2024 in #help
Issue with ASP.NET Core and WCF Service Integration
Hey everyone, I’m working on an ASP.NET Core application that consumes a WCF service. I’ve encountered an issue, and I’m hoping someone here might have some insights. When my app runs for the first time after some while, I get the following error message:
Exception: System.ServiceModel.FaultException1[MyProj.ExternalService.ServiceError]: There is already an open DataReader associated with this Command which must be closed first. (Fault Detail is equal to MyProj.ExternalService.ServiceError).`
It looks like the external service is returning the "There is already an open DataReader…" message. Has anyone experienced something similar, or does anyone know what might be causing this?
5 replies
CC#
Created by Eple on 7/25/2024 in #help
Question regarding tasks
Please consider the code below. Won't the usersTask run twice? And since I need its return value, isn't it unnecessary to run it within a Task.WhenAll() method?
var usersTask = service.GetAllUsers();
await Task.WhenAll(usersTask, someOtherTask);
_users = await usersTask;
var usersTask = service.GetAllUsers();
await Task.WhenAll(usersTask, someOtherTask);
_users = await usersTask;
53 replies
CC#
Created by Eple on 7/18/2024 in #help
Question regarding multiple calls to AddHttpClient()
I have a class library that calls this:
services.AddHttpClient();
services.AddHttpClient();
Then the main project calls this:
builder.Services.AddHttpClient();
builder.Services.AddHttpClient();
Can it cause any issues?
11 replies
CC#
Created by Eple on 7/12/2024 in #help
✅ Help needed: ensuring synchronization on startup for Minimal API app
I have a Minimal API application that I need to execute code on during startup. This application synchronizes changes between two systems. If the application has been offline, it must check for any missed changes as soon as it starts.
27 replies
CC#
Created by Eple on 6/3/2024 in #help
✅ Help needed: Buttons update enabled state after two clicks.
Hello, I need help to find out why it takes two clicks before the buttons change the enabled state. Please see the attached video and also my code below:
<StackLayout>
<Button Text="Start the service" Command="{Binding StartTheServiceCommand}" />
</StackLayout>

<StackLayout>
<Button Text="Stop the service" Command="{Binding StopTheServiceCommand}" />
</StackLayout>
<StackLayout>
<Button Text="Start the service" Command="{Binding StartTheServiceCommand}" />
</StackLayout>

<StackLayout>
<Button Text="Stop the service" Command="{Binding StopTheServiceCommand}" />
</StackLayout>
public MainPageViewModel(ILogger<MainPageViewModel> logger, WorkerService workerService)
{
_logger = logger;
_workerService = workerService;

StartTheServiceCommand = new Command(
execute: () =>
{
_logger.LogInformation("Starting the service at: {time}", DateTimeOffset.Now);
Task.Run(async () => await _workerService.StartAsync(new()));
RefreshCanExecutes();
},
canExecute: () => !_workerService.IsRunning);

StopTheServiceCommand = new Command(
execute: () =>
{
_logger.LogInformation("Stopping the service at: {time}", DateTimeOffset.Now);
Task.Run(async () => await _workerService.StopAsync(new()));
RefreshCanExecutes();
},
canExecute: () => _workerService.IsRunning);
}

public ICommand StartTheServiceCommand { get; }
public ICommand StopTheServiceCommand { get; }

private void RefreshCanExecutes()
{
(StartTheServiceCommand as Command)!.ChangeCanExecute();
(StopTheServiceCommand as Command)!.ChangeCanExecute();
}
public MainPageViewModel(ILogger<MainPageViewModel> logger, WorkerService workerService)
{
_logger = logger;
_workerService = workerService;

StartTheServiceCommand = new Command(
execute: () =>
{
_logger.LogInformation("Starting the service at: {time}", DateTimeOffset.Now);
Task.Run(async () => await _workerService.StartAsync(new()));
RefreshCanExecutes();
},
canExecute: () => !_workerService.IsRunning);

StopTheServiceCommand = new Command(
execute: () =>
{
_logger.LogInformation("Stopping the service at: {time}", DateTimeOffset.Now);
Task.Run(async () => await _workerService.StopAsync(new()));
RefreshCanExecutes();
},
canExecute: () => _workerService.IsRunning);
}

public ICommand StartTheServiceCommand { get; }
public ICommand StopTheServiceCommand { get; }

private void RefreshCanExecutes()
{
(StartTheServiceCommand as Command)!.ChangeCanExecute();
(StopTheServiceCommand as Command)!.ChangeCanExecute();
}
8 replies
CC#
Created by Eple on 5/31/2024 in #help
Why does it give the error?
No description
3 replies
CC#
Created by Eple on 4/12/2024 in #help
Help Needed: Choosing Between VSCode on Mac or Visual Studio via Remote Desktop for Windows Backgrou
I'm starting a new project and can't decide between two options: using VSCode on my Mac or using Visual Studio on a Windows computer through remote desktop (the connection is fast and stable). The project is a background service that will eventually run on Windows. Any suggestions on which setup would be better for this?
10 replies
CC#
Created by Eple on 3/15/2024 in #help
Background Service and Blazor
Hi all, I wish to create a Service and a Blazor interface. Can someone help me get started? That is a Service doing some work and a Blazor interface communicating with it. I need help to choose the right project types.
14 replies
CC#
Created by Eple on 3/2/2023 in #help
❔ JObject find value
I have the following JSON
{
"sale": {
"id": "x",
"transaction": {
"id": "y",
"state": "Completed"
}
}
}
{
"sale": {
"id": "x",
"transaction": {
"id": "y",
"state": "Completed"
}
}
}
I want to check if sale.transaction.state == "Completed" But since the keys sale, transaction and state are optional and not always in the response, I must check for their presence. Is there a better way than what I have below?
var responseObject = JObject.Parse(responseString);
if (responseObject["sale"] != null && responseObject["sale"]["transaction"] != null && responseObject["sale"]["transaction"]["state"] != null)
{
if (responseObject.Value<string>("sale.transaction.state") == "Completed")
{
Console.WriteLine("Yes");
}
}
var responseObject = JObject.Parse(responseString);
if (responseObject["sale"] != null && responseObject["sale"]["transaction"] != null && responseObject["sale"]["transaction"]["state"] != null)
{
if (responseObject.Value<string>("sale.transaction.state") == "Completed")
{
Console.WriteLine("Yes");
}
}
7 replies
CC#
Created by Eple on 12/19/2022 in #help
❔ Where to store .exe file?
My ASP.NET application executes wkhtmltopdf.exe (convert html to pdf) - where is the best place to store wkhtmltopdf.exe?
2 replies
CC#
Created by Eple on 12/16/2022 in #help
❔ Update-Database error
2 replies
CC#
Created by Eple on 12/16/2022 in #help
❔ PDF generation library?
I'm looking for a way to generate PDF file in an ASP.NET application.
11 replies
CC#
Created by Eple on 12/7/2022 in #help
❔ problem with ModelState
2 replies
CC#
Created by Eple on 11/25/2022 in #help
❔ DbUpdateConcurrencyException
7 replies
CC#
Created by Eple on 11/22/2022 in #help
❔ How to make property auto-increment?
4 replies
CC#
Created by Eple on 11/6/2022 in #help
Edit Users
1 replies
CC#
Created by Eple on 11/5/2022 in #help
Web Application with separate protected areas
11 replies