Degree Blogg
9May/120

Sharepoint debugging – process terminated by IIS

Posted by Andreas

”The web server process that was being debugged has been terminated by IIS”

When debugging Sharepoint components you’re likely to come across this error message. It is easily fixed by turning off the ping IIS is sending the worker process at regular intervals to keep it alive.

Go to IIS Manager, select the Application Pool used by your Sharepoint app, choose advanced settings and turn the “Ping Enabled” setting under “Process Model” to FALSE:

image

30Mar/122

Delete ReSharper Test Results on “Clean Solution”

Posted by Joakim

On my local dev machine, I can see no reason for keeping old test results (on a build server it’s another matter completely though). You usually run your tests quite often when developing, and thus you get a lot of “test result”-folders cluttering up your hard drive. Some test runners have options for configuring how many old test results you would like to keep, but this is not the case for ReSharper’s test runner (afaik).

To remedy this I’ve created a new target in the project file for my test project, that will delete the test result folder when I right-click the solution Visual Studio’s solution explorer and select “Clean Solution” (or on a project and select “Clean”). By default ReSharper creates the test results in “<ProjectFolder>/bin/<Configuration>/TestResults”, you can however change this (and therefore need to modify the config below accordingly).

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  .
  .
  .
  <PropertyGroup>
    <TestResultsFolderPath>bin\$(Configuration)\TestResults</TestResultsFolderPath>
  </PropertyGroup>
  <Target Name="AfterClean">
    <RemoveDir Directories="$(TestResultsFolderPath)" Condition="Exists('$(TestResultsFolderPath)')" />
  </Target>
</Project>

This target will check if there is a test results folder, and if there is, it will delete it (and it will only run when you clean the solution/project).

If you have more than one test project (i.e. one for unit tests and one for integration tests, etc.) you need to add it the project file for each project. Also beware that adding this target will affect everyone working on the project, not just you!

This solution should work for other test runners as well, just modify the “TestResultsFolderPathabove to reflect where the test results are created.

As I said in the beginning, some test runners allow you to configure how many old test results should be kept at any time, making this a non-issue. E.g. if you’re using the test runner found in Visual Studio out of the box, you could go to “Tools –> Options –> Test Tools –> Test Execution” and specify a number for the “Limit number of old Test Results to”-setting.

28Mar/120

NCrunch = time saved

Posted by thorhalvor

NCrunch is an automated continuous testing tool for Visual Studio .NET. It takes responsibility for running automated tests so that you don't have to.

Instead of going through these steps when doing Test Driven Development:

  1. Write tests
  2. Run tests
  3. Write code
  4. Run tests
  5. Refactor code
  6. Run tests

NCrunch will take care of all the "Run tests" and you can therefore concentrate on writing and refactoring your tests and code.

How does it work?

I will give some simple examples below but you can also go to NCrunch's About-page where you can see a video.

First of all, will you get new column with red/green/black dots on every line of code.

Green = Covered by successfull test
Red =  Covered by test but failing
Black  = indicating that there are no tests for this line of code.

It will test while you write and you get feedback while coding. No need to compile or save the document.

A specific example of the most basic steps is shown below:

A: You see a green dot for every line of code. That means at least one test is testing these lines and it is also successful.
B: If I hold the mouse over the dot at line 45 I can see that there are 4 passings tests for this part of code.
C: If I comment line 43-46, the color of the dots will immediately change because some tests are now failing. And some code is untested.
D: Holding the mouse over the red dot at line 42 gives a summary of why it is red. This part of code is covered by 3 passing tests and 1 failing.

This was only the basics of NCrunch. Other things it can do is for example: Code Coveage, Performance metrics, Inline Exception Details, Paralell Execution ++

My advice is therefore: Download, Install and Enable it. Try to not focus on it in the beginning, just "let it do its job", get familiar with the new "dots" and explore its features step by step.

13Jan/120

Conditional breakpoints in Visual Studio

Posted by Andreas

A Visual Studio feature worth checking out is the conditional breakpoint. In short, it allows you to set specific conditions that have to be met for a breakpoint to freeze execution. You have the choice between several types of conditions, like the value of a variable or the number of iterations over a specific breakpoint required before execution stops.

In the following example a list of car manufacturers is enumerated. I want the breakpoint to kick in when and only when the current car is “Subaru”. To achieve this, create a breakpoint like normal (F9) and right click the red marker in the left margin of the editor:

image

Select “Condition” which will open up the following dialog box:

image

Set your condition (standard boolean syntax, in my case car.Equals(“Subaru”) ) and when running the code the breakpoint will ignore all items where this condition if false.

This feature has several other varieties, and it saves you the manual job of iterating through 27 items before the one record that you want to follow through the next code block appears..

27Sep/100

Silverlight debugging i Firefox

Posted by Stian

Microsoft SilverlightHvis du som Silverlight utvikler har Firefox som din default nettleser har du kanskje blitt frustrert over at debuggeren ikke har kunne koble seg til dine breakpoints i Visual Studio. Etter å ha sjekket femten ganger at du står i debug mode har du fremdeles bare tomme røde sirkler i Visual Studio som sier "No debug symbols have been loaded...".

Følg denne oppskriften:

  1. Skriv følgende i adresselinjen i Firefox: about:config
  2. Les advarselen og lov å være forsiktig ;)
  3. Søk etter et valg som heter "npctrl"
  4. Du får frem et treff under "dom.ipc.plugins.enabled.npctrl.dll"
  5. Endre denne fra "true" til "false" ved å trykke "Toggle"
  6. Restart Firefox

Nå skal debugging virke som normalt i Firefox!

16Jul/100

Add WebService i Visual Studio

Posted by Stian

I Visual Studio 2008 / 2010 er "Add Webservice" gjemt bort med mindre du sitter i et Web prosjekt. Du står her med valget mellom "Add Reference" og "Add Service Reference". Det sistnevnte valget er for å lage referanse til Windows Communication Foundation (WCF) services og WCF Data services. Hvis du ønsker å legge til en web service på sammee måte som i tidligere versjoner eller på web prosjekter kan du følge denne oppskriften:

WebService1 WebService2
1. Høyre klikk på prosjektet og velg "Add Service Reference". 2. Klikk på "Advanced..." knappen i dette bildet.
WebService3 WebService4
3. Velg "Add Web Reference" 4. Voila! Nå skal du ha et kjent skjermbilde.