If you want to run your apps in localhost through IIS Express without having to launch Visual Studio in admin mode every time, run this one-time command through an admin-elevated cmd (replacing your app name and port):
>netsh http add urlacl url=http://localhost.myapp.com:1337/ user=everyone
Now you can launch Visual Studio in normal mode and when you Ctrl-F5, you won’t get a “failed to register url” error.
This is an extension method that serializes any object to xml. Note that it is “null resistant” in that if the target is null, the extension does not throw an object-not-set-to-an-instance exception, but instead simply returns null.
public static string ToXmlString(this T item) where T : class
if (item == null)
using (var stream = new MemoryStream())
using (var writer = XmlWriter.Create(stream))
new XmlSerializer(item.GetType()).Serialize(writer, item);
xml = Encoding.UTF8.GetString(stream.ToArray());
UPDATE: I’ve created a solution script so you can run this with a single command
If you want to quickly delete all the bin and obj folders in a solution:
- Make sure you have Microsoft’s Productivity Power Tools 2012 installed in your Visual Studio’s Extensions and Updates.
- Right-click on the solution in Solution Explorer
- Open Command Prompt
- Run powershell
- Paste and run this: Get-ChildItem -include bin,obj -recu -Force | remove-item -force -recurse