Brady Kelly
Explore posts from serversASP.NET Dependency Injection Fails to instantiate service
I'm trying to inject a service over which I have no control (hence no use of an interface) and determine why the DI container cannot instantiate the service. This code applies:
UsersRepository
doesn't get injected into LoginEndpoint
when I rely on CTSCore.Security.Users
being injected, but when I create in manually, the repo does get injected into the endpoint.
I've tried using an Oakton
environment check like this:
but this check fails when invoked.
How can I determine why the container is not registering a CTSCore.Security.Users
instance when I can easily do it myself?1 replies
✅ Read `launchsettings.json` environment variable from a terminal script in Rider
It looks like the only way to get Rider to reload real environment variable values is to restart the IDE. This is a pain when I'm debugging or experimenting with values that change often, so I figure a way around this is to update the 'fake' environment variable in
launchsettings.json
, then run a script in the IDE terminal to read that value and set the real environment variable in the OS (Windows for now). That way I know my app is getting an up to date value from the OS variable.
I'm just stuck on how to read the launchSetting.json
variable from a terminal script (PowerShell).7 replies
Configure Serilog to only write warnings to Seq sink
I have the following Serilog configuration:
In this case I've had to include the minimum level override for
Microsoft.EntityFrameworkCore
because it was filling up the Windows Event Log sink with warnings I'd rather only see in Seq. Moving on I would like to 'reverse' this to only write EF Core warning level events (or other detailed events) to the Seq sink. How can I go about this?1 replies
Android Emulator fails when launched from Rider
When I try and debug a MAUI project using the Android Emulator in Rider I get an error message saying "The emulator process for AVD <avd_name> has terminated". If I debug the same project in VS2022, the emulator launches fine. If I launch the emulator using VS2022, I can still debug my project from Rider though.
1 replies
✅ Strange version error with EF.Core
I have a third party exe that references assembly
CTSCore.dll
. It seems to run fine, and when I examine the DLL I see it has a reference to Microsoft.EntityFrameworkCore.8.0.2.0
, yet in the bin
folder of the app I see Microsoft.EntityFrameworkCore.8.0.424.16902
. Yet when I reference CTSCore
in my web api and call a method on one of its classes, I get a FileNotFoundException
looking for Microsoft.EntityFrameworkCore.8.0.2.0
.
1. How is the exe running while my web api is failing? Looks to me like it should also be causing an exception when EFCore.8.0.2.0 isn't found. I suspect it might be a difference in how the two executables use assembly versions. I don't see why a WinForms app should be different from a Console app though, and the web api is a console app.
2. How can I insulate myself from this?21 replies
✅ Minimal API: Pass app config to IEndpointRouteBuilder
I am using route builders to map routes for a minimal API, like this:
I'd like to access the app's IConfiguration from within these classes and am hoping there is a better way than reading config values in
Program
and passing them to each register endpoints method. I'd really like to receive config values or IConfiguration as ctor parameters.3 replies
Minimal web API gives HTTP 500.19 error on IIS
I am trying to get a .NET 8 minimal web api up and running under IIS on Windows 11. Based on a blog post, I created a new app pool with
No managed code
as the CLR version[1] and assigned it to the Default Web Site. Everything else is default. Then, from Rider, I use publish to folder to publish my web api project to C:\inetpub\wwwroot
. When I choose Manage website=>Browse
in IIS manager I get an HTTP 500.19
error:
A quick search suggested this was because my web api uses appsettings.json
, so I added a web.config
file the project, but that made no difference. The web.config in my source is almost empty:
But after publishing it grows a little and looks like this:
Many hits on another search tell me the solution here is to remove invalid elements from the config file, but how must I know what is valid or not.1 replies
✅ Troubleshooting MAUI build errors
I have my MAUI project that gives me build errors and an equivalent example project that builds and runs fine on my Android device. I'm trying to determine what differs between the two projects, but apart from little things like names etc. I can't find any significant differences, yet only the example project builds. The same build error occurs twice in my project:
This error is logged once for an Android build and once for an iOS build. Each of these builds logs an obscenely long call to
csc.exe
. These calls start off like this:
One of my problems is these compiler commands have no less than 190 /reference
parameters each. I am busy trying to use regex to break a command down into a string containing a list of references so I can compare these between project builds, but this is an extremely low level approach and progress is somewhat slower than I can actually bill time for.2 replies
✅ How to debug data binding for a control on a MAUI content page
I'm trying to get a DevExpress
DataGrid
control working as the only content on a MAUI content page. I'm setting the ItemSource
property in the page Loaded
event and so far all I can manage is to see that my breakpoint in that event handler is getting hit when I debug the app on my Android device. Test data is being loaded correctly here, into an ObservableCollection
and the CollectionChanged
and PropertyChanged
events are being raised by my view model, but when the loaded event handler completes, the DataGrid
only shows column headers and zero rows.
I was previously using a CollectionView
control and that was populating properly. I thought it should be a relatively small and simple step to switch to another, similar control, based on my dim memoroes of working with data binding in WPF. It appears it's not at all so simple.
I'm hoping to find other events I can add handlers for and use to examine properties on the control, and maybe set properties to observe changes in the running control. I would also like to try any other means I can find of debugging a control using standard MAUI/XAML data binding setups, and I would greatly appreciate any advice and suggestions on this.2 replies
MAUI ContentPage binding not reflecting in child CollectionView on Android
I have this
ContentPage
in my MAUI app that targets only Android and iOS.
When I just populate the viewmodel in the page Loaded
event, the collection view doesn't get bound to the viewmodel's collection, I only see the Header
text.
When I explicitly bind a viewmodel instance to the collection view's ItemSource
, I see the items from the viewmodel:
I am raising PropertChanged
for the Data
property in the viewmodel:
To start with, besides them being separate libraries, why should the Android and Windows CollectionView
and or ContentPage
bind differently?1 replies
✅ MAUI CollectionView Not Displaying
I am trying to get a data bound
CollectionView
to display in my MAUI app, so far only on Android, but when I navigate the content page hosting the view, only the header displays. I've searched a round a bit and can't seem to find anything that applies, so I'm throwing this out here so long.
Here is my whole content page:
I populate the viewmodel from the page's Loaded
event like this:
When I navigate to the page, my breakpoint in OnLoaded
gets hit, and the JSON properly deserializes into 200 DTO's that look OK. I don't see any error messages logged for binding or anything, but the Android log is so busy it's kind of hard to tell. I know the page and collection view are loading because the text in the Header
template displays, but that is all I can see on my device.3 replies
Project skipped on Solution Build
My solution of five projects has
Cts.Maui.Dx
as the main project, with a project reference to Cts.Maui.Models
, but when I try a solution build in Rider, I get the following build output, with errors because Cts.Maui.Models
is missing. The other two projects seem to be building fine.
This is the abridged output. The actual output has three bloody entries for dotnet.exe exec "C:\Program Files\dotnet\sdk\8.0.204\Roslyn\bincore\csc.dll"
that total a whopping 15kb per line but I assume these are for the three projects that are building.3 replies
✅ Add NuGet packages to Git
I'm frequently offline and this is driving me nuts. Last night I did a git reset in a temper tantrum and NuGet threw its toys. Now I thought I could just go and add
<project>/packages
to my repo, but that folder doesn't exist. I can only find C:\Program Files (x86)\Microsoft SDKs\NuGetPackages
and C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages
. The latter doesn't look promising but I could maybe, at a push (it makes me queasy), add the SDK one.
Yet I'd rather not make a bad situation worse by including all projects' packages to git for one project. Surely there is a way I can configure NuGet to use a packages
folder again? When I set the local packages folder to packages
and do a restore, then click the link for packages folder
I get taken the global packages folder, C:\Users\brady\.nuget\packages
, and the confgured local folder <project>/packages
still doesn't exist. Either Rider or I have a case of mistaken identity here, but to me, local bloody means local.3 replies
Ambiguous reference with MAUI attached property
I have XAML like this, quickly copied from an example on the DevExpress git repo, and my XAML is quite rusty, so I'm not sure what to make of the errors I'm getting. I'm trying to use their
DataGridView
control:
Now on Grid.SetRow
and Grid.SetColumn
I get "Ambiguous reference" errors. I suspect it's because the DataTemplate.Grid
is nested inside a higher up ContentPage.Grid
and MAUI doesn't know which property to attach, but I'm completely stumped as to what to do. Surely these things are normally more tightly scoped?1 replies
✅ DataGrid Equivalent for MAUI
Is there a FOSS library that provides the equivalent of a DataGrid control for MAUI? I'm targeting just Android and iOS, and understand the issues there may ne with such a beast on the small screen, but I've looked high and low and only found one. When I tried to install the NuGet package I initially got an error from NuGet about a detected downgrade of
Microsoft.Maui.Controls
and Maui.Controls.Compatability
from 8.20.0
to 8.0.7
(I think, I have just recreated my MAUI project and am not keen on reproducing the mess I made editing package reference versions up and down or deleting the packages
folder.
I need to show a list of license application line items with a few columns on a landing page. The user selects one and gets taken to a details page. Do I have to roll my own?2 replies
✅ Architecture in a MAUI project
I'm not asking about the architecure of the MAUI project template, or MAUI itself, but after several hours of really hard battles I've finally got Rider to create me a working MAUI project. Now I'd like to proceed and add features according to my requirements. It's here I'm asking for suggestions w.r.t. resources on sound architecture or at least project structure for a MAUI app.
I'm looking to build an Android and iOS app that uses a WEB API (minimal in this case) to talk to a SQL Server database, currently hosted on Azure but could be on-premises. I'm also curious as to testing stratgegies for MAUI.
2 replies
Automatic Assembly Versioning in .NET Core
Some googling turned up a great many disparate approaches to this, so I thought I'd turn to the experts here for suggestions.
I want to set up automatic semantic versioning for a .NET 8 solution, preferably across any IDEs. I also want a simple, one project approach to give to a client do that any changes they make to a DAL DLL they provide me with reflect in a non-semantic version number. The minimum requirement here is that I can tell my local copy of the DAL apart from the 'live' but frequently changing one hosted on Azure.
First, I would like a simply edit to
.csproj
or similar I can write instructions for to the owner of the DAL. Then I would like some guidance on setting up proper and automatic (far as possible) semantic versions to a solution across VS and Rider.1 replies
✅ Mock a .NET library to test a minimal web API.
I'm busy developing a .NET minimal API to provide services (data access) for a MAUI app. The API must use a DAL that is, for now, hosted on Azure where it directly accesses a SQL Server database through EF. My first checkpoint is to test the web api locally to ensure endpoints are correctly set up etc. and to do so I'll need to mock the DAL (a single .NET DLL).
The DAL has no interfaces to mock, but I can add those if needed, but I was wondering id there was any way besides adding interfaces to automatically mock the DAL classes.
14 replies
✅ MAUI with Rider
I'm asking in the hope that someone might have some info I couldn't find last time I managed to get a MAUI app running with Rider, on Android? Last time I tried I had failures all over until I installed Android Studio. Installing the dotnet workload and Android SDK on their own wasn't enough, apparently. If it's going to be the same I might as well just install Android Studio up front.
Update: I tried installing the dotnet
android
workload and got this far: https://pastebin.com/RjT7V3RA
I will try installing the prescribed worklod again though with :
dotnet workload install maui
5 replies
✅ Install Rider on Ubuntu from .tar.gz archive
So far I've found 2 sets of instructions to just extract the Rider.tar.gz contents to
/opt/
and then run /opt/<rider>/bin/rider.sh
, but that runs Rider from a terminal, and I'd much rather I could just run the executable from my Avitivities sidebar.
How can I properly install Rider using the archive I have. I don't have bandwidth to download it again using Snap or some other method.5 replies