Skip to content
Fix Code Error

Tag: .net

Why is Logger not automatically available as DI service

July 17, 2021 by Code Error

Posted By: Anonymous When trying to instantiate public class MyClass : BackgroundService { private ILogger<MyClass> Logger {get;} public MyClass(Logger<MyClass> logger) { Logger = logger } } through .Net DI by registering MyClass through services.AddHostedService<MyClass>(); When the class is activated, an exception is thrown: System.InvalidOperationException: ‘Unable to resolve service for type ‘Microsoft.Extensions.Logging.Logger1[MyClass]’ while attempting to activate …

Continue Reading

Private nuget source github returns 401 with correct credentials

July 16, 2021 by Code Error

Posted By: Anonymous I have a nuget package that is hosted on my private repository. I added the minimum amount of scope flags at first but later added except for a few admin level ones. Now when adding the source to my global ‘nuget.config’ ind the IDE (Rider/jetbrains) It prompts me for my github credentials …

Continue Reading

setsimplecolumn doesn’t position the text to the given coordinates in PDF using itextsharp 5 in C#

July 16, 2021 by Code Error

Posted By: Anonymous I am new to iTextShap and I am trying to add two text columns using SetSimpleColumn and somehow the second column is not positioning to the given x-coordinate. I have already gone through a lot of content available on the internet and the iTextSharp documentation for the version(5.5.13.2), that I am using …

Continue Reading

Why am I getting a null exception when trying to assign a value to a nested object in C# asp.net 5?

July 15, 2021 by Code Error

Posted By: Anonymous I am trying to assign a value to a nested object however I get a null exception. System.NullReferenceException: Object reference not set to an instance of an object. code below addingTaskScheduleDto addToReturnTask = new addingTaskScheduleDto(); userTaskDto test = new userTaskDto(); test.UserId = task.UserTasks.FirstOrDefault().UserId; test.TaskScheduleId = task.UserTasks.FirstOrDefault().TaskScheduleId; // null exception happens on the …

Continue Reading

Is it possible to register multiple consumers for a RabbitMQ queue using MassTransit?

July 14, 2021 by Code Error

Posted By: Anonymous I use awesome MassTransit (v7.1.6) with .NET to publish and consume messages with RabbitMQ To bind consumer to a specific queue I configure endpoints this way: configurator.ReceiveEndpoint( "QueueName", cfg => { cfg.ConfigureConsumer<MyConsumer>(context); cfg.ExchangeType = Direct; }); So when I start my app I see only one consumer (and one connection for it) …

Continue Reading

How do I split a string into multiple variables and remove chars not required

July 14, 2021 by Code Error

Posted By: Anonymous I have the following string, which I need to break down into 2 main usable variables. StreamTitle=’Let’s Groove – Earth Wind and Fire’;StreamUrl=’https://listenapi.planetradio.co.uk/api9/eventdata/86966431′; I need to split the string first at the point of the first ";", so we have String1 = StreamTitle=’Let’s Groove – Earth Wind and Fire’; String2 = StreamUrl=’https://listenapi.planetradio.co.uk/api9/eventdata/86966431′; …

Continue Reading

Using EF Core 3.1 SQLite database in .NET 4.7.2 class library

July 13, 2021 by Code Error

Posted By: Anonymous I have included package Microsoft.EntityFrameworkCore.Sqlite (latest 3.1.x version) in a .NET 4.7.2 Project. This is the OnConfiguring Method of my DbContext: protected override void OnConfiguring(DbContextOptionsBuilder options) { options.UseSqlite([email protected]"Data Source=D:MyDb.db"); } I reference the class library from another .NET 4.7.2 project. Whenever I try to read from, write to or create the database …

Continue Reading

FluentMigrator – how does it know which migration to execute

July 13, 2021 by Code Error

Posted By: Anonymous How does FluentMigrator know what migrations to execute / migrate when you start up the application? Example: I got two migrations already performed (1 and 2). Now I create a third migration and give it an id of 3. When I launch my application, FluentMigrator will execute the migrations, but how does …

Continue Reading

Is it possible to reinstantiate a dbcontext when using a delayed task in .net core api

July 13, 2021 by Code Error

Posted By: Anonymous I have a controller where the functionality required is to implement a call where two actions are done simultaneously, first we get input and do a call to an external application then respond to the call OK we are working on it and release the caller. When the external application responds, we …

Continue Reading

.NET 5 Console App – Handle OAuth2 Redirect URL

July 13, 2021 by Code Error

Posted By: Anonymous I’m trying to get a basic .NET 5 cross-platform console app to be able to get an oauth token through Github’s API. I’m fairly familiar with the OAuth2 flow and have implemented several websites that request and serve OAuth tokens. My issue is that I cannot figure out how to intercept/listen to …

Continue Reading

In rosyln, how to get the syntaxnode with a location given?

July 10, 2021 by Code Error

Posted By: Anonymous I am currently learning roslyn source generator. What I intend to make is a source generator that automatically implements interfaces property member when a type interit interface but corresponding members are not implemented. The automaticlly implemented members will be autoproperty by default. What I have done so far: [Generator] public class AutoImplementInterfaceGenerator …

Continue Reading

How to create a User delegation SAS key for Azure Blob access using old Microsoft.WindowsAzure .NET SDK?

July 9, 2021 by Code Error

Posted By: Anonymous I am trying to access azure blob for file uploads from .NET. I want to use user delegation SAS token here since they are considered secure. I can find many documentation for the .NET 12 library which uses the Azure.Identity and Azure.Storage namespaces. But the project I’m working on does not has …

Continue Reading

How to get rid of this problem ( On adding a nuget packages from VSCode it says terminated with exit code: 1.)?

July 9, 2021 by Code Error

Posted By: Anonymous When I trying to add Nuget Packages by Nuget gallery extension from VS Code. It doesn’t install the NuGet package. Executing task: dotnet add /home/[user]/Public/Projects/yogihosting.com/Identity/Identity/Identity.csproj package Microsoft.AspNetCore.Identity.EntityFrameworkCore -v 5.0.6 -s https://api.nuget.org/v3/index.json < Determining projects to restore… Writing /tmp/tmpIIHQRz.tmp info : Adding PackageReference for package ‘Microsoft.AspNetCore.Identity.EntityFrameworkCore’ into project ‘/home/[user]/Public/Projects/yogihosting.com/Identity/Identity/Identity.csproj’. info : Restoring packages …

Continue Reading

Lookbehind with “not character” ignores match at position 0

July 9, 2021 by Code Error

Posted By: Anonymous I am trying to achieve a regex to select (%?[fFsmhd]){1,} preceded by + and not by +. My first option was (?<=[^\]+)(%?[fFsmhd]){1,} which seems to work except that the position 1 is never matched. Test: +fFsmhd (problem here, does not match) +fFsmhd (matches) A workaround I found to this problem is to …

Continue Reading

How can i enable CORS on google cloud function .NET Core 3.1

July 9, 2021 by Code Error

Posted By: Anonymous i have function pdf set protect password service function on google cloud but i can’t call service from my react js website. because service is block by CORS my function on google cloud .NET Core 3.1 namespace SimpleHttpFunction { public class Function : IHttpFunction { private readonly ILogger _logger; public Function(ILogger<Function> logger) …

Continue Reading

model validation error message isn’t working And Returning Null

July 8, 2021 by Code Error

Posted By: Anonymous I have Model Based on DataBase and here it is //—————————————————————————— // <auto-generated> // This code was generated from a template. // // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. // </auto-generated> //—————————————————————————— …

Continue Reading

How to authenticate with private nuget package source while running dotnet restore

July 8, 2021 by Code Error

Posted By: Anonymous I am trying to run dotnet restore –configfile NuGet.config my-solution.sln on the command line to restore packages from a private nuget source but I am unable to authenticate with the private nuget and I am getting this error: Retrying ‘FindPackagesByIdAsyncCore’ for source ‘http://my.private.nuget/source/FindPackagesById()?semVerLevel=2.0.0’. Response status code does not indicate success: 401 (Unauthorized). …

Continue Reading

A custom TypeConverter for generates AddRange() in WinForms designer not working

July 8, 2021 by Code Error

Posted By: Anonymous From question: Get designer to generate AddRange for simple List property of UserControl Following TypeConverter doesn’t generate AddRange(). While I see Some Controls generate it with same code manner. Form1.designer.cs // userControl11 // this.userControl11.BackColor = System.Drawing.Color.Red; this.userControl11.Fruits.Add(new WindowsFormsApp2.Fruit(false, null)); this.userControl11.Fruits.Add(new WindowsFormsApp2.Fruit(false, null)); this.userControl11.Fruits.Add(new WindowsFormsApp2.Fruit(false, null)); this.userControl11.Fruits.Add(new WindowsFormsApp2.Fruit(false, null)); this.userControl11.Fruits.Add(new WindowsFormsApp2.Fruit(false, null)); this.userControl11.Fruits.Add(new …

Continue Reading

Adding multiple rows to a table in docx files with OpenXML

July 7, 2021 by Code Error

Posted By: Anonymous I am using TemplateEngine.Docx, Template engine for generating Word docx in Visual Studio for C#. Basically I am trying to add multiple rows to a table in an edited word document using a for loop. However when I loop through the if statement it will just rewrite the data that was just …

Continue Reading

What is the difference between TimeZoneInfo.Local and FindSystemTimeZoneById?

July 7, 2021 by Code Error

Posted By: Anonymous I know time and timezones is a difficult issue, yet I’m still confused by the following: Console.WriteLine("DST Test"); var DT = DateTime.Now; TimeZoneInfo tzi = TimeZoneInfo.Local; bool DaylightSavingTime = tzi.IsDaylightSavingTime(DT); Console.WriteLine($"Time: {DT} DST: {DaylightSavingTime} TimeZone: {TimeZoneInfo.Local.DaylightName}"); tzi = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time"); DaylightSavingTime = tzi.IsDaylightSavingTime(DT); Console.WriteLine($"Time: {DT} DST: {DaylightSavingTime} TimeZone: {TimeZoneInfo.Local.DaylightName} "); …

Continue Reading

How can I get the actual coordinates of the image when I click on the pictureBox whose size property is set to CenterImage in winForms?

July 6, 2021 by Code Error

Posted By: Anonymous The resolution of image is 4000×7000 and size of picture box is 500×600. private void pictureBoxZoom_Click(object sender, EventArgs e) { MouseEventArgs me = (MouseEventArgs)e; string message = "X=" + (image.Width * me.X / pictureBox1.Width) + ", Y=" + (image.Height * me.Y / pictureBox1.Height); MessageBox.Show(message); } Solution As the picturebox size mode property …

Continue Reading

Are EventCounters the standard way to expose metrics from .NET libraries?

July 6, 2021 by Code Error

Posted By: Anonymous Since .NET Core 3, the .NET SDK exposes metrics through the EventCounters. It is also possible to implement your own EventCounter. So let’s assume I’m developing a memcache client in .NET, would it make sense to expose get/set metrics through EventCounters? Also, I noticed that none of the Well-known EventCounters use dynamic …

Continue Reading

visual studio preview 16.11.0

July 6, 2021 by Code Error

Posted By: Anonymous I’m trying to load the NET 6 preview 4 into Visual Studio preview 16.11.0 and I don’t see an option Use preview of the .net core SDK. tool –>options–>Environment –>preview features Is it possible to use both Visual Studio 16.11 in preview and then turn it on to use the .net 6 …

Continue Reading

Can an instance creation in fixed block lead to invalid pointers or corrupt memory?

July 5, 2021 by Code Error

Posted By: Anonymous Assume an unsafe method. There is a fixed block that pins an array by the first element, i.e. fixed (void* p = &array[0]). In that block, an instance is being created by either a new keyword, or by a Marshal.PtrToStructure. Am I risking p to point to an invalid address? Will this …

Continue Reading

Validate .editorconfig file using Github Action

July 5, 2021 by Code Error

Posted By: Anonymous I want to make sure that any pull request in my Github repo follows the rules defined in .editorconfig (ASp.NET Core 5 C# project). I have found https://github.com/github/super-linter to lint the code using, I have added the below linter.yml file in my workflow, — ########################### ########################### ## Linter GitHub Actions ## ########################### …

Continue Reading

how to integrate selenium driver for chrome and Firefox in gitlab ci with dotnet blazor server for e2e tests

July 5, 2021 by Code Error

Posted By: Anonymous I want to run my e2e tests which user geckodriver and chromedriver with gitlab ci and installing before with apt commands for e2e tests within in a blazor server project. I use the following within my code: _driverChrome = new ChromeDriver(chromeOptions); _driverFirefox = new FirefoxDriver(firefoxOptions); I tried to use gitlab-selenium-server to achieve …

Continue Reading

Post request with many-to-many relation

July 4, 2021 by Code Error

Posted By: Anonymous I want to send a post request to my API that includes relations for example: { "name": "test", "description": "test", "releaseDate": "0001-01-01T00:20:40", "publisherId": 1 } Where publisherId is the foreign id. I can get this to work for one-to-many relations but not many-to-many. This is my model right now: public class Game …

Continue Reading

How can I change build tools for projects in VS Code?

June 30, 2021 by Code Error

Posted By: Anonymous I want to build a C++ code but it errors. When I check the error message it’s related with .NET. I have C# extensions but this isn’t C# and I want to change this to g++ for C++ projects. I have g++ installed and added to path however I don’t know how …

Continue Reading

Creating and maintaining same codebase (class library) with multiple assembly versions as dependency

June 29, 2021 by Code Error

Posted By: Anonymous Given following source code which need to be maintained within a class library project: using Newtonsoft.Json; namespace Zephyr.SharedProject.Core { public class TestClass { public TestClass() { string json = JsonConvert.SerializeObject(new { PropertyA = 1 }); } } } What are the options do we have if our class library need to support …

Continue Reading

Access and change a control in WPF from another window

June 29, 2021 by Code Error

Posted By: Anonymous In MainWindow.xaml I have a TextBox with a name tbName. Underneath it I have a button with an OnClickEvent. I want to set the text of a a TextBlock named welcomeRank1Tb in another window called EmployeeRank1 with the Text that has been entered in tbName Textbox. How do I access welcomeRank1Tb from …

Continue Reading

Posts navigation

  • 1
  • 2
  • 3
  • 4
  • …
  • 40
  • Next

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error