C#

C

C#

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

Join

✅ Asp .NET Core production settings.json question.

Hi all, As you know you have an appsettings.json file. Which contains some general things such as:...

✅ Visual Studio SSMS error An item with with the same key has already been added

So I am following a tutorial of Model First Approach in ASP.NET MVC in which I am using ADO.NET Entity Model Data, Empty EF Designer model and when generating the database after defining it's properties getting an error of An Item with the same key has already been added. Here's my Model and the error while generating DDL is An item with the same key name is already added....
No description

CanExecuteChanged event

Hey. I am learning how to use Commands in C# and created simple command, to interact with my ViewModel (some notebook manager). If some notebook is selected, adding new note should be possible, if nothing is selected, the button binded with that command should be disabled. I have following code: ```c# using System.Windows.Input; using EvernoteClone.Model;...

Setting wcf response element name

Hi, I'm writing a wcf soap service and I need to align response element name (see file for more). How can I do it?...

How to to dynamically provide T type of a generic method

I am having an interface declaration which has many-many implementations. The usecase/logic is similar, but the return type differs. (tldr: the services parse and validate data extracted from different systems. They each return the parsed structure relevant to the given system and the detected errors). I want to achieve something like this, however I cannot pass the Type retrieved from the specific implementation in the method call. The services are provided through factory pattern. ...
No description

✅ Binding Nested values in RequestBody to Model

Consider the following model I use inside the MVC structure: ```cs public class Collection { /// <summary>...

job advice

ok so i just passed some offline technical tests for a asp.net backend dev job. but honestly, while i'm quite experienced with C# as a WPF dev i dont know much about asp.net and havent really developed anything using it. i might have an interview in a week again, so can you prime me on what i should learn in this week? as fast as possible, i want to get as much knowledge.

csc.exe takes 140 Seconds to build one specific Project

this here is from dotnet build -bl ``` 18> 17 ms CallTarget 3 calls 18> 17 ms CheckForDuplicateItems 3 calls...

✅ Changing ASPNETCORE_ENVIRONMENT causes broken site.

Hi all, I am wanting to test our ASP .NET CORE App coupled with Blazor Wasm in production. So I changed ASPNETCORE_ENVIRONMENT to "Production", and altered Program.cs to work with it:...

Need advice on how to update my WPF app from .net6 to .net8 with minimal disruption to users

Hello. I tend to work more in asp.net, but a couple of years ago I was asked to build a WPF application that is distributed to ~1500 users. I chose .net6 at the time as it was the latest LTS. Because of a lot of weird customizations that were required, I also built my own updating framework for it. For two years this has been fine, but now I'm being asked to upgrade it to .net8 LTS. This presents some challenges. My application is 12MB because the installer would install .net6 desktop runtime (I'm using Advanced Installer). It's a single file application. I now need to figure out the best way to update this for all users to .net8. I am able to push out updates to my application just fine, but I don't have a good sense for how I can upgrade to .net8. My first thought was to include it in the app, but now my size went from 12MB to something like ~184MB. This is difficult because every update would now require the full .net version, presumably. I looked into trimming but I guess that isn't supported for WPF, of course....

Inheritance

Hello all, I have an inheritance problem. When I create an object Entity x; and later I asign him the value x = new MovingEntity(Texture,Position), the values are not assigned onto x. Why? class Entity...

Open brace on new line for new Control Blocks not working

Hi everyone, it seems that since the last update this function isn't working for me anymore? For example, when I write an if statement then write an open bracket and press enter it doesn't put the open bracket into a new line anymore. Is it the same for anyone else and does anyone have a solution for that?...
No description

✅ Does .NET 8 compiled by .NET 9 sdk as production ready as .NET 8 compiled by .NET 8 sdk?

.net 9 sdk can target .net 8 Where do I get more info on this topic?...

Publish A Project That Reference To Another Project To Output DLL To `libs` Dir

Hello, I have a project X that compiles as library (DLL) with has a lot of nuget packages. This project used as utils for my other project, project A. Project A is a winExe project, self contained that I want to publish. Upon publish, it builds project X than project A....

Get another writeline on second itteration

Im storing a username and password (fejk ones) in an array and using this for-loop i want the second pass to display "Pick a password", how do i go about this? string[] user = new string[2]; for (int i = 0; i < user.Length; i++) {...

✅ .NET 8 enum to string serialization throws an exception

Hello, Following the docs, a custom JsonSerializerContext is applied on the controllers, yet an exception is thrown. ```c# public sealed record GetLinkMetricsRequest...

What is wrong with my C# Perlin noise generator?

I've been trying to code my own implementation of the Perlin noise algorithm based on this paper: https://www.cs.umd.edu/class/spring2018/cmsc425/Lects/lect13-2d-perlin.pdf However, it ends up producing a weird pattern which is pretty far off the result I was looking for. The image it creates is below. I tried messing around with the noise function and dot product function, but I'm unsure of what is actually going wrong. I suspect that I've made a silly error with the logic behind it, so if one of you could point that out for me then that would be greatly appreciated....

chinese checkers Unity 2d

hallo i am new in this server and i want some help if anyone interested. my name is dani from sweden and i study game development in the university. we are working on a project to make a chinese checkers in unity and i find it hard to understand the MVC pattern we are working with. if anyone can help me understanding the cod better i have the project and all the scripts. pls send me a message.
No description

✅ How do Avro, ORC and Parquet work?

I have been learning about big data and these came across as a few of the popular "optimized file formats". I want to understand how they work.