Tag: <span>Visual Studio</span>

One annoying problem is when sometimes you try to build your solution, only to get a pile of compilation errors due to a missing DLL. This is often caused by one of the DLLs not downloading from NuGet. The package will be in packages.config, but only the .pdb file gets downloaded.

Even more annoying is when you’re the only developer to have this problem. Everyone else can build the solution without problem.

The answer is fairly simple, but not obvious. Read more for the details.

When refactoring, it’s often hard to see which methods can easily be moved to another class, and what depends on what. Visual Studio has a built-in tool that can make this pretty easy, and almost fun! For a quick video overview of the tool, see this Channel9 video. The current article covers a lot of what is in that video, but concentrates on how to use the tool for refactoring. It’s worth watching the video, as there is a lot more to this than will be shown here. Note: The dependency graph feature is only available in the Grown Up versions of Visual Studio, ie Enterprise, Ultimate or whatever-they-call-it-this-week versions Creating a dependency graph To get started, click the Architecture menu, choose Generate Dependency graph, and then For Solution… Sadly, you only seem to be able to do this for a whole solution (the For Include File option is for C++…

Whilst working a WPF window, I ended up dumping loads of small jobs onto another developer, as he was the main one working on the XAML file for the window, and if we both tried to edit the file, we ended up with conflicts. After dumping the umpteenth extra job on him, I was trying to work out if there is a way I could ease his burden a little. There had been quite a few new issues where the extent of my involvement had been to modify the database and update the model. After that, I had to pass it over to him, to avoid us stomping on each other when working on the same files. So, I got to wondering if there was any way we could split the new quote window up, so multiple people could work on it at the same time. I immediately rejected using…

Every now and then, I have seen my CPU usage jump up to close to 100% on all cores, which can slow things down somewhat… This looks really impressive, like I’m working so hard that my machine can’t keep up with my frantic pace. Sadly, this isn’t always the truth! Looking at Task Manager, shows the culprit to be microsoft.alm.shared.remoting.remotecontainer.dll. If you are using VS2013 or later, and are not using the Community edition, you may notice some annotations above your methods and properties… This feature is known as Code Lens, and is one of those things that is really worth getting to know, as it’s a massive time-saver. Quick digression from the main theme of today’s symposium to tell you why it’s so good… By default, there are about five or six code lenses, but as I’ve changed my options to show only one, only that one is visible in the…

A quirk I have noticed with Visual Studio (2013 and later) is that sometimes when you break in your code and hover your mouse over a variable, instead of showing you the little pop-up that allows you to examine the variable, you don’t get anything. If you try using the Immediate window to see what the variable holds, you get a really informative message like “Internal error in the expression evaluator” which doesn’t help a lot. This might be a bug in the managed debug engine that ships with Visual Studio. Try turning on Managed Compatibility Mode (which effectively turns it into pre-2013 debug engine), located under Options – Debugging: This fixed it for me. Source: http://stackoverflow.com/questions/21854426/get-internal-error-in-the-expression-evaluator-on-add-watch-function-when-tr

Stopping a build If you are working on a Grown-Up Solution, that has lots of projects, and takes days to build (OK, slight exaggeration, but you know the feeling!), you might sometimes want to cancel a build. This usually happens when you’ve just changed something, started a build and then realised you needed to do something else before trying to build. It’s very frustrating sitting there waiting for VS to finish the build, only to tell you in a smarmy voice that the build failed. “Yes, I know the build failed, that’s why I wanted to stop it you condescending computer!” It’s at this point that you feel like smacking it in the face (or monitor), but you don’t, because you are too polite. What you would really like to do is stop the build. Thankfully there are a few ways to do this, presented here in reverse order of…

In case anyone has been hiding under a rock for the last few months (and I can’t say I blame you if you have), Microsoft’s latest stupidity is to ignore decades of usability studies, and have everything on the UI look like it’s shouting at you. In particular, Visual Studio 2012 and later have menu bars that look like this by default… Does the word “Bleah!” spring to mind? Thankfully, this monstrosity is easy to fix, but requires using the registry editor. If you aren’t comfortable mucking around in the registry, then ask an adult to do it for you 🙂 Click the Windows button on your keyboard, and type regedit in the search box. Click the Enter/Return key, or click the RegEdit icon that apepars in the search results. Navigate to the registry keys shown below: For VS2012: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\General\ For VS2013: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\General\ Future versions of Visual Studio will probably follow the same…

I had been having some serious grief with Visual Studio’s unit testing tools. VS was complaining that some tests did not exist, and others called methods that didn’t exist. Both claims were total lies as all methods in question existed, and could be found by using the “Navigate to” feature in VS.

I had two basic errors when I tried to run tests. One was of the form “Method TestProject.SystemsRepositoryTest.CreateNewCamera does not exist” when the method did exist. I could right-click the test in the Test Results window and choose “Open test” and it would take me there. However, when trying to run the test, VS claimed it didn’t exist.

The other error I got was of the form “Test method TestProject.SystemsRepositoryTest.GetAllCameras threw exception: System.MissingMethodException: Method not found: ‘System.Collections.ObjectModel.ObservableCollection`1 Repository.GetAllCameras()'” which was also a lie as the method being tested existed. Again, I could go to the test method, click on the name of the method being called, click f12 (Navigate to) and be taken to the code for the method.

Thanks to these problems, I have wasted loads of time debugging things that could have been fixed with unit testing. It has been frustrating to say the least!

Well, I finally found the answer…

I opened the bin/Debug folder in the test project in Windows Explorer and deleted everything in it. I then rebuilt the test project, and my tests ran fine.

For some odd reason, it looks like rebuilding the test project wasn’t actually changing the DLLs in the folder, so it was using old versions, in which the methods didn’t exist. Deleting them all forced VS to grab fresh copies of the referenced DLLs, and rebuild the test project’s DLL.

I don’t know if this is a bug in Visual Studio 2010, but it doesn’t seem to be a feature that I would have added in by choice!