Questions

Why is my api key null with ServiceStack ApiKeyAuthProvider?

Here is my Auth config: ``` container.Register<IAuthRepository>(c => new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>())); container.Resolve<IAuthRepository>().InitSchema(); Plugins.Add(new ...

1 Dec at 16:51

Reflection - Call constructor with parameters

I read type from loaded assemblies for example: ``` var someType = loadedAssemblies .Where(a => a != null && a.FullName.StartsWith("MY.")) .SelectMany(a => a.GetTypes()) ...

1 Dec at 15:56

How can I change the JSON date serialization format for as single service in ServiceStack 3?

I have a number of legacy services in a ServiceStack 3 based middleware application which use the default date serialization format for JSON. The issue is that this is not human readable for debuggin...

1 Dec at 14:51

Xamarin Forms Button Command binding inside a ListView

I have the following problem, in my view I have a Listview. In this listview I would like to have two buttons. One for editing the item, one to delete it. ``` <ListView Grid.Row="1" x:Name="Arbeits...

1 Dec at 14:41

Can System.Web be used with ASP.Net Core with Full Framework

We are running serveral sites based on different .Net versions. One of the sites is running .Net 4.6 and ASP.Net MVC 5.xx To use the new syntax for Razor we want to upgrade this site to use .Net 4...

Return View as String in .NET Core

I found some article how to return view to string in ASP.NET, but could not covert any to be able to run it with .NET Core ``` public static string RenderViewToString(this Controller controller, stri...

Render Html code with razor

I've searched over this website and I've looked over similar questions and i did not find the answer, I am sure it is somewhere but i did not find it, I have a string like this one for example : ``` ...

1 Dec at 23:21

Using Gzip to compress/decompress an array of bytes

I need to compress an array of bytes. So I wrote this snippet : ``` class Program { static void Main() { var test = "foo bar baz"; var compressed = Compre...

1 Dec at 11:13

ASP.NET Core CORS WebAPI: no Access-Control-Allow-Origin header

I have deployed my ASP.NET Core web API to Azure, and I can access its endpoints using Swagger or a web debugger like Fiddler. In both cases (same origin in Swagger, different origin using Fiddler fro...

23 May at 10:31

Entity framework automatically renaming many-to-many tables without any changes

I've been working in the same project for almost 1½ year and today when I wanted to add a change to the db (code first). All of the sudden EF migration wants to rename a lot of the many-to-many tables...

Why is infinity printed as "8" in the Windows 10 console?

I was testing what was returned from division including zeroes i.e. `0/1`, `1/0` and `0/0`. For this I used something similar to the following: ``` Console.WriteLine(1d / 0d); ``` However this code...

1 Dec at 16:11

C# 7.0 "deconstructor"

I'm reading about [C# 7.0 new stuff](https://msdn.microsoft.com/magazine/mt790184?MC=Vstudio&MC=.NET&MC=MSAzure&MC=CSHARP&MC=DevOps), and I cannot grok, at least from the example given, what would be ...

1 Dec at 12:6

Where's the NuGet package location in ASP.NET Core?

I'm new to ASP.NET Core, and am trying to figure out where NuGet packages are stored on my local machine. I've installed the following NuGet packages: ``` nuget dapper nuget MicroOrm.Pocos.SqlGener...

ServiceStack Route using array as parameters

I need to create this `URL` for request using `ServiceStack`, but I couldn't find a way to generate this as `URL` route: [http://server.com/myserver?service=2&item[0].reference=222&item[1].reference=...

Dependency Injection error: Unable to resolve service for type while attempting to activate, while class is registered

I created an .NET Core MVC application and use Dependency Injection and Repository Pattern to inject a repository to my controller. However, I am getting an error: > InvalidOperationException: Unable ...

Does C# 7 allow to deconstruct tuples in linq expressions

I'm trying to deconstruct a tuple inside a Linq expression ``` // somewhere inside another method var result = from word in words let (original, translation) = Convert(word) ...

9 Sep at 13:33

DateTime.Now retrieval speed

Is there any chance that this statement would return true DateTime.Now == DateTime.Now can a very fast machine return true for this statement, I tried on several machines and its always false ?

5 May at 14:15

ASP.NET add migration 'composite primary key error' how to use fluent API

Hello I am in the process of creating a Web Application and have already installed both the and . During the process of executing an add-migration in the package manager console I get an error "" ...

Object reference not set to an instance of an object when trying to log service exceptions servicestack

I'm getting the following message: > Object reference not set to an instance of an object When trying to log the exceptions thrown by the service, I'm using the following service exception handler i...

30 Nov at 19:48

'List' does not contain a definition for 'Where'

I am trying to create a method where I can pass a `Linq` expression as a parameter to return a new list of items. Currently I am doing this ([based off this answer](https://stackoverflow.com/question...

23 May at 12:24

Support SQL Server change tracking with Entity Framework 6

I have an Entity Framework 6 Code First model generated from an existing SQL Server database. The database is using SQL Server Change Tracking, so for all the data manipulation operations generating f...

Multiple controllers with same URL routes but different HTTP methods

I've got a following two controllers: ``` [RoutePrefix("/some-resources") class CreationController : ApiController { [HttpPost, Route] public ... CreateResource(CreateData input) { ...

.NET Core and System.Drawing

I am trying to reference System.Drawing in a .net core console app targeting net46 but the assembly is not there. According to MS if you use dotnetcore System.Drawing is not available. But if you refe...

20 Oct at 15:19

Xamarin.Forms.Color to hex value

I have a Xamarin.Forms.Color and I want to convert it to a 'hex value'. So far, I haven't found a solution to my problem. My code is as follows: ``` foreach (var cell in Grid.Children) { var pixel...

18 Aug at 18:56

Windows Defender Antivirus scan from C# [AccessViolation exception]

We are writing a code to do on-demand scan of a file from C# using Windows Defender APIs. ``` [DllImport(@"C:\Program Files\Windows Defender\MpClient.dll")] public static extern int WDStatus(...