C#

C

C#

We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.

Join

✅ What are the top 10–20 advanced .NET/C# concepts every developer should master?

Hi folks, what are the top 10–20 advanced .NET/C# concepts that every developer should know?

✅ Class problem

Im new with C# and in my script im looking to call a script alr created but it won't work
No description

✅ FREE service

guys i offer my service for free ; i'm ready to work with you in your next .NET project ; can someone help me ?i want to work with a team on real project ?

✅ C# project that contains C++ on mac

Hey guys, so I want to try getting a C# project working that also contains c++ compiled into a library, but mac is making this quite difficult. I can compile the .dylib manually and compile my .cs file using the dotnet command, but when it comes to actually making this into a managable project I am a bit stuck. It seems normally what I would want to do is use a .vcxproj file to compile into a library, and then in a .sln file have some sort of settings to build both my .csproj and .vcxproj together. I tried to just do this with dotnet, but it seems the dotnet command does not support solutions with .vcxproj files. I tried msbuild and dotnet-vcxproj but they both fail for the same reason: ```...

✅ Help with using C++ library in C# code

hello, I am trying to use a c++ library using a .dylib (mac dll) and its giving me a weird error that i can't find a lot of info on, maybe because its unique to osx? ``` willow@willows-mbp csharp % set DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib willow@willows-mbp csharp % dotnet run ==10641==ERROR: Interceptors are not working. This may be because AddressSanitizer is loaded too late (e.g. via dlopen). Please launch the executable with:...

I'm crashing out at .NET MAUI Localization

I followed these steps https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/localization?view=net-maui-9.0#vs-code-setup And still it gives the same error: MainPage.xaml(9,17): XamlC error XC0000: Cannot resolve type "clr-namespace:[MyApp].Resources.Strings:AppResources". Is it because I'm on Linux and not using VS?...

✅ Web APIs: Authentication Providers

I am getting set up with a basic web API that is basically glorified CRUD with a react SPA frontend with some external data providers, and I'm trying to get the dev setup fully integrated. My main problem is around authentication. Previously I have used username + password auth with asp.net identity, but I would like social login providers, SAML SSO, etc, so was planning on going with an alternative. That seemed to be one of: 1. Auth0, Microsoft Entra ID, AWS Cognito, etc managed solutions 2. Duende Identity Server / Keycloak / another local solution ...

Can someone explain reflections in simple terms?

I don't really understand whats the point of the reflection. I get that it allows you to get the information about the class, but if I know the name of the class and the method why not just create an instance of that class. I searched up it is used in plugin architecture but it still seems questionable since you have to either enforce GC to unload old dll or reload project. Have you guys used it in production if so when and why?...

✅ dotnet test doesn't show correct total number of unit tests at the end

I have a solution with many projects. When I run dotnet test, it selects all my xUnit projects and correctly executes all of them. I have 440 unit tests in total, but at the end, dotnet test outputs a number that is sometimes 428 sometimes 380 sometimes 440 (the correct number) etc ... I think it sometimes fails to aggregate all the test results. I find it hard to make a MRE to share because I tried on two computers, and I can only see the bug on one of them. On the other one, no matter how...

✅ CQRS and Repository pattern

The repository and services pattern is very similar to the mediator and CQRS. What's the point of these two similar patterns?

✅ How do i rescale design project

I dont want to rescale components but the whole IDE window. When im compiling it it looks normally.
No description

✅ Blazor WASM Headers

How can I set headers? Cross-Origin-Embedder-Policy: require-corp Cross-Origin-Opener-Policy: same-origin ...

✅ Weird ASP0016 behavior

Is there a semantic difference between these two pieces of code? the first one is fine, but the second one gives me ASP0016 (which i don't think is correct? it's late and i'm kind of an asp noob so i might be mistaken...). the only difference is that the lambda for atomLinks.Select has async/await in the first one, but not in the second. Code 1, async/await, no warning ```cs app.MapGet("/molecule.xml", async context => {...

using ArrayPool<T> across await / yield

I was optimizing Linq's TakeLast, but I have a different opinion from the reviewer regarding ArrayPool and yield. I would like official guidelines (at least for implementations within the BCL). I'd like to hear other people's opinions. https://github.com/dotnet/runtime/discussions/48257#discussioncomment-14756300...

rgument 2: cannot convert from 'int' to 'System.Func<int, decimal>'

```C# int lineReading; if (inputStudentFile == "1") {...

Visual studio Installer

i previously was using visual studio pro 2022 but my extensions were no longer updating and i was getting a very odd error so i decided to do a uninstall and reinstall of vs but the problem persisted so i decided to uninstall both vs studio and vs installer since then i have downloaded the exe for visual stuio installer again but when i attempt to run it, it silently fails with no logging or events to see. Things i have tried to do to resolve the issue include 1. Removed Registry for vs 1. Run exe as Admin 2. Remove all Temp files of VS and VS installer 3. Clear all group policies...

CS Final Year Project ideas required as I'm about to hit the deadline

I've thought a lot but I couldn't come up with anything to pick for my final year project. I dont wanna get away with some copy paste thing as many students here do. Rather I want to end my degree with something good, creative and not too simple. And something that would look good on my CV as well if possible. I'd appreciate any ideas that you guys might have....

Blazor Server with Custom SignalR Hub

Hello, I am experimenting with adding notifications to my companies Intranet. I thought using SignalR for this would be a good idea. And it was working locally, until I put it up on our test server and I found an issue. We are using Windows Authentication, and it seems the Blazor Server Authentication is hitting my servers Windows Authentication and then my IUserIdProvider is setting the SignalR Context Identity to this as well, so we would mean there is only 1 client. Is there a way of authenticating Client to Server, without the use of JS interop. I have a working version on the server with JS, however if it's possible I want a C# only approach. I have also tried a cookie authentication, with a 'double-hop' approach, but I can't seem to get that to work, the cookie from middleware never arrives, thus a 401....

✅ I'm trying to allow CORS on C# in order to allow cookies on my frontend, but I fail.

Hey, I'm trying to create a functionality that works this way: I login-in in the frontend -> The backend receive the username that logged-in with controller http method -> I store the username inside a state and show it to the user on the top-left of the screen. Now, I added those lines to the Program.cs file: ```cs...
No description