Newest 'c#' Questions

Q&A for professional and enthusiast programmers

Value cannot be null parameter name: source even when IEnumerable in not null

I have the following models: public class Student { public int Id { get; set; } [Display(Name = "First Name")] public string FirstName { get; set; } [Display(Name = "Last Name")] ...

Use Progress Bar Instead Of Seek Bar of Media player in C#

I created a media player and I add progress Bar instead Of (windows media player) Deafult Option. When I try to open a media everything is normal and Media been played But progress bar didnt works. ...

EnvDTE - How to get a file path from a ProjectItem via the FileNames property

I'm working on a DTE Wrapper library. For full typed access on a Visual Studio solution over DTE. All works okay But now the problem: I use the method "AddFromFile" on solution folder. After add a ...

C# how to display image uploaded in html form on another page

I can do it easily with text by declaring string = this.TextBox1.Text; but cant work it out with Images Html: Image<input type='file' id ="ImgID" runat="server" onchange="readURL(this);" /> C#...

C# how do I make my label from an label array disappear when clicked on?

My code makes 5 labels appear with a random .Left location, you can see it. I want the particular label to disappear when I click on it, but I don't know how to tell it to my click void. public ...

mongo DB bson to c#

I am new to MongoDB, what I would like to do is Under property address I would like to save person's name and age, it might be one person per property or more than one, so I am trying with just name ...

Add volume to a media file

I made a program able to play mp3 files like this: class Mp3Player : IDisposable { public bool Repeat { get; set; } public Mp3Player(string fileName) { const string FORMAT = @"...

Binding ListView inside a GridView

I'd like to create a calendar week view and show some things inside. So it will have a header which is the date and additional a list of persons which have their birthday on this date. My approach was ...

Getting the the direction where the mouse is moving in Unity5 C#

I'm trying to capture where the mouse is moving specifically in the x axis. public class star_behaviour : MonoBehaviour { bool recording = false; float startx = 0.0f, endx = 0.0f; // Update is ...

How to “override” an internal class in C# for an open source project

I am trying to modify a class that I have obtained from an open source library. While I have referenced the library in my project, the original class contained references to parts of the library that ...

Multiple graphs with one main y axis in ASP.NET

I want to ask you if there is some good tool to draw some "graphs" with digital or analog values of multiple elements in real time. I will need one big main y axis with current time (or 0) on right ...

how to open excell sheet (like a database)

I, i need to open a excell sheet and get the values of collumns to a variables(list) file path(root) sheet1 collumn A ---to--> public static List myList1= new List(); collumn B ---to--> public ...

How can I seed data to already created database?

I am creating a football manager game. I have used identity 2.0 as it will work well for my registration and login. I was able to add the extra tables that were needed but now I need to seed the data ...

when i run a hello world on visual studio this error appears how can i fix it [on hold]

Server Error in '/' Application. Could not load file or assembly 'Microsoft.AI.WindowsServer' or one of its dependencies. The process cannot access the file because it is being used by another ...

Unable to retrieve data from UserControl after postback

I have a page that stores dynamically created UserControls, now when I am trying to retrieve the data from the UserControls by clicking a button, nothing happens. How do I fix it? I tried to use ...

ASP.NET Entity Framework issue: one-to-one, two objects mapping to same table

My ASP.NET MVC (.NET Core Framework 1.0) code consists of two models: public class BusLine { public int Id { get; set; } [Column(Order = 0), ForeignKey("RouteA")] public int RouteAId { ...

C# models diagram

I am looking for a tool like mssql workbench where I can draw my database diagram, but for mssql instead. I am programming in asp.net core and would like to have the tool auto generate a diagram based ...

There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key “Geslacht”

First of all, I'm a beginner in what concerns C#, Razor, ASP.NET... I want to make a 'DropDownListFor' for the genders with a 'List' but the problem is that I get the errormessage as described in the ...

Controls all stuck in top left corner when I debug my VS for Mac iOS app

I've been working through the introductory Hello, iOS project in VS for Mac, and I believe I've done everything according to the instructions. The layout of my storyboard looks fine, however when I ...

C# Run programs and get environment variables after they run

I have two batch scripts I am trying to run using c#, and then see how they affect the environment. The code I have is string finalEnvVarsFile = Path.GetTempFileName(); string arguments = string....

JSON Deserialization - String Is Automatically Converted To Int

When I deseiralize the JSON to the C# object below, either using Newtonsoft explicitly or via the model binding mechanism of ASP.NET Web Api, the string id value is automatically converted to int. I ...

Xamarin.Android HTTP Random Delays

I have a method that executes several HTTP requests called LoadServers() A button that executes LoadServers(). For my issue I only tap the button once the previous LoadServers() call has finished. A ...

C# callback on new process created?

I want for my callbackMethod() to run whenever a certain new external process is created. I was looking at the WMI apis, I have read to some extent I can attach an event handler whenever a process ...

Can't load website in CefSharp

I'm trying to load a website URL using RegisterJsObject in one of two cefsharp instances. The URL is received from the website (chromeBrowser1) however It wont update the window (chromeBrowser2). I ...

Symmetric difference of bytes in files

I have dumped binary files (all of the same length) about certain entities which are part of one, and only one, of two categories. Fortunately I know exactly which file belongs to which category. I ...

Elgato HD not showing in Devices list with DirectShow.GetDevicesOfCat

I'm trying to get content from a capturing device the Elgate HD. Using C# with the DirectShow Lib, calling DsDevice.GetDevicesOfCat(DirectShowLib.FilterCategory.KSAudioDevice); does not give me the ...

Auto-updating GPS location

I was using Unity's GPS System and noticed that it never updated. I had to close the app and launch it again in order to get my current position. using UnityEngine; using UnityEngine.UI; using System....

C# How to check a Listbox for a string + object?

I'm trying to search for a certain number(object) in a listbox wich comes together with a string in order to highlight it. In the following bit of code i override a ToString() method to contain all my ...

sarsa and q-learning in reinforcement learning

I having some trouble understanding the deference between qlearning and sarsa and the meaning of in policy and off policy is this mean that q learning have to take the max for all next possible ...

Change thread priority - Unity 3d

So I am using threading in my application. I wanted to benchmark parts of my code, and I saw that the code runs significantly faster on the main thread - 2-3 times faster. I wanted to tweak the ...

ScrollView does not work inside a dynamically created element

I need to create some FrameworkElements dinamically. I have a StackPanel, and I create inside of it a Pivot, with one PivotItem, and inside a ScrollViewer with a StackPanel and Buttons, like this: ...

How to emit a Type in .NET Core

In C#, how do I emit a new Type at runtime with .NET Core? All of the examples I can find for .NET 6 don't seem to work in .NET core (they all begin with getting the current AppDomain, which doesn't ...

How to get the Key of an item in the array of dictionary based on its value?

The following method print this: Minimum Temperature is 16 Maximum Temperature is 27 The Average Temperature is 22 Now I want in addition to temperatures I also have the days in which the ...

WaveOut stuttering while another media is playing in another environment

I am working on streaming mp3 in real time using NAudio library. I have prepared a code to do it and it works good in general except while another media is playing in another process (e.g. Youtube, ...

ObservableCollection doesn't update ListView

My ObservableCollection list doesn't update view. I use MVVM Light This is my VM public class MainViewModel : ViewModelBase{ public ObservableCollection<ProductModel> Products { get; set; } ...

What is the proper method for assigning multiple hierarchicalDataTemplates to a TreeView ItemTemplate?

I have three XML HierarchicalDataTemplates. They are loaded at runtime and then assigned to the TreeView.ItemTemplate. This is the code that I used, successfully, about six years ago on a similar ...

My 2D array won't work?

Please check why my code is not working.Everything seems to be fine but it does not work. #include<iostream> using namespace std; int main() { char display[7][4]={{1,A,B,C,D}, ...

How can I print out the first in list? [duplicate]

I am new here. I a question about a list. How can i print out the first in the list? if (element.Contains(keyword)) { foreach (string s in item) { Console.WriteLine(s); }

ASP.NET MVC Passing a List of Lists to the ViewBag

I have an Entity with a definition of: public class Skill { public enum Level { Begginer, Intermediate, Advanced } public int Id { get; set; } [Display(Name ="Skill Group")] public ...

C# Generics, is this where constraint possible?

I have quite strange scenario in my .NET Core application. I'm providing zip with test case solution, because there is lot of inheritance hard to compile in brain. enter link description here The ...

XML Builder using Azure / DocumentDB

I'd like to build an app and host in Azure using DocumentDB to see how it works. The app allows a user to select a template from a list. This template is simply a list of data such as detail1 ...

check user is joined channel or not telegram bot?

how to check a user is in my channel or not with C# and Telegram.Bot nuget package? look like XO game bot(First check user is in channel or not.if user is in channel bot running,or if not join in ...

T4 Template - Add Extra View output to MVCView

I have added the CodeTemplates to my ASP.NET MVC Project in VS2015. There I changed in MvcControllerWithContext the Controller.cs.t4 file. This works very good as i have tested it, changed also the ...

Take all .mp3 files from a device

I am trying to build kind of a music player but I want it to be "mobile" like... what I mean by that is when you first open the app to already have stored all your songs and display them in a nice way....

How to make a login window in Unity

I am new at C# and can't get my username and password program to work. I need to get the inputs from the user and check it against the account details which I've stored in a dictionary. using ...

How can I insert 2 or 3 rows to the same table using linq

I try to insert in my table Days 2 or 3 entities like "day Saturday Group A" and "day Monday Same Group A" and "Friday Same group A" using (db = new DataClasses1DataContext()) { List<...

The UPDATE statement conflicted with the FOREIGN KEY constraint error?

When I try to update a user profile in my app i get the following error: The UPDATE statement conflicted with the FOREIGN KEY constraint "FK_dbo.UserDetails_dbo.Companies_CompanyId". The conflict ...

Setting formBorderStyle to None fails with error FormBorderStyle is used as a variable

System.Windows.Forms.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; WindowState = System.Windows.WindowState.Maximized; I am trying to set the FormBorderStyle to None (to get fullscreen)...

Login screen using asp.net and SQL Server

I am trying to create a login page but but my Login button does not work. I am selecting username and password from my sql server database. Unfortuantely I am getting an error "System.Data.SqlClient....

Configure Oracle .Net Framework Data Provider for NPoco

NPoco should work for Oracle database out of the box. But when I try to create the Database object it says it cannot find the .Net Framework Data provider: _db = new Database("...
Translating... 0%