Microsoft Q&A

C#

6,934 questions

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

Browse all C# tags

6,934 questions with C#-related tags

Sort by: Updated
0 answers

Accessing the Windows.Services.Store store in a C# Forms application.

I have been unable for days to get this line recognized in a C# Forms application. I've searched the web and looked at sample code. private Windows.Services.Store.StoreContext _context = null; I get: Error CS0234 The type or namespace name…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
asked 2023-01-30T03:52:46.18+00:00
technoway 201 Reputation points
edited a comment 2023-01-30T08:57:02.9233333+00:00
technoway 201 Reputation points
1 answer

filter & save to xml function doesnt work viewmodel

Hello Morning: First i read xml file to fill the datagrid edit, save the xml file, then export the datagrid to excel file using OpenXML, then read the excel file to fille the datagrid. When i jsut read the xml file, i can filter the datagrid and edit…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,172 questions
asked 2023-01-23T15:35:49.1233333+00:00
Kran2022 241 Reputation points
edited the question 2023-01-30T08:54:17.41+00:00
Kran2022 241 Reputation points
1 answer

Intent Filter / DeepLink .Net MAUI

I want to implement an application that will be viewable in my application using Intent Filter. I added in the MainActivity.cs file Filter Intent [IntentFilter(new[] { Intent.ActionView }, Categories = new[] { Intent.ActionView, Intent.CategoryDefault,…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
885 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
609 questions
asked 2023-01-19T14:47:27.51+00:00
Влад Тигинян 0 Reputation points
commented 2023-01-30T08:47:31.04+00:00
Leon Lu (Shanghai Wicresoft Co,.Ltd.) 41,411 Reputation points Microsoft Employee
0 answers

Change InkDrawingAttributes Opacity for Pen brush

I using a color picker to draw with a pen, but using this code I can't change de opacity of the pen color: InkDrawingAttributes inkDrawingAttributes = InkCanvas.InkPresenter.CopyDefaultDrawingAttributes(); inkDrawingAttributes.Color =…

Universal Windows Platform (UWP)
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
556 questions
asked 2023-01-26T14:51:19.3+00:00
Anderson Cavalcante 21 Reputation points
commented 2023-01-30T08:46:16.1333333+00:00
Roy Li - MSFT 26,391 Reputation points Microsoft Employee
0 answers

Why is the combo box cursor/caret moves to the beginning when down arrow is hit?

In my app I have a combo box <ComboBox ItemsSource="{Binding ComboItems}" SelectedItem="{Binding SelectedCBItem}" StaysOpenOnEdit="True" Text="{Binding SelectedCBItem,…

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,172 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
asked 2023-01-23T05:18:53.03+00:00
don bradman 371 Reputation points
commented 2023-01-30T08:42:46.02+00:00
Hui Liu-MSFT 14,561 Reputation points Microsoft Employee
1 answer

WPF Mousemove is a noticeable lag

I am making a UserControl called VolumeScrollBar to control the volume a video player I am working on. Now the problem I am having is when I slide my SwitchPath it moves noticeable slower than my mouse. How can I fix this ? note: everything is working…

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,172 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
asked 2023-01-29T06:16:37.1733333+00:00
Brandon Boone 1 Reputation point
commented 2023-01-30T08:33:03.29+00:00
soren60 81 Reputation points
1 answer

Shell Navigation and using a Dictionary to pass values.

I am trying to learn how to pass complex data types to a page using a Dictionary. As you can see in the example code below that Name was hardcoded, but I was wondering what is the best practice if I wanted to dynamically set the Name property in the view…

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
885 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
asked 2023-01-27T15:01:59.6933333+00:00
Ronald Rex 506 Reputation points
answered 2023-01-30T08:15:55.4533333+00:00
Leon Lu (Shanghai Wicresoft Co,.Ltd.) 41,411 Reputation points Microsoft Employee
3 answers

how to write a 3layers winform applications in c#?

hi every body i am noob in c# and programming and i really care to code right and learn c# programming very correctly. so at first I want to write a 3 layers win form applications that read and write data into a table in sql server. for this project I…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
asked 2023-01-25T15:43:48.5766667+00:00
Farshad Valizade 21 Reputation points
commented 2023-01-30T08:13:52.68+00:00
Hui Liu-MSFT 14,561 Reputation points Microsoft Employee
0 answers

UWP CreateOutputReport failed to create report ID

The following code has an error, System. Exception: "The data is invalid. The specified report type is not present. What is the reason? Error statement: var outputReport = hiddevice.CreateOutputReport(0);  The handle was opened, but the output…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
Universal Windows Platform (UWP)
asked 2023-01-13T03:54:22.5666667+00:00
yu chen 0 Reputation points
commented 2023-01-30T07:55:38.04+00:00
yu chen 0 Reputation points
2 answers

Displaying Deserialized JSON Data In Razor Page

Hello Everyone, I am using Visual Studio 2022 (x64) Community Version Entity Framework Core 6 C# Razor Pages (Not MVC) I am pulling data from the Google YouTube API, and want to display it on a .cshtml page. Here is a sample of the data: { …

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,536 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
2,399 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
146 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
1,182 questions
asked 2023-01-30T02:39:33.7466667+00:00
Brian Ashcraft 0 Reputation points
answered 2023-01-30T07:49:22.8533333+00:00
Zhi Lv - MSFT 18,541 Reputation points Microsoft Employee
1 answer One of the answers was accepted by the question author.

How to marshal an array of fixed size structs from unmanaged to managed memory

.Net 7 Having an IntPtr (nint) pointing to an array of fixed size and blittable structs in unmanaged memory. Marshal.Copy does not seem to have any method like: Copy(myPointer, myStrcuctArray, 0, myStructArray.Length) (It accepts an array of int,…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: The period of time during which a program is being executed in a computer.
956 questions
asked 2023-01-29T21:43:46.12+00:00
Magne 96 Reputation points
accepted 2023-01-30T07:33:53.36+00:00
Magne 96 Reputation points
2 answers

How to use C# Linq to find average value of a double list.

Hello: I have the following data: List<double[]> asks = new(); var ask1 = new[] { 4.0, 4.0 }; var ask2 = new[] { 5.0, 5.0 }; asks.Add(ask1); asks.Add(ask2); List<double[]> bids = new(); var bid1 = new[] { 3.0, 3.0 }; var bid2 = new[] { 2.0,…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
asked 2023-01-23T20:40:50.73+00:00
john zyd 406 Reputation points
commented 2023-01-30T06:49:24.0466667+00:00
Jack J Jun 19,046 Reputation points Microsoft Employee
2 answers

Performance issues - Sql Server 2022 Standard Edition

Hi, I've been using SQL Server 2014 express to store data and interact with my C# applications on Windows 10 for different years. I wanted to do some test with Sql Server 2022 before upgrading to that version so I've installed the Evaluation Edition (all…

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
2,399 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
8,484 questions
asked 2023-01-27T14:01:43.71+00:00
Leonardo Azzari 0 Reputation points
answered 2023-01-30T06:41:26.8466667+00:00
CosmogHong-MSFT 6,616 Reputation points Microsoft Employee
1 answer One of the answers was accepted by the question author.

How to clear text box records before or after downloading a file in ASP.NET web application

using (FileStream fs = File.Create(dataDir + xmlFileToConvertTo)) { Byte[] info = new UTF8Encoding(true).GetBytes(xmlData); fs.Write(info, 0, info.Length); …

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
ASP.NET Web Forms
ASP.NET Web Forms
A part of the ASP.NET web application framework that can be used to create ASP.NET web applications.
397 questions
asked 2023-01-26T04:58:36.0633333+00:00
Roefatin, Ridzuan 20 Reputation points
commented 2023-01-30T06:35:22.47+00:00
XuDong Peng-MSFT 4,571 Reputation points Microsoft Employee
0 answers

Model is always null on Razor page

hello All, I have the following code on my cshtml page: @if (Model!=null && Model.EmergencyInfos!=null && Model.EmergencyInfos.ToList().Count>0) { var count = Model.EmergencyInfos.Count; @for…

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,536 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
ASP.NET MVC
ASP.NET MVC
A Microsoft web application framework that implements the model-view-controller (MVC) design pattern.
588 questions
asked 2023-01-30T05:11:54.52+00:00
Anjali Agarwal 81 Reputation points
commented 2023-01-30T06:26:38.4+00:00
Zhi Lv - MSFT 18,541 Reputation points Microsoft Employee
1 answer

using FileSystem.OpenAppPackageFileAsyn to open and play mp3 files stored on Google Drive

Hi I am using VS 2022 and C# to develop a MAUI App which needs to be deployed for IOS/Android and Windows. I would like to play audio files that are stored on Google Drive using audioPlayer. Can I use FileSystem.OpenAppPackageFileAsyn to open the file,…

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
885 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
asked 2023-01-22T22:11:13.7033333+00:00
Riffy 206 Reputation points
commented 2023-01-30T05:30:46.5266667+00:00
Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 11,061 Reputation points Microsoft Employee
1 answer

401 Unauthorized when Granting access via Azure AD App-Only

I followed this article but I modified the sample code a bit to use GetContextAsync instead of GetAzureADAppOnlyAuthenticatedContext AuthenticationManager authManager = new AuthenticationManager(clientId, certPath,certPassword,tenantId); using…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
5,989 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
1,666 questions
asked 2023-01-25T03:58:59.3433333+00:00
Jack Le 0 Reputation points
edited the question 2023-01-30T04:41:15.46+00:00
Shweta Mathur 11,076 Reputation points Microsoft Employee
0 answers

How to System.BadImageFormatException (No string associated with token) error solved

Our Web Application build in .NET 4.8 and hosted as an azure app service throws this exception in some views. Here is the stack trace for one of these exceptions. We have run out of options to try certain things but it is stuck like that. We have tried…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: The period of time during which a program is being executed in a computer.
956 questions
ASP.NET MVC
ASP.NET MVC
A Microsoft web application framework that implements the model-view-controller (MVC) design pattern.
588 questions
Internet Information Services
asked 2023-01-28T13:47:57.62+00:00
Tabish Ashraf 0 Reputation points
edited the question 2023-01-30T03:46:09.9833333+00:00
AjayBathini-MSFT 0 Reputation points Microsoft Employee
3 answers

Problem querying JSON using LINQ when there are semicolons in the name tag

I'm trying to work with a Json file from an outside source. They put semicolons and additional data in some the field names. I'm trying to query the data using LINQ and having problems. Is there a way of specifying wildcards in LINQ queries? I'm…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
asked 2023-01-27T09:11:06.9366667+00:00
Richard Rosenheim 1 Reputation point
answered 2023-01-30T03:05:09.28+00:00
Jack J Jun 19,046 Reputation points Microsoft Employee
3 answers

after running code , this error show i am using window 10, C#, Asp.net, Bootstrap, JavaScript, Html lang

ASP.NET Web Forms
ASP.NET Web Forms
A part of the ASP.NET web application framework that can be used to create ASP.NET web applications.
397 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,934 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
444 questions
asked 2023-01-24T09:23:53.4466667+00:00
Rupa Kumari 0 Reputation points
commented 2023-01-30T02:47:04.53+00:00
QiYou-MSFT 851 Reputation points Microsoft Employee