Collect all kinds of c# programming exceptions and fault solutions.

arrayMaxConsecutiveSum c#

As part of learning c# I engage in codesignal challenges. So far everything is going good for me, except for the test stated in the title.
The problem is that my code is not efficient enough to run

C# Print ID CARD but Problem is without Color

i have problem with print card id when i print this not have color just black and white.
private void Button1_Click(object sender, EventArgs e)
pd.DefaultPageSettings.PaperSize =...

Xamarin-Android - Dynamically load native C library embedded in .NET assembly

I am trying to dynamically load a custom native C library which is embedded in a .NET library at build time, used in a Xamarin-Android app.
The process I want to do is:
I built the .NET library and

c# - LoaderException for assembly (Unable to load one or more of the requested types)

So I'm working on our intranet, which is plugin based. I wrote a new plugin, which I want to deploy now. This plugin is using two .dll reference (JenkinsClient(for models) and JenkinsClientApi(helper

Asp.NET Core 2.2: Swagger endpoint specific security definition

I am using Swashbuckle.AspNetCore 5.0.0-rc2 in one of my .Net Core 2.2 REST projects. Within my project I am serving two different apis which are logically connected to each other.
Today, I manag...

My (software) service is continuously removed after a windows 10 update on a notebook/ client

I have a service running on my clients notebooks which is used by my software (Xmlservice)
I install this service from a setup project as an output file.
When Microsoft releases there update (for e...

ASP.NET CORE GIVES A WARNING This package may not be fully compatible with your project

I am working on an core project and i have installed a nuget package which is in .net framework. but on rebuild it gives the following error:
warning NU1701: Package 'Microsoft.AspNet.We...

Retrieve part of structured data from POCOs C#

I have a List<TerminalLink> from which I want to retrieve a subset of. See the class structure below.
The subset is defined by a "map" which identifies which ChannelLink to select i...

Aggregate Eventgrid events

I am using eventgrid,the events are written to the topics and the data is processed and saved in cosmos db.
Now we are trying to build a report in power bi where we are planning to use streaming

How to download an assetbundle into the app folder for IOS/Android and get the required model from it?

Around 5 models were given the name 'kitchen' and around 3 models the name 'furniture' in AssetBundle. Then I created them into the local path using the following code:

How to create a new object in the unit tests project?

I have a class that uses interface. I would like to use the class itself in my unit test, but I don't know how to do it.
My code:
public class Store
private readonly ICache _Cache;

How do I process an uploaded image and save to Azure storage using ImageSharp and ASP.NET Core?

I working on an ASP.NET Core project, one of the main features I need to work out is how to allow users to upload an image that is automatically rescaled and converted to a 'jpg'. This means that ...

TimeSpan Issue in EF Core 3.1

I have a problem querying PostgreSQL database using EF Core 3.1.
The query is very simple
var gamesQuery = this.dbContext.Games.Where(game => game.StartTime > DateTime.Now).AsQueryable();

I want to show users a text l when Label 2 and 3 has a specific value in C#

So i'm working on a project with a random number generator and if Labels 2 and 3 give out a specific value like "25" and "250" i want to show a text to the users. For the labels i am using an ID.

C# After opening an excel workbook, how can I prevent a user from opening another excel file(via windows) in the same excel instance?

I have created a program that searches excel, word, and txt files for a user entered string. So I open each file, search for the string, and add the file(with info) to a datagrid if the document co...

Acces Violation Exception Not Handled

I'm facing with an Acces Violation Exception from Third Party dll, that I can not capture.
Note: Change the version of dll is nort possible.
I tried the following things without result reading other

mqttnet client not getting subscribed topics

I'm using ( and have written a small class to handle my mqtt client. The client connects to the broker and publishes it's messages successfully. Now I w...

Why can't you put Console.ReadKey() in front of the text displayed to the console, or assign Console.ReadKey() to a variable?

using System;
class MainClass {
public static void Main (string[] args) {
Console.WriteLine("Press any key to continue...");
Console.WriteLine(" key pressed", Console.

How to add an appsettings.json file to my Azure Function 3.0 configuration?

The new Azure Function 3.0 SDK provides a way to implement a Startup class. It gives access to the collection of services that are available by dependency injection, where I can add my own componen...

how to access db context within a static method/class in core 2

I have an core 2 webapplication with EF 6. The way I have been using db context so far is using dependency injection provided by core to inject the context into controllers:

Need string manifest to avoid magic strings in webapi c# application

I have a c# webapi application which has magic strings and numbers everywhere. I am asked to change this by having a string manifest or a bundle which holds these strings in one place and refer the...

Getting "Running the docker.exe login command failed." while trying to publish to Azure container registery

I am trying to publish my .Net core app docker image to Azure Container Registry using Visual Studio 2019.
It was working fine, but suddenly I started to see the following error:
Publish has encou...

ASP.NET Core 3.1, logging only specific messages to Azure Log Stream Console

I have an ASP.NET Core 3.1 API running on Microsoft Azure App Service.
I have set up an ILogger into the app and I use it extensively to monitor the behavior of the API. I would like to be able t...

Delegating Switch not considered in Code Coverage

I have found the following problem, while working with switch cases. R# showed me a simplification of the switch statement, which basically binds a delegate to the case label when you assign a vari...

VS Code IntelliSense does not work with Unity. Why?

VS Code IntelliSense does not work with Unity. Why?
I am using Unity with VS Code. When I type I do not get any suggestions which are related to Unity. E.g. I am not getting the gameObject suggeste...

Updating ASP.Net Core Angular template from Version 8 to 9

The book that i read has version 9 from the beginning (ASP.NET Core 3 and Angular 9 - Third Edition) and uses also the angular template. I have the latest visual studio updates for vs 2019 installe...

remove decimal points from percentage and keep percent symbol in .net

I am trying converting decimal to string which are in this format 0.85 to 85% by using below code, but i am always getting like this
85.00 %
and the code i am using like this below

Select name based on ID with ASP.NET MVC

I create a new form and I want view name based on id in another table, but the id can't view in the dropdown list:
This is the view:
<div class="form-group">
<label class=&

How to send a json file with HttpClient in C#?

I'm trying send a JSON file with postman and it's working. But when I'm trying to send the same contents via HttpClient it's not working.
System.IO.File.WriteAllText(dirName + "\\importproduct.js...

How can I get textbox value based on Id in another table?

Why doesn't the textbox Name get value by Id?
So this is view ex_op:
This Id and Name, I get based on tbl_operator. When I entered Id then the Name will show.
This is controller ex_op:

How do I map CSV header to propertyname at runtime with ChoETL

Using choETL I found that I can map csv position to property name like this
public class Emp
public string Name { get; set; }
public string Other{ get; se...

Analyzer 'Microsoft.Azure.WebJobs.Extensions.DurableTask.Analyzers.FunctionAnalyzer' threw an exception of type 'System.NullReferenceException'

I get this warning while building my Azure functions project. There aren't much details in the the stack trace. Can anyone please help me make sense of this error?
> CSC : warning AD0001: Analy...

How to run AutoITX script in c#

I wanted to pass credentials to IE through selenium code, for this I have used AutoIT. There is a method in java to run the autoit script, but I cannot find equivalent method in C#. Please help me

C# core Dependency injection using RestSharp

I am currently using RestClient to fetch data from a website.
I would like to be able to use dependency injection in the controller class in my core project that uses the Client class.

How Do I Access Windows.Gaming.Input in a Non-UWP C# Project?

I've seen some examples of using Windows.Gaming.Input in C++ console apps but is there a way to access it in a non-UWP C# project as well?

How can I configure log4net?

I use not from app.config configuration - I have a log4net.config file.
App.Config looks like that:
<section name="log4net"

ArrayOfXElement to DataSet in C#

No, there is no appropriate answer in stack overflow yet. I am getting ArrayOfXElement in .net Core through Connected Services. But, I need to convert it into DataSet. How can I do that? I wrote the

PowerBI App-Only-Auth Embedding Issue w/ pbiClients.Reports.GetReportInGroup

I am trying to embed a Power BI report to a custom application. I have followed Microsoft's developer guidance, but I am hitting some odd issues that are not documented very well on the we...

Orbiting an object in Vuforia using c# Unity

I have written a simple script in c# for Unity to make a 3D object like sphere orbit (0,0,0) above image target.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

C# Distinct by property of List<class> inside a class

class Parent
string Name;
string Description;
List<Child> Actions;
class Child
string Action;
string Value;
I have List<parent> parents and I want to

Xamarin Forms issue with HTTPS request

I have created an application in Xamarin forms with Visual Studio 2017 Professional and Visual Studio 2019 cumulative edition.
The problem is that the app works fine with HTTP requests, but in the ...

Why is RedirectToAction() method not working in Authentication?

I am doing authentication for a project. When I redirect it to another controller after authentication, it's not working. After I remove [Authorize] in the redirected controller, it's getting redir...

How can I flush all loggers in a dotnet core appliation just before doing a Environment.Exit()

Basically I have the old known issue of an application crashing and having no debug logs, because the application terminated before it could write the logs.
A classic approach is to catch all Excep...

Debug and release versions of application work but cannot install it, NET 3.5, C#

I've developed app in VS2015 which needs to run on target computers that have Windows XP, NET 3.5. The release and debug versions of the application work without any problems on those computers.
I ...

Running a Curl Command from C#

I'm trying to run a curl command from a C# program. My code is below. When I run the code below, I get an exception that the file is not found. I want to be able to do this but I do not want to ...

Verifying SendGrid's Signed Event Webhook?

I'm trying to implement the validation from this link.
I don't w...

Fundamental question about synchronizing with the UI thread in Winforms using c#

I know Winforms has only one UI thread, and if you need to update it while you are on another thread, you should use invoke method.
My questions is if what you are doing does not change the look o...

ASP.NET Core MVC MySQL Server Connection

I'm having issues trying to establish a connection to a server I've setup using Windows Server 2019 in ASP.NET Core MVC 3.1.
The only things I've installed on the server is the MySQL suite and IIS....

Can I pass an integer list from c# to prolog predicate?

I've written a predicate in prolog that verifies if the given matrix is a magic square or not. It works but I want to make a graphical interface using C#. I've searched on how to connect prolog to ...

Xamarin Forms not Displaying new page when using <Editor> element and SDK

The project is done in Xamarin Forms but this is an iOS-specific problem because we do not use SDK on the Android project.
When trying to navigate from page to page neither on Simulator nor on real