r/dotnet

Image 1 — A look back at the past
Image 2 — A look back at the past
Image 3 — A look back at the past
Image 4 — A look back at the past
▲ 326 r/dotnet

A look back at the past

I noticed a discussion in the comments yesterday about the Professional Active Server Pages 2.0 book from Wrox, which back in the day was one of the only sources of information us oldies had to work with as a reference for classic ASP. Even one of the authors chimed in and is still active in this sub (Brian Francis).

I’ve kept my copy. I also have a number of books in my bookshelves that were invaluable back in the day and some of them I’ve kept for posterity even though they are worthless from a tech perspective now.

Hopefully they bring back nice memories for some of you too.

u/desnowcat — 4 days ago
▲ 58 r/dotnet

NaturalCron 1.1.0: define your own schedule keywords

I introduced a new cool feature in NaturalCron 1.1.0: you can now customise your own keyword rule and add it to the NaturalCron engine. It is usually added once on app startup, before any parsing.

For those who don't know, NaturalCron is a scheduling library for .NET where you write schedules in plain words instead of cron strings, e.g. every 30 minutes between 09:00 and 18:00.

Version 1.1.0 adds custom keywords: you define a word once at app startup, with your own logic, and then use it in any expression.

NaturalCronCustomKeywords.Configure(cfg =>
{
    // A day keyword (the default time unit is Day).
    cfg.AddMatchable("holiday", dt => myHolidays.Contains(dt.Date));

    // An hour keyword.
    cfg.AddMatchable("evenHour", dt => dt.Hour % 2 == 0, NaturalCronTimeUnit.Hour);
});

Then:

every holiday at 09:00
every day at 09:00 except holidays
every day on [holiday, 15th] at 09:00

A keyword can also be a class, so it can come from your DI container and read from a cache.

Also new in 1.1.0:

  • except, which works with built-in values too: every day at 09:00 except [saturday, sunday]
  • A shorthand for every: every 15th at 18:00, every 1stMonday at 09:00, every 9am

GitHub: https://github.com/hugoj0s3/NaturalCron NuGet: https://www.nuget.org/packages/NaturalCron

Feedback welcome, especially on the syntax.

reddit.com
u/West_Ad6277 — 4 days ago
▲ 3 r/dotnet+1 crossposts

Issue connecting my blazor app to remote sql server database hosted my Monsterasp.net

Hello everyone. I have completed the multi-step form challenge from Frontend Mentor and attempted to deploy the finished web app using monsterasp.net through visual studio code. I followed all the instructions from a YouTube video to a tee but when I try to actually submit data to the database I get this error:

\Error: Microsoft.Data.SqlClient.SqlException (0x80131904): The target principal name is incorrect. Cannot generate SSPI context.``

I did some further research into it but everything seemingly leads to a dead end for my specific use case. Here is microsoft's documentation on the specific error:

https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/connect/cannot-generate-sspi-context-error

Note: When I built and deployed the app for the first time the connection string was incorrect. I fixed it and published the app again through visual studion. I am not sure whether that is causing some lingering problems.

u/Mob_Pilled — 5 days ago
▲ 91 r/dotnet

Why aren’t packages.lock.json files the default in .NET projects?

I recently went down the rabbit hole of NuGet version locking and was surprised by how little attention packages.lock.json seems to get in .NET compared to lock files in other ecosystems like node.

A typical PackageReference may pin your direct dependency, but it doesn’t freeze the entire resolved dependency graph. Transitive dependencies are still resolved during restore.

NuGet already has everything needed to make this deterministic:

<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>

Commit the resulting packages.lock.json, and then in CI:

dotnet restore --locked-mode

That gives you a frozen direct + transitive dependency graph, including package content hashes. If the graph changes without the lock file being deliberately updated, CI fails instead of silently accepting it.

What I also hadn’t appreciated before looking into this is that Central Package Management and lock files solve different problems:
Directory.Packages.props -> centrally manages the versions you specify
packages.lock.json -> records the fully resolved dependency graph
So using CPM doesn’t really make the lock file redundant.

We’ve started looking at this more seriously from the reproducible-build / supply-chain side rather than just dependency management.

I’m curious how people here handle this:
Do you commit packages.lock.json for applications? And if not, is there a particular reason you prefer NuGet to resolve the graph on restore?

I wrote up what I learned, including locked-mode CI, CPM/transitive pinning and the supply-chain implications:
https://vensas.de/blog/nuget-version-locking

Disclosure: I work at vensas, where the article is published.

u/Enough_Secretary_137 — 11 days ago
▲ 41 r/dotnet+1 crossposts

Hypa - A terminal multiplexer built in C#

I want to share a little project I've been working on for a few weeks now, an entirely C# .NET 10 AOT compiled terminal multiplexer, currently only Linux and MacOS but I do intent to add Windows as a fully supported platformat eventually.

Hypa v1.0

https://github.com/Hypabolic/Hypa

I actually started building this just as proof it could be done and be high performance in .NET as a sort of way of kicking back against basically every tool these days being built in Rust (including Microsoft recently porting Copilot itself to Rust).

My inital aim was to build a simple herdr type mux clone but as I built it I've ended up going beyond that scope and building things not available in herdr.

One feature I really wanted for a start were 'background panes' essentially a normal terminal pane doing whatever you (or an agent) wants it to do but it never appears in the TUI until you ask for it (or the agent running inside it requests it)

The next feature I wanted was remote machines built in natively, which herdr does do, but I wanted to totally avoid things like SSH and managing keys, in Hypa we call these remote machines cubes (hypa cubes...). Hypa uses the QUIC protocol to connect to remote machines and certificate management is handled for you behind the scenes. All you need is the join code and some type of network access to the remote machine.

I've really enjoyed building this as a hobby project, and I hope some of you will give it a go and offer me some feedback.

I look forward to seeing what you all think and getting some feedback, but most of all I'm just happy I can show that these sort of highly performant terminal experiences CAN and SHOULD be built in C# .NET and native AOT is mature enough to support them.

u/Hephaestite — 11 days ago
▲ 9 r/dotnet+1 crossposts

How are you handling automated dependency/security remediation across multiple .NET repos?

I’m working with an environment that has a large number of .NET repositories, and we regularly get dependency issues such as:

  • Outdated NuGet packages
  • Security vulnerabilities reported by Mend
  • Vulnerabilities in transitive dependencies
  • A newer package version potentially causing breaking changes
  • The same vulnerable package affecting many different repositories

The manual process can become quite repetitive:

Mend finding → identify dependency path → find a safe version → update .csproj/Directory.Packages.props → restore → build → run tests → rescan → create PR

I know tools like Mend Remediate, Renovate, Dependabot, and Snyk can automate parts of this, so I'm interested in how teams are actually handling this in real-world environments.

reddit.com
u/Express_Peak_6876 — 11 days ago
▲ 5 r/dotnet+1 crossposts

GRPC server-side assets with state/persistent data

I am writing my first gRPC application and I am totally lost:

I have to provide gRPC server access to persistent data. The persistent data resides outside the application (it is a hardware device). Reading the persistent data is an expensive operation and it is not an option to ask the device for data every time a gRPC request arrives. Figuring out if the persistent data changed between calls is cheap.

Thus, I want to pull the persistent data into memory upon startup and if the persistent data changed, creating a copy of the data. For each gRPC request, I can ask the device if an update is necessary. If not, I service the request using the (shadow) data kept in memory.

I follow the Microsoft "gRPC services with C#" route and I end up with a server side asset, similar to the tutorial:

public class GreeterService : Greeter.GreeterBase
{
    private readonly ILogger&lt;GreeterService&gt; _logger;
    public GreeterService(ILogger&lt;GreeterService&gt; logger)
    {
        _logger = logger;
    }

    public override Task&lt;HelloReply&gt; SayHello(HelloRequest request, ServerCallContext context)
    {
        return Task.FromResult(new HelloReply
        {
            Message = "Hello " + request.Name
        });
    }
}

This is the default template Visual Studio creates for a gRPC server. I do not know how the Microsoft gRPC server works and I do not think it should be required to reverse engineer it. The documentation states that I have to edit the .proto file to suit my needs (done) and to implement the server-side asset (i.e. the code that generates the response to the request). The rest is handled by the auto generated framework.

I learnt the painful way that this is a stateless approach, i.e. each gRPC transaction creates a new instance of this class and destroys it after it is finished. This is great for a stateless service, but I need some persistent information stored long term in memory. This clearly does not work with this approach as I have to keep my data in scope.

What is the civilized way? So far I considered:

  • A pure static class that is doing the business logic. Well. Works, but goes against modern principles.
  • Some singleton dynamic class doing the business logic. The problem here is that I do not want to learn how the gRPC framework works and I am afraid that the GC decides to kill my business logic class. Sure, I can create a static/global instance somewhere, but that is probably even uglier. I do not know how to nicely keep my object in scope.

So what is the proper way to handle this? To give you an idea: How to have a persistent integer value with a gRPC, implementing a setter and a separate getter? Where do I "store" this value? The integer must be a "long lifetime" variable, i.e. stay alive between gRPC requests.

reddit.com
u/szgyula — 11 days ago
▲ 0 r/dotnet

Can you give me some examples?

Hey, I’m coming from Ruby on Rails

I want to know what kind of architecture you guys use. I’ve reading some content, and I see GitHub only have package or small projects.

Do you guys have some structure similar to real life?
Claude suggest this: https://university.kurz.fyi/dotnet-concepts/modular-monolith-module-boundaries

But I don’t know if it’s something real life architecture.

Can you please give me some instructions?

Thank you in advance

u/Fit_Ad_1874 — 10 days ago