Monday, November 30, 2009

Unable to find service IVsDiscoveryService

I had a problem with Visual Studio 2008. When I try to update service reference I have got following error message: "Unable to find service IVsDiscoveryService"...

To solve this do the following:
Open command prompt, go to the devenv folder (usually C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE) ande type following command:

devenv /resetskippkgs


You can save some time for finding visual studio disk and reinstalling visual studio.

Friday, November 20, 2009

Visual Studio macro for opening file from unit test folder

My test creates log file in current test execution folder dir. And sometime I need to open that file to see content. So, I made macro in visual studio for that:


Public Sub OpenLog()
Dim solutionPath As String
Dim solutionDir As String
Dim dirInSolution As String()

solutionPath = DTE.Solution.FullName
solutionDir = Path.GetDirectoryName(solutionPath)
solutionPath = solutionDir + "\TestResults"
dirInSolution = Directory.GetDirectories(solutionPath)

Dim lastTestDir As String
Dim currentDT As Date

For Each currentDir As String In dirInSolution
Dim ct As Date
ct = Directory.GetCreationTime(currentDir)
If (ct > currentDT) Then
currentDT = ct
lastTestDir = currentDir
End If
Next

' we have dir name
' open log file from that dir
Dim finalPath = lastTestDir + "\Out\trace.log"
DTE.ItemOperations.OpenFile(finalPath, ViewKind:=EnvDTE.Constants.vsViewKindTextView).Activate()
End Sub

Sunday, November 15, 2009

Using linq to select nodes in tree structure

If we have tree structure of object like this:

class C1
{
public List Children {get; set;}
public string Name {get; set;}
}


and have list of C1 object for example "listOfC1" we can use Linq to select object that match specific name path, for example "N1/N2/N3":


var result =
from c1 in listOfC1
where c1.Name == "N1"
from c2 in c1.Children
where c2.Name == "N2"
from c3 in c2.Children
where c3.Name == "N3"
select c3;

Friday, November 13, 2009

Errors in MSDN samples for LINQ

Microsoft has put on his site samples for LINQ. But on that page there are several errors. For example http://msdn.microsoft.com/en-us/vcsharp/aa336758.aspx#SelectManyCompoundfrom1 explain how to use "compound from". In theirs example it's written:

var pairs =
from a in numbersA,
b in numbersB
where a < b
select new {a, b};

but if you try this code you will get compile error:
"A query body must end with a select clause or a group clause"

The code should be:

var pairs =
from a in numbersA
from b in numbersB
where a < b
select new {a, b};

I am wondering how they gets their results.

Thursday, November 12, 2009

Total commander and SkyDrive

I was searching for solution how to map SkyDrive as a network drive or how to use skydrive as drive in Windows explorer. I found SkyDrive Explorer but I was very disappointed when I saw that I cannot use that drive in Total Commander.

But there is also plugin for Total Commander that enables using SkyDrive within TotalCommander. You can download plugin here.