.net 5.0 seems to be wrong in detecting zero-terminzted string
The following code: class Program { static void Main(string[] args) { const string s = "abc"; const string sz = "abc\0"; void Report(string str) =>…
There's a problem with this formula with Excel Scenarios in C#
I am using Microsoft.Interop.Excel to collect summaries from different scenarios in a specific worksheet. C# Code: using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; …
method takes any enum
hi how to get this functionality: public static void GetEnum(string txt, out Enum result) { Enum.TryParse<value.GetType()>(txt, out value); // error } thanks in advance
Binary NOT in c#
Hello I have a misunderstanding issue...if you can please help me. I get a binary number: 110 for example, in string format and I want to apply the not ~ operator and get 001. I try to convert it to sbyte or byte but for "1" I get 49.…
Windows Forms C# application - Automatically handle DPI Scaling when a user sets the display to 125% or 150%
We had designed a Windows Form application such that it is suitable for all the resolutions. We came across a situation where the applications appear to be incorrectly sized when the user chooses 125% or 150% in the machine display setting . I have set…
Use a String from a "try catch" in another "try catch"
Hello, how can I use a String inside a "try catch" outside in another "try catch"? I need the string "server_token_string". string server_token_string; try { using…
Reading big files while file may be still copying into the folder
Hi everybody, We seem to be getting an error on a regular basis at the same time. The error occurs when we try to read the file and when we check properties of that file in the Windows Explorer we can see that there are 2 dates: Creation Date and…
Why sometimes windows service app can't build dynamic assembly?
I have some server app. This app run, read some files, create C# classes, build this and load assembly. This app can work in two modes - one mode is window desktop application, and other mode - as windows service but core in dll is common. …
prevent the program from hiding the mouse cursor
I'm working on a touchpad program and i avoided mouse position changes by this code: public partial class MouseHooker { public MouseHooker() { _hookID = SetHook(_proc); } private static readonly LowLevelMouseProc _proc =…
How do I clear a remote session after publishing my C# MVC application from Visual Studio?
So I have my C# MVC application, happy with its design, I publish the application onto external servers (ionos), once I've published I've found if I create a new account or go to log into the application its like the session is still hanging around. As…
C#: Send email via SMTP
Hi all, I am attempting to develop a process that sends automated notifications via email. For development, and having a gmail account handy, I followed the instructions in this video: C# SMTP in Action : How to Send Email in C# using Gmail (Aug.…
The required column 'FirstName' was not present in the results of a 'FromSql' operation.
Hello, I have a stored proc that I'd like to return a portion of the fields that are in my model. If I don't return every field in my model, I'm getting "The required column 'FirstName' was not present in the results of a 'FromSql'…
Not able to call C# function for CosmosDb Change feed from power shell
I am able to run the below code, if I run it as a console application, Now my requirement is that InstanceTime, ProcessorName and ChangeInstance is passed as an argument from PowerShell and run this method and get the required changed documents output. I…
Best practice for handling async dispose using lock/semaphore
I have run into an issue where I have a async method that disposes of resources asynchronously. This method needs to be multithreaded as potentially it can be called at the same time depending on circumstances. Using a plain lock won't work because you…
How to create instance of Win32 COM object?
I have some legacy code that need to port over to C#. There is a COM server object written in C++ that is called by other Win32/MFC apps. I'm trying to see if I can write a C# app and create an instance of the COM object just like the other Win32/MFC…
Why does AudioPlaybackConnection keep disconnecting from Bluetooth devices in non-UWP applications?
I've created a test method in C# to connect to Bluetooth devices through the newly introduced AudioPlaybackConnection class in the WinRT API. I see that AudioPlaybackConnection is marked with the DualApiPartition attribute, so it should work in desktop…
How to use both sub-classes in C#
Hi All, I want to how to use both subclasses "InterestEarningAccount" and "LineOfCreditAccount" in the same program. TIA sub class InterestEarningAccount using System; namespace Inherit3 { public class InterestEarningAccount :…
[UWP][BLE][C#]How to identify last packet for large data in BLE Write and Notify in Win10
I have a Windows class library that uses UWP BLE APIs. The setup is: BLE Host: Win 10 laptop BLE peripheral: Win 10 laptop or Android I need to send large file (a few K to a few M) to and from peripheral (using Write/WriteWithoutResponse and Notify)…
C# Platform Invoke ADUser Constructors parameterless
Hi Developers ! I'am a newer of C#,once i want to practice how to Invoke Unmanaged code And i got the Assembly:Microsoft.ActiveDirectory.Management.dll,to practice how to use ADUser Constructors to create an abject whose properties are similar to a…
Float type in database but the number becomes different after getting to C#
In database, there is a field in "float" type. There is a record with 300.88. (correct value) After getting into DTO ("double" type), it becomes 300.87999988 After passing DTO to textbox in view, it displays 300.88 correctly. …