Change C++/CLI project to another framework than 4.0 with vs2010

This shows up when you press F1 in the Framework and References dialog: By default for new projects, the targeted framework is set to .NET Framework 4. The IDE does not support modifying the targeted framework, but you can change it manually. In the project file (.vcxproj), the default targeted framework is represented by the … Read more

How do I check if a property exists on a dynamic anonymous type in c#?

public static bool DoesPropertyExist(dynamic settings, string name) { if (settings is ExpandoObject) return ((IDictionary<string, object>)settings).ContainsKey(name); return settings.GetType().GetProperty(name) != null; } var settings = new {Filename = @”c:\temp\q.txt”}; Console.WriteLine(DoesPropertyExist(settings, “Filename”)); Console.WriteLine(DoesPropertyExist(settings, “Size”)); Output: True False

Co-variant array conversion from x to y may cause run-time exception

What it means is this Control[] controls = new LinkLabel[10]; // compile time legal controls[0] = new TextBox(); // compile time legal, runtime exception And in more general terms string[] array = new string[10]; object[] objs = array; // legal at compile time objs[0] = new Foo(); // again legal, with runtime exception In C#, … Read more

No generic implementation of OrderedDictionary?

Implementing a generic OrderedDictionary isn’t terribly difficult, but it’s unnecessarily time consuming and frankly this class is a huge oversight on Microsoft’s part. There are multiple ways of implementing this, but I chose to use a KeyedCollection for my internal storage. I also chose to implement various methods for sorting the way that List<T> does … Read more

How can I get a web site’s favicon?

You’ll want to tackle this a few ways: Look for the favicon.ico at the root of the domain www.domain.com/favicon.ico Look for a <link> tag with the rel=”shortcut icon” attribute <link rel=”shortcut icon” href=”https://stackoverflow.com/favicon.ico” /> Look for a <link> tag with the rel=”icon” attribute <link rel=”icon” href=”https://stackoverflow.com/favicon.png” /> The latter two will usually yield a higher … Read more

Cleaner way to do a null check in C#? [duplicate]

In a generic way, you may use an expression tree and check with an extension method: if (!person.IsNull(p => p.contact.address.city)) { //Nothing is null } Full code: public class IsNullVisitor : ExpressionVisitor { public bool IsNull { get; private set; } public object CurrentObject { get; set; } protected override Expression VisitMember(MemberExpression node) { base.VisitMember(node); … Read more

How do I run msbuild from the command line using Windows SDK 7.1?

To enable msbuild in Command Prompt, you simply have to add the directory of the msbuild.exe install on your machine to the PATH environment variable. You can access the environment variables by: Right clicking on Computer Click Properties Then click Advanced system settings on the left navigation bar On the next dialog box click Environment … Read more

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