Configure DNS Aliases in IISExpress for localhost

A direction we are taking Process PA is white labelling for our partners. To do this we are still hosting on the same scalable platform on Microsoft Azure and essentially adding another level of multi-tenanting in our codebase. When a user navigates to https://app.processpa.com/ they will get our first party branded experience. However, when a user navigates to something like https://partner1.processpa.com, they will get a tailored experience complete with branding, different resources, templates and features specific for those customers supported by our partners.

Building out the experience using Dependency Injection with Branch By Abstraction based on the host is reasonably straight forward. I however wanted the local development environment to be run in the same way, rather than switching in code for whatever partner experience was being built out at the time. To do this I need to be able to configure local DNS records for localhost and IISExpress. The answer I found on StackOverflow but below are the simplest steps that worked for me.

  1. Open Notepad as an Administrator
  2. Open in Notepad C:\Windows\System32\drivers\etc\hosts
  3. Copy the comment lines for localhost host and add as your DNS records
    127.0.0.1    partner1.localhost
    ::1          partner1.localhost
  4. For Visual Studio 2015, open <Solution folder>\.vs\config\applicationhost.config
  5. Find the site and add the bindings you need, making sure to change the ports.
    <bindings>
    <binding protocol="http" bindingInformation="*:1704:localhost" />
    <binding protocol="https" bindingInformation="*:44300:localhost" />
    <binding protocol="http" bindingInformation="*:1705:partner1.localhost" />
    <binding protocol="https" bindingInformation="*:44308:partner1.localhost" />
    </bindings>
  6. To prevent the need to run Visual Studio as admin to start IISExpress on those ports, open an Administrator command prompt and run:
    netsh http add urlacl url=http://partner1.localhost:1705/ user=machine\username
    netsh http add urlacl url=https://partner1.localhost:44308/ user=machine\username

If you have certificate trust issues check out: https://blogs.msdn.microsoft.com/robert_mcmurray/2013/11/15/how-to-trust-the-iis-express-self-signed-certificate/.

And that’s it! When you go to https://localhost:44300 or https://partner1.localhost:44308 you get the same application with a different experience.

Visual Studio Debugger Failing to inspect variables

Everything compiled fine and the app is running well. However when I attached the debugger to w3wp.exe and however over variables, no value was being shown. Ctrl-Alt-Q on one for Quick Watch revealed the problem.

error CS1704: An assembly with the same simple name ‘###’ has already been imported. Try removing one of the references (e.g. ###.dll) or sign them to enable side-by-side.

Error seems straight forward enough. Help points to fixing references as the error would suggest. This only just started happening. And not just me. So it must be a code change right? Looking through version history, everything looks innocent. I check the references and they are all fine. So I must have some messed up assemblies somewhere.

Rebuild.

Clean. Build.

Clean entire workspace. tfpt treeclean

Restart visual studio.

Rise & Repeat…

No avail. Both my git and TFVC workspaces have the same problem.

Reboot computer in case of cache.

Then I delete the Temporary ASP.NET Files for the web site in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files.

Bingo! Some change must have caused a duplicate to be place in there somehow. Not the best resolution, but as least I can inspect the code with the debugger again.

Debug Lambda Expression–Delivered!

Way back in July 19, 2011 I added on the, then relatively new, Visual Studio User Voice page Debug Lambda expression feature request. It quickly gain many votes and was sitting in the top few all this time. Microsoft stated that this was a hard thing to do requiring a complete rewrite of their Expression Evaluator. Instead of just saying it was too hard and not important enough, they did get to work. It is available now in Visual Studio 2015 Preview. Full details are given in the Support for Debugging Lambda Expressions with Visual Studio 2015 on the Visual Studio ALM blog.

 

Debug Lambda expressions [UserVoice]

It has been a long time coming. But I for one am very happy it has come. Well done Microsoft and all who were involved.

Visual Studio 2013 Cookbook Review

Disclaimer: I was provided a complimentary electronic copy of this book by the publisher. In no way was I directed on the content of my review. Opinions are mine alone.

Why would you buy a Visual Studio 2013 book instead of just using the Internet to find what you need? Simple, time and content. The amount of new features and ways to do things in this version is substantial. Mining the Internet you are sure to miss many gems that could make a large difference to your day-to-day work. Going through this book you will benefit that a team of people has done the work for you. Ensuring they have included everything and the content is correct for your easy perusal.

  • Chapter 1 gives a very good overview of the new additions to the main tool you use each day.
  • Chapter 2 gives a very good starting place for Windows 8.1 development. It will get you past the new stuff quickly to allow you to get into the code.
  • Chapter 3 goes over Web Development with MVC 5 and the new One ASP.NET model.
  • Chapter 4 uses some I’m not dead yet WPF ("WPF remains the recommended choice for developing desktop applications on the Windows platform. Visual Studio 2013 itself is a WPF application", p 118) WF, WCF and .NET application development.
  • Chapter 5 Debugging Enhancements
  • Chapter 6 Asynchrony in .NET
  • Chapter 7 C++, I skimmed this one, but the C++ developer should be thrilled, and it makes me want to learn DirectX.
  • Chapter 8 Team Foundation Server features from a users perspective. Great features that many developers aren’t utilizing that can very much help day-to-day. If you are managing a TFS server though, you’ll want more than what is provided here.
  • Chapter 9 is on languages TypeScript, Python and IronPython. TypeScript I knew and understand, but I have no idea about Python, and don’t really want to, but it’s good to know it’s available if that’s your flavour of choice.
  • Appendix contains recipes on Installers, Submitting Windows Store apps, Visual Studio Add-ins and extensions, and creating your own snippets.

The "There’s more…" sections littered throughout are valuable on there own, revealing many power user features I was unaware of. The recipe format of the books make it a great reference to have on-hand. Going to the relevant recipe within the book will be a faster and more reliable process than going online.

I intended to flick through this book quickly and dive in on a couple of chapters. I however could not help but go through it all. The capabilities we have available to us, just from Visual Studio is amazing. Going over it all I can’t help but think of all the possibilities and opportunities. Now I must get back to coding.

If you want to get a hold of this book you can get it directly from the publisher, Amazon and many retailers.

Technorati Tags:

Web Test playback does not use concurrent requests as recorded

I have been running performance tests using Visual Studio Web Tests and Load testing. The goal has been to prove the raw load time and the scalability under increasing users. The web test recorder is quite good for simple request-replay. However, beware a bunch of work is required to parse previous requests for keys to be passed back in subsequent requests, especially for more complex web applications but not as much on simple web sites.

Here’s the results for the single user playback with requests grouped into relevant transactions that we needed to measure.

Web Test results

The odd thing that was happening though is that when we were timing the action Open Report with a stopwatch manually in the browser we were getting typically getting under 5 seconds for completion. The reason for the difference became clear when you watch the web test running. You will see each request going sequentially. If you compare it to the timing from the browser, the actually running is not like that. Below is the timings column from network monitoring from the browser. The two highlighted rows are the requests that take the longest amount of time, but are run together.

Browser Timings

Adding up these request sequentially gets us to similar total time as to what the web test replay presented. So to make the request parallel in the web test you need to set the requests as dependent requests to the first. Right-click the request and select Add Dependent Request.

image

This will add http://localhost/. Delete that request after you have drag-and-dropped the requests that you want to run concurrently into the Dependent Requests folder.

image

Rerunning the web test after this change resulted in timings much like what we experienced manually.

Improved Web Test results

Other things to look for is that Think Times are not on and set to 0 for all requests and turn on cache control for all requests.

Update: So when does the web test recorder get the dependent requests correct? Taking into account the Initiator column in the Network tab of the development tools made it clear:

Initiator

These link and script tags are by default dependent requests for the page.

image

These XMLHttpRequest JavaScript calls are not seen by the web test recording as running in parallel and need to be manually be put in as dependent requests as above.

Technorati Tags:

Visual Studio 2013 Project Load Error – The parameter is incorrect or Unspecified error

Here we have this nice obscure error message from Visual Studio 2013. I get it for almost all my projects within the solution, which at 23 or 67 that’s no fun.

image

If a project is reloading due to a background update and you click Reload, then you might get this other unhelpful message.

image

The strange part is that it would go away and then come back. What we discovered is that it is a bug due to the source control bindings on the solution mismatching the connection settings in Team Explorer. In our case we have multiple URLs that resolve to our TFS server. In our solution file we have http://tfs:8080/tfs/<projectcollection&gt; yet in my connection I have https://tfs.<domain&gt;.com/tfs/<projectcollection>. After going through all the error dialogs if you Save All to save the solution file and do a diff, you will see all the URLs updated to your connection.

image

After making sure all the source control paths are the same in all your solution files, ensure everyone on the team updates their TFS connection, by creating a new connection to the desired address.

  1. image
  2. image
  3. image
  4. image
  5. image

You don’t need to remove the existing one, although, it is advised so that you are sure to connect to the correct address.

Failure of Search TFS

Well over a year ago I set up a landing page to start gathering emails for interest in Search TFS. A dynamic integrated TFS work item search experience. Today I am calling an end to the project. Although the project didn’t go anywhere, by the process I followed I wasted little time and could fully justify the position the product was to take. The main reason to kill it is that Visual Studio 11 is shipping with integrated TFS work item searching. Finally.

Team Explorer VS11 Search

I think this helps justify that there is a need for what I wanted to do. The existing Search Work Items for TFS 2010 had 7,076 downloads on the 1st January 2011 when I was starting this and now has, 23,093. That’s not a bad niche. How many would be willing to pay for something better is another question. On my landing page, I got 12 emails. Considering that there was absolutely no push, SEO, linking (apart from this blog) or advertising I’m happy there was something and I have a baseline.

Soon after I launched the landing page I got wind the Microsoft was finally going to do something. So I waited to see. Now that I’ve been playing with Visual Studio 11, I’m happy with the new Team Explorer for the most part, but I was quite disappointed with the search. It’s no better that the current available plug-in. That means it’s slow and query based. I wanted more like OneNote, where you see results as you start typing:

OneNote Search

The market though, even for something substantially better I feel is drastically reduced now that it is first party. I’m disappointed Microsoft didn’t do better since search is one of the most important features of work item tracking. The way that UserVoice does it to help prevent duplicates is brilliant. I’m hoping the search works better with TFS 11 but  since running it against Team Foundation Services (fantastic btw, especially the just announce build service) I have little hope for that.

All is not lost. TFS Working On has improved in its download rate. ClickOnce deployment having less friction may have helped that. It’s long overdue for an overhaul. I’ve had plans for nice Windows 7 integration for a long time, now I should be looking at Windows 8 perhaps. Search TFS will still fit nicely into TFS Working On, especially for those that don’t live in Visual Studio.

Visual Studio Minimalist Toolbar

Although for most functions in Visual Studio, I use shortcut keys, a couple of buttons for when you are already on the mouse is very handy. Visual Studio however has multiple toolbars and a load of buttons that, for the most part, just take up valuable screen real estate. Even on my new triple 22” wide screen setup.

The question of using the Ribbon in Visual Studio was raised on the new Visual Studio UserVoice feedback forums. I personally gave this three votes, but I am also in favour of as little toolbars as possible. So I added the comment:

The Ribbon done right would have a customizable quick access toolbar which would include the Debug button and your other frequent ones there. And as with the Office Ribbons you can collapse it to just the tabs, so in effect, you can have more screen real estate all the time while still accessing any functions you want with, at most, two clicks. Much better than continually showing and hiding the relevant toolbars. However, Visual Studio currently lets you put toolbar buttons right up in the menu row, which is where I have my common buttons and can remove any other toolbar.

That would give you something like this, as I have in Windows Live Writer:

Windows Live Writer Ribbon - Customizable and Collapsed

However, I just want to elaborate what I meant by buttons in the menu bar, as my colleagues didn’t know you could do it either.

  1. Right-click any where on the toolbars and click Customize…
  2. Select the Commands tab
    Commands Tab
  3. Menu Bar is already selected, so click, Add Command…
    Add Command...
  4. Select the command you want
    Add Command Dialog
  5. Position and Customize it’s details
    Customize Item

And here is the result:

Visual Studio Minimal toolbar

Debug Lambda Expressions

Although I think the Ribbon would clean things up nicely and allow everyone easy minimal toolbars with the quick access, better function and shortcut key discovery, as seen above, it is already quite customizable. With that in mind I think the time would be much better spent getting the debugger able to evaluate Lambda expressions. Time and time again, I am stopped because I cannot evaluate a simple .Select(x =>x == y). Whether this is in the code you have written, or just something you want to write in the quick watch or immediate window to determine the contents of something quickly. I raised this suggestion:

Debug Lambda expressions

Allow Quick Watch and other Debug functions to work with Lambda expressions.

"Expression cannot contain lambda expressions" makes this powerful language feature second-class within the IDE.

Especially for data intensive applications being able to write Lambda expressions in the Quick Watch, Watch, Immediate Windows and debug evaluation is a must have.

Which I am pleased to say has got to the top 3 on the Hottest Ideas. So please vote on it.

Debug Lambda expressions - 3rd Hottest Idea

Technorati Tags:

Visual Studio ASP.NET Development Server – “Internet Explorer cannot display the webpage”

I like to work at home, and my set up at home is almost at good as work, but due to less distractions it can be better. When I created a TFS workspace for my home computer (was Vista, now Windows 7), I got the latest source, built it, and all was good… almost. It did not run. We are building an ASP.NET application and when running under the ASP.NET Development Server (WebDev.WebServer.exe) I would get sent to this error page, which told me nothing useful about why it was failing.

This was irritating, but didn’t really bother me because I could work around it quite quickly. I opened the Web properties of the ASP.NET Web Application project (right click the project, select Properties and then the Web tab on the left) and set it to run from the Local IIS (Internet Information Services) Web server. The only issue this had was I must run Visual Studio as an Administrator since I have User Account Control (UAC) enabled, and I don’t get Edit and Continue.

 

Today however, this won’t do. Today I want to create a new workspace on my home machine to work on multiple unrelated things at the same time. Multiple workspaces is a great productivity boost, from reproducing issues locally in an unchanged environment, to running units tests or other long running processes and working on something else while they are chugging away. I do not want to create multiple virtual directories in IIS, although I could. One of the things I like about the environments I have set up, is that they allow virtually no configuration on any PC you want to use, as long as you have Visual Studio with Team Explorer, you are ready to develop. And our rich wiki requires OneNote and that is all. Both enable also enable working offline and starting new developers or changing PCs is very easy. I thought it might be related to UAC or the firewall, but after a quick look around and I found ASP.NET Developer server not working which lead to IE won’t connect to asp.net server which had the solution. Opening up Notepad as Administrator (since I have UAC on) loading the C:\Windows\System32\drivers\etc\hosts file and commenting out the line ::1 localhost, restart only the browser instance that failed and all is working.

Now Visual Studio does not need to run as Administrator, I do not need to configure IIS, I can have Edit and Continue and multiple workspaces all running completely independently.

 

Must have for any Visual Studio 2008 developer

PowerCommands for Visual Studio 2008. Install it. Nothing else really needs to be said, but I want to highlight a few things.

This is a free Microsoft built VSX (Visual Studio Extensibility) extension. It adds extremely useful yet simple menu commands that are integrated as if Visual Studio shipped with them already there. I will not go into the detail of the commands there is a comprehensive yet brief document here for that. It is definitely worth the installation and Visual Studio just does not feel the same without it anymore.

I have been using version 1 for a couple of months now and have just found version 1.1 was released a month ago which adds a host of new handy features. It gets better, the source code is available. This provides a great example on how to code seamless add-ins to Visual Studio. Before you can build the source you need to install the Visual Studio SDK. I have a list of simple refactoring commands that I intend to write as a learning exercise that will also make common coding tasks easier.

If PowerCommands has convinced you that free first party VSX extensions are a good thing, be sure to check out other releases from Microsoft on the Visual Studio Gallery. The Resource Refactoring Tool is another very good must have.

Technorati Tags: ,