Questions tagged [c#]

C# (pronounced "see sharp") is a high level, object-oriented programming language that is designed for building a variety of applications that run on the .NET Framework (or .NET Core). C# is simple, powerful, type-safe, and object-oriented.

0
votes
0answers
3 views

How to decrease the “bounce” rate when a rigidbody hits another?

I have a racket and a ball, both have rigidbodies. Ball has a physics material in it, which has bounce set to 0.8. When I hit the ball with the racket, ball goes too high up. Setting bounce to 0.0 ...
0
votes
0answers
4 views

Why does my code complain about marshalled interface in VS2017 but not in VS2013 when intiation COMSecurity

In my current project we have a COMInterface that we intialize in the beginning of the Code. It worked fine in VS2010 and VS2013 and we haven't made any changes. I can compile and run the code from ...
0
votes
0answers
5 views

Is there a property for UserControls similar to Application.OpenForms of Forms?

I'm trying to do what's being done here but for UserControls. I want to call a method found on one of my UserControls from another form.
0
votes
0answers
14 views

How are values passed in generic methods?

According to Exam Ref 70-483: rogramming in C# by Wouter de Kort book 3th chapter test question 15 How are values passed in generic methods? I found answer: They are passed by reference But ...
0
votes
0answers
5 views

How to pass a password when using HtmlAgilityPack

I am trying to read the XML files of a website, I am using HtmlAgilityPack. This is the code I am using: HtmlWeb web = new HtmlWeb( ) ; HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack....
0
votes
0answers
8 views

C# Automatic numbering Datagridview

Is it possible in datagridview with a bindingsource when adding a new row it's copy the last cell name and put a number to it? Copy the name is not a problem but the number after the name i can't get ...
0
votes
1answer
16 views

How to get data from Select tag and Insert into Input tag using ASP.NET

Right now I have a Select Tag retrieving all the Title of the documents from the Database: string QueryString = "SELECT TITLE FROM DOC"; SqlConnection myconnection = new SqlConnection(...
0
votes
0answers
12 views

Gantt chart data visualization

I have a c# windows form application that controls the data in a MySQL database. This is the back end but I would like to display the db info on a Gantt chart that will be displayed for the employees ...
0
votes
2answers
25 views

Make Button Ignore ENTER key pressed c#

im building a page using ASP.NET, however, the first element of my page is a Button and there are other elements below it, however, if the client types something and it shows a confirmation box, and ...
0
votes
0answers
11 views

WPF MVVM - Simple Binding Button with Textbox (Icommand)

What I'm trying to do is: when the textbox contains the value "123" it should enable the button and allow me to click it. Solution Image & View Image I can not find a way to trigger the Button ...
0
votes
0answers
14 views

Issue when checking if file exists in shared drive

I am trying to find out if a file exists in a shared drive from a Windows machine in the local network. The drive can be easily mounted and accessed with my machine and it does not require credentials....
1
vote
0answers
11 views

How to instantiate method of a factorymethod pattern and and use that method in different classes?

This is my BrowserRunnerFactory.cs where I have defined to choose chrome and Firefox browser: public class BrowserRunnerFactory { public static IBrowserInterface InitiateBrowser(BrowserType ...
0
votes
1answer
15 views

Highlight text + ctrlc and get a windows notificiaton

I want that if i highlight and copy ctrl-c the following "When a computer is being assembled, which action can be taken to help eliminate cable clutter within a computer case?" WHAT DO I WANT? ...
1
vote
0answers
9 views

Quotes not updating graphics draw string per quote

I've got an issue here where if I request a quote by clicking the small blue box, it doesn't want to update the numbers in the box every quote. This is what I use to draw the string into the box. ...
0
votes
0answers
12 views

ASP.NET Core 2.1 Referring to ApplicationDbContext from Class Library

I have these 2 projects App.ClassLibrary and App.Data I followed this tutorial https://garywoodfine.com/using-ef-core-in-a-separate-class-library-project/ to move my migrations and models to App....
0
votes
0answers
4 views

Bot Framework - Luis Dialog - Set the LuisModel attribute from Web.config

I am writing a chat bot in Microsoft Bot Framework based on LUIS. (This is my first time using LUIS). I have a basic LuisDialog class where I would like to set the LuisModel attribute. The problem is, ...
-1
votes
0answers
11 views

Excel to interactive Web Application

I am looking for a way to be able to upload an excel sheet (with VBA etc.) from a local computer to the web so that users can interact with the input and see the outputs on the browser as if it was ...
0
votes
0answers
18 views

How can I streamline the LookUp command below?

I have this: public HierarquiaDto Selecionar(int id) { var query = (from p in Context.PapelContratos join g in Context.GruposCargo on new { a=p.UsuarioGrupoCargo, b=p....
1
vote
0answers
14 views

How to deal with nested quaries with a restclient in c#

I have the following code already to post a request: string requestString = "https://api.bimobject.com/search/v1/products?Bearer_token=" + AccesToken + "&filter.brand.id="+BrandID; var client = ...
0
votes
1answer
22 views

When canceling an async operation. Throw an TaskCanceledException or just return?

When canceling an async operation when should I use this (just return): if( ct.IsCancellationRequested) return; , instead of this (throw an exception): if( ct.IsCancellationRequested) throw new ...
-1
votes
0answers
22 views

How to swap DataRow in DataTable (Keep RowState) C#

I'm building a app for my company but i get a problem. I want to swap two DataRows in DataTable but don't change their state. For example: DataRow dr01 = dataTable.Rows[0]; //RowState = Added ...
0
votes
0answers
9 views

Ext.NET Token is not unique exception but I only see ID once

I have a .cshtml file where I build a large number of elements and then call ToScript on the result, which should transform it to HTML. However, I consistently get a TokenNotUniqueException on this ...
-1
votes
0answers
49 views

How to check if form is not visible (minimized)

I am using this code to check if the form is minimized: [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] protected override void WndProc(ref Message m) { ...
0
votes
1answer
14 views

ASP.NET Core using UserManager or Entity Framework to validate extended form field

I've followed the procedure to scaffold the Razor Class Library as per: Scaffold Identity in ASP.NET Core projects I've also extended my model to include a property called Office365DomainName: [...
1
vote
1answer
32 views

Get all names of property of another class - Unity 5 C#

I created this class called Genes and I want to get all it's properties inside of another script. I tried using PropertyInfo[] props = typeof(Genes).GetProperties(); but props is an empty array. I ...
0
votes
0answers
9 views

c++ CLR to bridge a c++ dll with a c# application

I am trying to follow this example: http://blogs.artinsoft.net/Mrojas/archive/2008/06/19/Log4NET-for-C++.aspx to get Log4Net running in a c++ dll. I created an empty CLR project, changed the output ...
0
votes
0answers
22 views

Inheriting base class events

I do not know if there is an answer to this - I can not seem to find examples so maybe my terminology is not right or maybe this should not be done so forgive me for asking. I have a base class with ...
0
votes
0answers
13 views

c# program gui won't build in debug mode but exe works fine

I made some changes to my c# code that compile fine, but the gui only partially displays its initial state, and it never updates the values I'm displaying despite the code underneath appearing to run ...
1
vote
0answers
14 views

Can .NET CORE CLI - load arguments from file?

I am using .net cli 2.0.3 and I was wandering if it is possible to load my arguments from file i.e. dotnet publish -args somefile Where somefile will contain the arguments which the certain command ...
1
vote
0answers
32 views

System.IO.FileNotFoundException when calling Command but reference exist

In my ResultGenerator class I am calling a command to perform a bulk insertion, the issue arises when I try to hit the command, it catches this error: Message = "Could not load file or assembly '...
0
votes
1answer
37 views

Deserialize JSON with varying properties

I have a json with varying properties like { "userFirstName":"John", "userLastName":"Doe", "userDefined-prop1":"value1", "userDefined-prop2":"value2", "userDefined-prop3":"value3" } ...
0
votes
0answers
14 views

C# UWP Download File with BackgroundDownloader in chunks

How to download a file on UWP in chunks? DownloadOperation BackgroundDownlaoder My Range : bytes=0-5242880,5242881-10485761,10485762-15728642,15728643-20971523,20971524-26214404,26214405-31457285,...
-3
votes
0answers
36 views

Update Successfully but didn't reduce my stocks, why?

When I insert the quantity I want to reduce or minus my item stocks. For example I have 10 cellphone in my inventory and they want to buy 2 pieces. So, if I minus that the answer will be 8 cellphone ...
-2
votes
0answers
12 views

SynchronizationContext + ParallelForEach deadlocks in unit test

I'm having a set of classes that, in a nutshell (and simplified) behave like the following unit test. public async Task Test() { void DoNothing() { } var disp = Dispatcher....
0
votes
2answers
28 views

How should i make use of ids in firebase database

Hi Fellow Firebase Devs! Earlier this year i got hired into a startup and we got going developing our app in xamarin and we decided to use firebase as our backend. A decision i in some ways regret as ...
0
votes
1answer
38 views

Multiple API models to C#

I have an API controller which is calling a 3rd party API, and then deserializing it via two API models to C#. I am using JsonObject and JsonProperties in the API models. Now I need to gather ...
1
vote
0answers
10 views

C# core and PowerShell Remoting should I use new-pssession or SSHConnectionInfo

I'm migrating a certain application to dotnet core that normally uses C# PowerShell code to remote to servers, respectively it is expected to be executed from a linux server rather than a Windows ...
0
votes
0answers
18 views

EF Core - updating an entity with a reference to itself tries to delete it?

In a project I am working on, we have a class Person that has two properties that are references to Person: CreatedById and UpdatedById. When I try to update a person that has CreatedById or ...
-1
votes
0answers
24 views

How to serialize or deserialize json objects without any library (including JavascriptSerializer)?

I want to serialize a json object for post json data to Rest Api. I don't use more dll like System.Web.Extensions so JavascriptSerializer class. Can i serialize or deserialize a json object without ...
0
votes
0answers
10 views

Is it possible to use a new SDK-style .csproj file for a UWP project?

Has anyone successfully created a .csproj file for a UWP project that uses the new SDK-style .csproj format? I drew inspiration from this question about WPF, and that got me 90% of the way there. ...
0
votes
0answers
14 views

When attempting to save a empty cell into a datagridview it throws exception, how can i continue after it?

I am adding data to a dataset from a datagridview with this code: try { foreach (DataGridViewRow row in newitmStockGridView.Rows) { ...
0
votes
0answers
15 views

Binding rangeslider to VM

here is a snippet of xaml I have a few RangeSliders and I would like to bind the upper and lower values to my VM. Normally I attempt like below, but this has two different values per element name, ...
0
votes
0answers
7 views

C# - NHibernate: evicting an entity and then getting it

I'm trying to understand how NHibernate works. To do so I've created a small test, given below. But the test is failing on the marked line and I don't understand why. What am I misunderstanding? To ...
0
votes
4answers
58 views

C#, Windows application, draw a square with side N

for school practice I have to make a windows application in C# that takes a input number and draws a square of X's with side N. I have to do it with a loops and i can't use any preset commands. (For ...
2
votes
0answers
18 views

Fill class with information from multiple MongoDB collections through Linq left join

I have a problem with LINQ joins in C# on a MongoDB database. Here is the class I want to fill: public class CompanyProduct { public string _id { get; set; } public string paymentId { get; ...
0
votes
0answers
15 views

“The type initializer for 'System.TimeZoneInfo' threw an exception” message when launching visual studio

While trying to launch visual studio I keep getting this message: The type initializer for 'System.TimeZoneInfo' threw an exception I tried uninstalling VS, but unfortunately it didn't help. I ...
0
votes
1answer
34 views

ASP.NET Core 2.1 Where to find database after performing migration

I have just started a new .net core project and created my first migration and updated the database locally. How can I view the table? In my previous ASP.NET MVC project, I could connect to .\...
0
votes
1answer
40 views

Performance Optimization for LINQ query in property getter

So I have a class which models a Sale made in a store. The Sale class has a List of Payment. The sale class always has a property called PointsPaid which uses LINQ to find the Sum of the payment ...
0
votes
0answers
12 views

how to force a file to save in spite of document recovery

I'm trying to go through a large number of word files (something like 40,000) (specifically .doc, so I can't use closedXML or anything that relies on the newer docx format). Some files refuse to save, ...
0
votes
0answers
16 views

Can't migrate Angular 4 project with ASP.NET Core backend to latest angular version in VS2017

I have only started working with Angular this year, and being experienced in .NET development, my backend is in ASP.NET Core. The Visual Studio 2017 template (not VS Code) worked fine for Angular 4, ...