No connection could be made because the target machine actively refused it?

If this happens always, it literally means that the machine exists but that it has no services listening on the specified port, or there is a firewall stopping you. If it happens occasionally – you used the word “sometimes” – and retrying succeeds, it is likely because the server has a full ‘backlog’. When you … Read more

Enum Naming Convention – Plural

Microsoft recommends using singular for Enums unless the Enum represents bit fields (use the FlagsAttribute as well). See Enumeration Type Naming Conventions (a subset of Microsoft’s Naming Guidelines). To respond to your clarification, I see nothing wrong with either of the following: public enum OrderStatus { Pending, Fulfilled, Error }; public class SomeClass { public … Read more

Convert.ChangeType() fails on Nullable Types

Untested, but maybe something like this will work: string modelProperty = “Some Property Name”; string value = “Some Value”; var property = entity.GetType().GetProperty(modelProperty); if (property != null) { Type t = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType; object safeValue = (value == null) ? null : Convert.ChangeType(value, t); property.SetValue(entity, safeValue, null); }

If async-await doesn’t create any additional threads, then how does it make applications responsive?

Actually, async/await is not that magical. The full topic is quite broad but for a quick yet complete enough answer to your question I think we can manage. Let’s tackle a simple button click event in a Windows Forms application: public async void button1_Click(object sender, EventArgs e) { Console.WriteLine(“before awaiting”); await GetSomethingAsync(); Console.WriteLine(“after awaiting”); } … Read more

How do I get formatted JSON in .NET using C#?

You are going to have a hard time accomplishing this with JavaScriptSerializer. Try JSON.Net. With minor modifications from JSON.Net example using System; using Newtonsoft.Json; namespace JsonPrettyPrint { internal class Program { private static void Main(string[] args) { Product product = new Product { Name = “Apple”, Expiry = new DateTime(2008, 12, 28), Price = 3.99M, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)