Ever since I remember I was in charge of my father’s computer (Well, to be honest, there was a time when I tried to install Skool Daze – a Commodore 64 game – on his brand new XT where he was ahead in the game but this quickly changed ;-) ).
Taking care of my father’s computer was an easy talk while we lived together in the same house but got significantly more challenging when I moved out, especially now that I’m in the US and my parents are in Germany. Since “remote controlling” my father on the phone wasn’t as easy as I hoped it to be (without going into details, I guess you know what I’m talking about…) I tried a couple of different programs including “Remote Assistance”, vnc, msn messenger and others over the time which all had different constraints. Without complaining to much none of them truly satisfied me. Fortunately though a friend introduced me to TeamViewer while we were struggling to setup his development environment and I’m using it ever since. Like Paint.NET, .NET Reflector, Fiddler, Process Explorer, FileZilla, … this is a “must have” tool for everybody doing IT-related work and getting regular requests from family and friends about “why the printer isn’t working anymore” or similar issues (I should probably write a “Must have tools” post).
To me it came down to a couple of things I liked about TeamViewer:
If you’re intrigued and have the same need (otherwise, what are you doing here ;-) ) give it a try and share your thoughts.
Happy administration!
Daniel
Hi,
I posted a bit of code the other day which I used to get a list of all Code Snippets we ship in Visual Studio. In a nutshell, I used XElement.Load to create a new XML document from a filename from which I then read elements from (There are way to many ”from” in this sentence ;-) ). Unfortunately, I forgot to import the XML Namespace in the code I posted which caused my code not to return any results (but instead provided me with a brilliant opportunity to write another post. hehe :-) ).
Let’s have a look at the code which is causing trouble and a Code Snippets to understand what’s going on (you can find the complete code including the Snippet class in the aforementioned post):
Dim query = _
From file In My.Computer.FileSystem.GetFiles( _
"C:\Program Files\Microsoft Visual Studio 10.0", _
FileIO.SearchOption.SearchAllSubDirectories) _
Where file.EndsWith(".snippet") _
Order By file
Dim snippets As New List(Of Snippet)
Dim snippetDocument As XElement
Dim snippet As Snippet
For Each item In query
snippetDocument = XElement.Load(item)
If snippetDocument...<Title>.Value IsNot Nothing Then
snippet = New Snippet With {.Title = snippetDocument...<Title>.Value.ToString _
, .Description = snippetDocument...<Description>.Value.ToString _
, .Path = item _
, .Size = New System.IO.FileInfo(item).Length}
snippets.Add(snippet)
End If
Next
Code Snippet
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Activate a Running Application by Name</Title>
<Author>Microsoft Corporation</Author>
<Description>Activates a running application using the name of the application.</Description>
<Shortcut>appActNa</Shortcut>
</Header>
<Snippet>
<Imports>
<Import>
<Namespace>Microsoft.VisualBasic</Namespace>
</Import>
</Imports>
<Declarations>
<Literal>
<ID>applicationName</ID>
<Type>String</Type>
<ToolTip>Replace with the name of the application. This is often the title of the application window.</ToolTip>
<Default>"Untitled - Notepad"</Default>
</Literal>
</Declarations>
<Code Language="VB" Kind="method body"><![CDATA[AppActivate($applicationName$)]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
As you can see there is a <Title> element in the the Code Snippet to which we are referring to in the code above… or are we?
Let’s dig a bit deeper, open the compiled program in .NET Reflector and disassemble it (if you don’t have .NET Reflector you have to stop reading NOW and get it!! Seriously, this tool is a life-safer and I’ve learned soooo much using it!).
If you focus on the parts I highlighted in red in the above picture you can see that <Title> consists out of the XML name and the XML namespace (check out XName..::.Get Method (String, String)). Since I didn’t import the namespace in my program an empty namespace got used resulting in the qualified name Title which doesn’t fit the namespace of the Code Snippet {http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet}Title, hence my program didn’t return any results.
To solve this problem I added the following line of code to my program
Imports <xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
and – finally – all is good :-)
Hopefully this solved the mystery of the missing results ;-)
Best!
I needed to create a list of all Code Snippets we ship in Visual Studio the other day containing their title, description and path on disc and size. As you might know, Code Snippets are stored in multiple directories below "%ProgramFiles%\Microsoft Visual Studio 10.0" so I had to traverse all the subdirectories of the aforementioned path to find all snippets.
Fortunately – linq to the rescue – this came down to a few lines of code :-)
Dim query = From file In My.Computer.FileSystem.GetFiles("C:\Program Files\Microsoft Visual Studio 10.0", FileIO.SearchOption.SearchAllSubDirectories) _
This statement gives you a List of Strings (or, to be a bit more precise, a System.Linq.IOrderedEnumerable(Of String)) which you can walk over to do all kinds of crazy things.
Here is what I did to solve the problem I described above:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim query = From file In My.Computer.FileSystem.GetFiles(txtPath.Text, FileIO.SearchOption.SearchAllSubDirectories) _
DataGridViewSnippets.AutoGenerateColumns = True
DataGridViewSnippets.DataSource = snippets
End Sub
End Class
Public Class Snippet
Private _Title As String
Private _Description As String
Private _Path As String
Private _Size As Long
Public Property Title() As String
Get
Return _Title
End Get
Set(ByVal value As String)
_Title = value
End Set
End Property
Public Property Description() As String
Return _Description
_Description = value
Public Property Path() As String
Return _Path
_Path = value
Public Property Size() As Long
Return _Size
Set(ByVal value As Long)
_Size = value
Btw, if you bind the result to a DataGridView you can copy&paste from there into excel. Needo :-)
Cheers!
P.S. If you'd like to understand why you need the Imports <xmlns="http... at the beginning of the code check the follow-up article I wrote.
P.P.S. You can download the source code from the MSDN Code Gallery.
Edited April 29, 2009: Included the "Imports" statement and did some cleanup work.
2009 is the 25th anniversary of Microsoft Press! To celebrate their b-bay they’re giving away two free e-books, namely
Get them as soon as the offer lasts :-)
The Virtual Earth Silverlight™ Map Control, enables a new level of performance without document object model (DOM) constraints. The release allows users to enhance their mapping and data visualization applications with powerful extensions, including high-fidelity video, animation, and vector graphics. The use of Silverlight also provides a development environment working with managed code, which allows for development, unit testing and debugging with Visual Studio 2008.
Integration with Detailed Virtual Earth Features
Seamless Development and Rich Toolkit
Rich, Interactive Silverlight Applications
To begin developing with Virtual Earth Silverlight Control CTP, visit Microsoft Connect: http://connect.microsoft.com/silverlightmapcontrolctp
I got the bits a while ago and have to say that I’m more than pleased ! Unfortunately back than they were still under NDA as we intended to disclose them at MIX so you can imagine my excitement that I’m finally allowed to share the goodness with you :-) (and that I can release a Silverlight version of Where is Daniel soon :-) if I find some time…)