Visual Studio serialization error when T4 uses DTE to open generated file

We have a C# T4 file named GenerateProxies.tt which calls several command-line codegen utilities. Using the System.Diagnostics Process class, we redirect the standard output to the T4 output text file...

5 May at 13:38

Entity framework query on just added but not saved values

I'm using Entity Framework from a couple of years and I have a little problem now. I add an entity to my table, with ``` Entities.dbContext.MyTable.Add(obj1); ``` and here ok. Then, I'd like to m...

7 Dec at 07:25

What are the differences between Decorator, Wrapper and Adapter patterns?

I feel like I've been using these pattern families quite many times, however, for me it's hard to see the differences as their are quite similar. Basicaly it seems like all of them is about another ...

6 Dec at 13:0

Get relative Path of a file C#

I currently writing a project in visual studio in c#. the project full path is: ``` "C:\TFS\MySolution\" ``` I have a file that I need to load during the execution. lets say the file path is ``` "...

7 Sep at 13:8

How long Cookies last, which return with JsonServiceClient Request

I am working with Xamarin-Forms application.To authenticate user I use ServiceStack CredentialAuthProvider.When authentication successfully done I got cookieContainer in response.I want to know how lo...

How to get authenticated user's name, IP address, and the controller action being called from an HTTP Filter?

I'm trying to audit my action events on the controller. I want to keep track of authenticated user's name, his IP address, and controller action being called. My filter code: ```csharp public c...

3 May at 05:13

C# 6.0 multiple identical null conditional operator checks vs single traditional check

Which out of the following two equivalent ways would be best for the null conditional operator in terms of primarily performance and then ease of use or clarity etc.? This: ``` idString = child?.Id;...

6 Dec at 12:22

How to import CSV file with white-space in header with ServiceStack.Text

I am using ServiceStack.Text library for reading from CSV files in C#. I would like to know how to deserialize CSV to objects where CSV contains white space separated header ? I am using this code...

6 Dec at 06:31

Implementing recursive property loading in EF Core

I'm on .NET Core 1.1.0, EF Core 1.1.0, VS 2015. I'm writing a system for posts/comments, and I need a function to load a comment and all of its children and their associated properties. Here's a simpl...

Does SemaphoreSlim (.NET) prevent same thread from entering block?

I have read the docs for SemaphoreSlim [SemaphoreSlim MSDN](https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k(System.Threading.SemaphoreSlim);k(TargetFrameworkMoniker-.NETFrame...

Visual studio code auto-complete

I have just downloaded unity and saw that now it supports Visual studio code, I downloaded it and made it the default editor. After trying to edit a script, it prompted me to download c# extension an...

Invalid Hyperlink: Malformed URI is embedded as a hyperlink in the document

I'm using the OpenXml namespace in my application. I'm using this to read the XML within an Excel file. This works fine with certain excel files but on others I get a run time error saying > Invalid...

6 Dec at 09:3

IQueryable does not contain definition for GetAwaiter

I'm using WebAPI in entity framework to create a new endpoint and I am having some issues. I'm trying to use a Linq Where statement to get my data, but I'm receiving the following error. > 'IQueryab...

5 Dec at 19:1

Unable to load type from assembly (C# Amazon lambda function)

Since Amazon now supports C# to build AWS Lambda functions, i wanted to give it a try, but i get stuck when performing a test. This is my simple class: ``` using System; using System.IO; using Syste...

Visual Studio 2017 unable to load project

I'm trying to load my VS2015 project into the newly installed VS2017RC but it keeps giving me the error (when loading or reloading): > Object reference not set to an instance of an object. It also...

How to update values into appsetting.json?

I am using the `IOptions` pattern as described [in the official documentation](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration#using-options-and-configuration-objects). This ...

3 Feb at 17:57

What is the best way to save game state?

I find the best way to save game data in Unity3D Game engine. At first, I serialize objects using `BinaryFormatter`. But I heard this way has some issues and is not suitable for save. So, What is the...

16 Sep at 09:56

An error occurred attempting to determine the process id of dotnet.exe which is hosting your application. One or more error occured

I have clone the project from source url. My friend has developed the asp.net core web application using .NetCore 1.0.0-preview2-003121 sdk. However on my pc I have install .NetCore 1.0.1-preview2-003...

19 Mar at 15:28

My C# program is detected as a virus?

I have created a C# program and I recently noticed that when I merge my referenced .dlls into one executable .exe file using IL Merge, my Anti Virus (Avast) immediately deletes it and says that it's a...

4 Dec at 15:48

How to generate class diagram from models in EF Core?

We are building an application using ASP.NET MVC Core and Entity Framework Core and we have the whole bunch of classes in our application. In previous versions of Entity Framework, we would use this m...

4 Dec at 07:10

Define a column as nullable in System.Data.DataTable

I need to define a `System.Data.DataTable` in C# VS2013; in one column, it may be int or null. But I got: > DataSet does not support System.Nullable<>. For the definition: ``` public DataTable myDataT...

10 Jun at 07:37

IMemoryCache Dependency Injection outside controllers

I have an ASP.NET Core MVC Project with an API. I then have a Class Library in the same solution named My API calls a repository method inside the Class Library Infrastructure, in the class `UserRe...

3 Dec at 11:32

Injecting multiple implementations with Dependency injection

I'm currently working on a ASP.NET Core Project and want to use the built-in Dependency Injection (DI) functionality. Well, I started with an interface: ``` ICar { string Drive(); } ``` and wa...

Local function vs Lambda C# 7.0

I am looking at the new implementations in [C# 7.0](https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/) and I find it interesting that they have implemented local functions bu...

4 Jun at 09:8

OrmLite is not recognizing Unicode in JSON field

Ormlite doesn't seem to recognize unicode strings (Arabic) that are stored inside the new 'json' field in MySql. I'm using MySql 5.7 engine .. Arabic is working for all other fields .. stored correctl...