How do I run Visual Studio as an administrator by default?

Copied and pasted from here, the Using Advanced Properties section. This will allow you to always have the program run as an administrator when you open it. Right click on the shortcut of the program, then click on Properties. Click on the Shortcut tab for a program shortcut, then click on the Advanced button. Check … Read more

LINQ: When to use SingleOrDefault vs. FirstOrDefault() with filtering criteria

If your result set returns 0 records: SingleOrDefault returns the default value for the type (e.g. default for int is 0) FirstOrDefault returns the default value for the type If you result set returns 1 record: SingleOrDefault returns that record FirstOrDefault returns that record If your result set returns many records: SingleOrDefault throws an exception … Read more

System.Timers.Timer vs System.Threading.Timer

This article offers a fairly comprehensive explanation: “Comparing the Timer Classes in the .NET Framework Class Library” – also available as a .chm file The specific difference appears to be that System.Timers.Timer is geared towards multithreaded applications and is therefore thread-safe via its SynchronizationObject property, whereas System.Threading.Timer is ironically not thread-safe out-of-the-box. I don’t believe … Read more

How do I use WPF bindings with RelativeSource?

If you want to bind to another property on the object: {Binding Path=PathToProperty, RelativeSource={RelativeSource Self}} If you want to get a property on an ancestor: {Binding Path=PathToProperty, RelativeSource={RelativeSource AncestorType={x:Type typeOfAncestor}}} If you want to get a property on the templated parent (so you can do 2 way bindings in a ControlTemplate) {Binding Path=PathToProperty, RelativeSource={RelativeSource TemplatedParent}} … Read more

In WPF, what are the differences between the x:Name and Name attributes?

There really is only one name in XAML, the x:Name. A framework, such as WPF, can optionally map one of its properties to XAML’s x:Name by using the RuntimeNamePropertyAttribute on the class that designates one of the classes properties as mapping to the x:Name attribute of XAML. The reason this was done was to allow … Read more

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