Questions

Why do C# struct instance methods calling instance methods on a struct field first check ecx?

Why does the X86 for the following C# method `CallViaStruct` include the `cmp` instruction? ``` struct Struct { public void NoOp() { } } struct StructDisptach { Struct m_struct; [Metho...

9 May at 21:7

Using in memory repo for data protection when running in IIS

I'm running a production server (Windows Server 2012) with an AspNet Mvc Core RC1 website. I'm seeing the following in the logs: > Neither user profile nor HKLM registry available. Using an ephemeral ...

WPF ScrollBar styles

Is it possible to create scrollbars like in this picture? [](https://i.stack.imgur.com/bVL61.png) This picture was taken from this link: [http://codesdirectory.blogspot.be/2013/01/wpf-scrollviewer-co...

8 May at 01:50

Attach StackTrace To Exception Without Throwing in C# / .NET

I have a component which handles errors using return values as opposed to standard exception handling. In addition to the error code, it also returns a stack trace of where the error has occurred. A w...

19 Apr at 11:51

How to compress multiple files in zip file

I'm trying to compress two text files to a zip file. This is how my public method looks like: ``` public ActionResult Index() { byte[] file1 = System.IO.File.ReadAllBytes(@"C:\file1.txt"); b...

7 May at 17:6

How to set asp.net Identity cookies expires time

I use Asp.Net Identity to control my app's authorization. Now, I need to do this: if the user does not operate in 30 minutes, jump to the login page, when he login does not select "isPersistent" check...

2 Apr at 22:25

Fastest way to get last significant bit position in a ulong (C#)?

What is the fastest(or at least very fast) way to get first set(1) bit position from least significant bit (LSB) to the most significant bit (MSB) in a ulong (C#)? For `ulong i = 18;` that would be ...

Cannot see the Image type in System.Drawing namespace in .NET

I'm trying to write a program that sorts images in specific folder by ther dimensions and moves little images to another folder via simple .NET console application. I decided to use System.Drawing.Ima...

6 May at 22:34

C# Double.ToString() performance issue

I have the following method to convert a double array to a `List<string>`: ``` static Dest Test(Source s) { Dest d = new Dest(); if (s.A24 != null) { double[]...

6 May at 20:37

Xamarin - Show image from base64 string

I'm pretty new to Xamarin and XAML stuff and here is what I've done so far in my portable project used by Android & iPhone (only using Android): Item.cs (loaded from JSON) ``` [JsonProperty("image")...

6 May at 19:43

Is there a way change the Controller's name in the swagger-ui page?

I'm using Swashbuckle to enable the use of swagger and swagger-ui in my WebApi project. In the following image you can see two of my controllers shown in the swagger-ui page. These are named as they ...

18 Apr at 18:6

How to call .NET methods from Excel VBA?

I found a way to call .NET 2 code directly from VBA code: ``` Dim clr As mscoree.CorRuntimeHost Set clr = New mscoree.CorRuntimeHost clr.Start Dim domain As mscorlib.AppDomain clr.GetDefaultDomain do...

12 Feb at 18:21

How to use mapper.Map inside MapperConfiguration of AutoMapper?

I need to map an object to another one using AutoMapper. The tricky question is how can I access an instance of the mapper (instance of IMapper) inside of the mapping configuration or inside of a cust...

27 Dec at 22:44

Wrong line numbers in stack trace

## The problem On our ASP .net website I keep getting wrong line numbers in stack traces of exceptions. I am talking about our live environment. There seems to be a pattern: The stack trace will a...

6 May at 13:17

XML Serialization similar to what Json.Net can do

I have the following Console application: ``` using System; using System.IO; using System.Xml.Serialization; using Newtonsoft.Json; namespace OutputApp { public class Foo { public o...

23 May at 12:23

Split a list into multiple lists at increasing sequence broken

I've a List of int and I want to create multiple List after splitting the original list when a lower or same number is found. ``` List<int> data = new List<int> { 1, 2, 1, 2, 3, 3, 1, 2, 3, 4, 1, 2,...

6 May at 12:2

Adding key values for items in picker

I am using a XAMARIN picker to select a country. The countries are hard coded in the picker. Is there a way I could identify each country name through a key value. I have done this in a similar way us...

6 May at 10:54

c#: How to Post async request and get stream with httpclient?

I need to send async request to the server and get the information from the response stream. I'm using HttpClient.GetStreamAsync(), but the server response that POST should be used. Is there a simila...

6 May at 08:7

Could not load file or assembly 'RestSharp, Version=105.2.3.0

I am having some trouble understanding this issue. I have a local project with [Twilio added via Nuget](https://www.twilio.com/docs/csharp/install). But when I export the project to my IIS server, i...

6 May at 18:39

Azure AD exception - AADSTS50105 - "The signed in user is not assigned to a role for the application"

I'm setting up authentication with Azure AD for an ASP.NET Web API 2 REST API. I'd like all clients to be able to use a username & password to authenticate with the REST API. I've setup Azure AD (fu...

6 May at 02:7

iOS background thread slow down when UI is idle

I have a Xamarin app that streams video from a remote server. I have a background thread that loops like this (pseudo-code): ``` private void UpdateMethod() { while (running) { boo...

Bad performance on Azure for Owin/IIS application

We measured some performnace tests and I noticed that the CPU is running a lot of time in kernel mode. I'd like to know why is that. : it's classic Azure Cloud service web role where Owin is listenin...

16 May at 05:40

How to change cell color with NPOI

``` using NPOI.XSSF.UserModel; using NPOI.XSSF.Model; using NPOI.HSSF.UserModel; using NPOI.HSSF.Model; using NPOI.SS.UserModel; using NPOI.SS.Util; (...) XSSFWorkbook hssfwb; using (FileStream ...

5 May at 14:35

Why use It.is<> or It.IsAny<> if I could just define a variable?

Hi I've been using moq for a while when I see this code. I have to setup a return in one of my repo. ``` mockIRole.Setup(r => r.GetSomething(It.IsAny<Guid>(), It.IsAny<Guid>(), It...

26 Sep at 23:54

UserPrincipal.FindByIdentity() always returns null

I am using LdapAuthentication to log a user into Active Directory. I want to find all the groups that the user belongs to. I am using the following code: string adPath = "LDAP://OU=HR Controlled Use...