Brady Kelly
Brady Kelly
Explore posts from servers
CC#
Created by Brady Kelly on 5/27/2024 in #help
ASP.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:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddScoped<Users>();
builder.Services.AddScoped<UsersRepository>();
...
class UsersRepository {
CTSCore.Security.Users Users;
public UsersRepository()
{
Users = new();
}
}
...
public class LoginEndpoint: Endpoint<LogonRequest, Results<Ok<LoginResponse>, UnauthorizedHttpResult>>
{
public UsersRepository? Repository { get; set; }
UsersRepository? _repository;
public LoginEndpoint(UsersRepository repository)
{
_repository = repository;
}
}
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddScoped<Users>();
builder.Services.AddScoped<UsersRepository>();
...
class UsersRepository {
CTSCore.Security.Users Users;
public UsersRepository()
{
Users = new();
}
}
...
public class LoginEndpoint: Endpoint<LogonRequest, Results<Ok<LoginResponse>, UnauthorizedHttpResult>>
{
public UsersRepository? Repository { get; set; }
UsersRepository? _repository;
public LoginEndpoint(UsersRepository repository)
{
_repository = repository;
}
}
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:
builder.Services.AddScoped<Users>();
...
public static void CheckServiceIsRegistered<T>(this IServiceCollection services)
{
services.CheckEnvironment($"Service {typeof(T).FullName} should be registered", s => s.GetRequiredService<T>());
}
builder.Services.AddScoped<Users>();
...
public static void CheckServiceIsRegistered<T>(this IServiceCollection services)
{
services.CheckEnvironment($"Service {typeof(T).FullName} should be registered", s => s.GetRequiredService<T>());
}
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
CC#
Created by Brady Kelly on 5/18/2024 in #help
✅ 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
CC#
Created by Brady Kelly on 5/17/2024 in #help
Configure Serilog to only write warnings to Seq sink
I have the following Serilog configuration:
Serilog.Debugging.SelfLog.Enable(Console.Error);
Log.Logger = new LoggerConfiguration()
.Enrich.WithProperty("Application", typeof(Program).Assembly.GetName().Name)
.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Error)
.WriteTo.Console().MinimumLevel.Information()
.WriteTo.Seq("http://localhost:5341", apiKey:"awz1rXJhgYM2xxKKYaZ2")
.WriteTo.EventLog(source:"Application", logName:"Application", restrictedToMinimumLevel:LogEventLevel.Warning)
.CreateLogger();
Serilog.Debugging.SelfLog.Enable(Console.Error);
Log.Logger = new LoggerConfiguration()
.Enrich.WithProperty("Application", typeof(Program).Assembly.GetName().Name)
.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Error)
.WriteTo.Console().MinimumLevel.Information()
.WriteTo.Seq("http://localhost:5341", apiKey:"awz1rXJhgYM2xxKKYaZ2")
.WriteTo.EventLog(source:"Application", logName:"Application", restrictedToMinimumLevel:LogEventLevel.Warning)
.CreateLogger();
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
CC#
Created by Brady Kelly on 5/4/2024 in #help
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
CC#
Created by Brady Kelly on 4/25/2024 in #help
✅ 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
CC#
Created by Brady Kelly on 4/24/2024 in #help
✅ Minimal API: Pass app config to IEndpointRouteBuilder
I am using route builders to map routes for a minimal API, like this:
public static class LicenseApplicationEndpoints
{
private static EndpointsConfig _config = new EndpointsConfig();

public static void RegisterLicenseApplicationEndPoints(this IEndpointRouteBuilder routes)
{
var group = routes.MapGroup($"{_config.RoutePrefix}/licenseApplications");

group.MapGet("/forUser{userId:guid}",
([FromServices] ILicenseApplicationService service, Guid userId) =>
service.GetLicenseApplicationsForUser(userId));
}
}
public static class LicenseApplicationEndpoints
{
private static EndpointsConfig _config = new EndpointsConfig();

public static void RegisterLicenseApplicationEndPoints(this IEndpointRouteBuilder routes)
{
var group = routes.MapGroup($"{_config.RoutePrefix}/licenseApplications");

group.MapGet("/forUser{userId:guid}",
([FromServices] ILicenseApplicationService service, Guid userId) =>
service.GetLicenseApplicationsForUser(userId));
}
}
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
CC#
Created by Brady Kelly on 4/23/2024 in #help
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:
The requested page cannot be accessed because the related configuration data for the page is invalid.
The requested page cannot be accessed because the related configuration data for the page is invalid.
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:
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<system.web>
<compilation debug="true" />
<httpRuntime />
</system.web>
<appSettings>
</appSettings>
</configuration>
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<system.web>
<compilation debug="true" />
<httpRuntime />
</system.web>
<appSettings>
</appSettings>
</configuration>
But after publishing it grows a little and looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" />
<httpRuntime />
</system.web>
<appSettings></appSettings>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\Cts.Mobile.WebApi.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" />
<httpRuntime />
</system.web>
<appSettings></appSettings>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\Cts.Mobile.WebApi.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</configuration>
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
CC#
Created by Brady Kelly on 4/22/2024 in #help
✅ 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:
ApplicationGrid.xaml(10,18): Error XFC0000 XamlC: Cannot resolve type "clr-namespace:DevExpress.Maui.DataGrid;assembly=DevExpress.Maui.DataGrid:dxg:AdvancedColumnLayout.RowDefinitions".
ApplicationGrid.xaml(10,18): Error XFC0000 XamlC: Cannot resolve type "clr-namespace:DevExpress.Maui.DataGrid;assembly=DevExpress.Maui.DataGrid:dxg:AdvancedColumnLayout.RowDefinitions".
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:
C:\Program Files\dotnet\dotnet.exe exec "C:\Program Files\dotnet\sdk\8.0.204\Roslyn\bincore\csc.dll"
C:\Program Files\dotnet\dotnet.exe exec "C:\Program Files\dotnet\sdk\8.0.204\Roslyn\bincore\csc.dll"
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
CC#
Created by Brady Kelly on 4/21/2024 in #help
✅ 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
CC#
Created by Brady Kelly on 4/21/2024 in #help
MAUI ContentPage binding not reflecting in child CollectionView on Android
I have this ContentPage in my MAUI app that targets only Android and iOS.
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:Cts.Maui.Dx.Models"
x:Class="Cts.Maui.Dx.ApplicationListPage">
<ContentPage.BindingContext>
<models:ApplicationListViewModel x:Name="ViewModel" />
</ContentPage.BindingContext>
<ContentPage.Content>
<CollectionView ItemsSource="{Binding Data}" x:Name="CollectionView">
<CollectionView.Header>
<Label Text="Header" />
</CollectionView.Header>
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Label Grid.Row="0" Text="{Binding LearnerDesc}" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="{Binding Originator}" />
<Label Grid.Column="1" Text="{Binding StartDate}" />
<Label Grid.Column="2" Text="{Binding IsLocked}" />
</Grid>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ContentPage.Content>
</ContentPage>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:Cts.Maui.Dx.Models"
x:Class="Cts.Maui.Dx.ApplicationListPage">
<ContentPage.BindingContext>
<models:ApplicationListViewModel x:Name="ViewModel" />
</ContentPage.BindingContext>
<ContentPage.Content>
<CollectionView ItemsSource="{Binding Data}" x:Name="CollectionView">
<CollectionView.Header>
<Label Text="Header" />
</CollectionView.Header>
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Label Grid.Row="0" Text="{Binding LearnerDesc}" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="{Binding Originator}" />
<Label Grid.Column="1" Text="{Binding StartDate}" />
<Label Grid.Column="2" Text="{Binding IsLocked}" />
</Grid>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ContentPage.Content>
</ContentPage>
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:
var stream = await FileSystem.OpenAppPackageFileAsync("appList.json");
var streamReader = new StreamReader(stream);
var json = await streamReader.ReadToEndAsync();
// Just loading the page viewmodel doesn't work.
// ViewModel.LoadFromJson(await streamReader.ReadToEndAsync());
var model = new ApplicationListViewModel();
model.LoadFromJson(json);
CollectionView.ItemsSource = model.Data;
var stream = await FileSystem.OpenAppPackageFileAsync("appList.json");
var streamReader = new StreamReader(stream);
var json = await streamReader.ReadToEndAsync();
// Just loading the page viewmodel doesn't work.
// ViewModel.LoadFromJson(await streamReader.ReadToEndAsync());
var model = new ApplicationListViewModel();
model.LoadFromJson(json);
CollectionView.ItemsSource = model.Data;
I am raising PropertChanged for the Data property in the viewmodel:
public IList<LicenseApplicationDto>? Data { get; private set; }

public event PropertyChangedEventHandler? PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string propertyName = "") {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

public void LoadFromJson(string json)
{
Data = JsonSerializer.Deserialize<List<LicenseApplicationDto>>(json) ?? throw new InvalidOperationException("Deserialized to null");
OnPropertyChanged();
}
public IList<LicenseApplicationDto>? Data { get; private set; }

public event PropertyChangedEventHandler? PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string propertyName = "") {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

public void LoadFromJson(string json)
{
Data = JsonSerializer.Deserialize<List<LicenseApplicationDto>>(json) ?? throw new InvalidOperationException("Deserialized to null");
OnPropertyChanged();
}
To start with, besides them being separate libraries, why should the Android and Windows CollectionView and or ContentPage bind differently?
1 replies
CC#
Created by Brady Kelly on 4/21/2024 in #help
✅ 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:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:Cts.Maui.Dx.Models"
x:Class="Cts.Maui.Dx.ApplicationListPage">
<ContentPage.BindingContext>
<models:ApplicationListViewModel x:Name="ViewModel" />
</ContentPage.BindingContext>
<ContentPage.Content>
<CollectionView ItemsSource="{Binding Data}">
<CollectionView.Header>
<Label Text="Header" />
</CollectionView.Header>
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Label Grid.Row="0" Text="{Binding LearnerDesc}" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="{Binding Originator}" />
<Label Grid.Column="1" Text="{Binding StartDate}" />
<Label Grid.Column="2" Text="{Binding IsLocked}" />
</Grid>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ContentPage.Content>
</ContentPage>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:Cts.Maui.Dx.Models"
x:Class="Cts.Maui.Dx.ApplicationListPage">
<ContentPage.BindingContext>
<models:ApplicationListViewModel x:Name="ViewModel" />
</ContentPage.BindingContext>
<ContentPage.Content>
<CollectionView ItemsSource="{Binding Data}">
<CollectionView.Header>
<Label Text="Header" />
</CollectionView.Header>
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Label Grid.Row="0" Text="{Binding LearnerDesc}" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="{Binding Originator}" />
<Label Grid.Column="1" Text="{Binding StartDate}" />
<Label Grid.Column="2" Text="{Binding IsLocked}" />
</Grid>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ContentPage.Content>
</ContentPage>
I populate the viewmodel from the page's Loaded event like this:
private async void OnLoaded(object sender, EventArgs e)
{
var stream = await FileSystem.OpenAppPackageFileAsync("appList.json");
var streamReader = new StreamReader(stream);
ViewModel.LoadFromJson(await streamReader.ReadToEndAsync());
}
...
public void LoadFromJson(string json)
{
var apps = JsonSerializer.Deserialize<List<LicenseApplicationDto>>(json) ?? throw new InvalidOperationException("Deserialized to null");
Data = apps;
OnPropertyChanged();
}
private async void OnLoaded(object sender, EventArgs e)
{
var stream = await FileSystem.OpenAppPackageFileAsync("appList.json");
var streamReader = new StreamReader(stream);
ViewModel.LoadFromJson(await streamReader.ReadToEndAsync());
}
...
public void LoadFromJson(string json)
{
var apps = JsonSerializer.Deserialize<List<LicenseApplicationDto>>(json) ?? throw new InvalidOperationException("Deserialized to null");
Data = apps;
OnPropertyChanged();
}
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
CC#
Created by Brady Kelly on 4/21/2024 in #help
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.
Build with surface heuristics started at 08:16:46
Use build tool: C:\Program Files\dotnet\sdk\8.0.204\MSBuild.dll
CONSOLE: MSBuild version 17.9.8+b34f75857 for .NET
CONSOLE: Build started 4/21/2024 8:16:46 AM.
CONSOLE: Project "C:\Users\brady\AppData\Local\Temp\Zojapov.proj" on node 1 (default targets).
CONSOLE: ControllerTarget:
CONSOLE: Run controller from C:\Program Files\JetBrains\Rider\r2r\2023.3.4R\533CB127EA8D8D4CE2837F707AB6B81\JetBrains.Platform.MsBuildTask.v17.dll
0>------- Started building project: Cts.Wpf
1>------- Started building project: Cts.Maui.Tests
2>------- Started building project: Cts.Maui.Dx
Build with surface heuristics started at 08:16:46
Use build tool: C:\Program Files\dotnet\sdk\8.0.204\MSBuild.dll
CONSOLE: MSBuild version 17.9.8+b34f75857 for .NET
CONSOLE: Build started 4/21/2024 8:16:46 AM.
CONSOLE: Project "C:\Users\brady\AppData\Local\Temp\Zojapov.proj" on node 1 (default targets).
CONSOLE: ControllerTarget:
CONSOLE: Run controller from C:\Program Files\JetBrains\Rider\r2r\2023.3.4R\533CB127EA8D8D4CE2837F707AB6B81\JetBrains.Platform.MsBuildTask.v17.dll
0>------- Started building project: Cts.Wpf
1>------- Started building project: Cts.Maui.Tests
2>------- Started building project: Cts.Maui.Dx
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
CC#
Created by Brady Kelly on 4/21/2024 in #help
✅ 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
CC#
Created by Brady Kelly on 4/19/2024 in #help
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:
<dxg:DataGridView.Columns>
<dxg:TemplateColumn MinWidth="310" Caption="Customers" FieldName="Name" IsGrouped="true" GroupInterval="Alphabetical" SortOrder="Ascending">
<dxg:TemplateColumn.DisplayTemplate>
<DataTemplate>
<Grid VerticalOptions="Center" Padding="15, 5, 0, 10" RowDefinitions="*" ColumnDefinitions="Auto, 3*, *">
<dx:DXStackLayout Orientation="Vertical" Grid.SetRow="0" Grid.SetColumn="1" Padding="0"
Margin="0" Opacity="0.7">
<Label Text="{Binding Item.Name}" FontSize="16" FontAttributes="Bold" />
<dxg:DataGridView.Columns>
<dxg:TemplateColumn MinWidth="310" Caption="Customers" FieldName="Name" IsGrouped="true" GroupInterval="Alphabetical" SortOrder="Ascending">
<dxg:TemplateColumn.DisplayTemplate>
<DataTemplate>
<Grid VerticalOptions="Center" Padding="15, 5, 0, 10" RowDefinitions="*" ColumnDefinitions="Auto, 3*, *">
<dx:DXStackLayout Orientation="Vertical" Grid.SetRow="0" Grid.SetColumn="1" Padding="0"
Margin="0" Opacity="0.7">
<Label Text="{Binding Item.Name}" FontSize="16" FontAttributes="Bold" />
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
CC#
Created by Brady Kelly on 4/19/2024 in #help
✅ 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
CC#
Created by Brady Kelly on 4/18/2024 in #help
✅ 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
CC#
Created by Brady Kelly on 4/18/2024 in #help
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
CC#
Created by Brady Kelly on 4/18/2024 in #help
✅ 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
CC#
Created by Brady Kelly on 4/16/2024 in #help
✅ 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
CC#
Created by Brady Kelly on 3/27/2024 in #help
✅ 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