Showing posts with label VisualStudio. Show all posts
Showing posts with label VisualStudio. Show all posts

Tuesday, July 18, 2006

Unable to add data connection. Key not valid for use in specified state. - MSDN Forums

solution:

1. Open the registry

2. Rename [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0]

To [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0back]

3. Restart Visual Studio

Monday, March 21, 2005

Close All for VS 2003

Imports EnvDTE
Imports System.Diagnostics

Public Module CloseAll
Private maxTries As Integer = 3
Sub CloseAll()
Dim currentTries As Integer = 0
While (Not exeClose()) And currentTries < maxTries
currentTries += 1
End While
End Sub

Function exeClose() As Boolean
Try
For Each d As Document In DTE.Documents()
d.Close(vsSaveChanges.vsSaveChangesPrompt)
Next
Catch
Return False
End Try

Return True
End Function

End Module

Saturday, March 19, 2005

AccessorsCreator for VS

Imports EnvDTE
Imports System.Diagnostics

Public Module AccessorsCreator
Sub createAccessor()
Dim selected As String = DTE.ActiveDocument().Selection.text()
If (selected Is Nothing Or selected.Length = 0) Then
Exit Sub
End If

selected = selected.Replace(",", "")
selected = selected.Replace(";", "")
Dim parts() As String = selected.Split(" ")
Dim memberCount As Integer = parts.Length - 2

Dim basicOutput As String = "public $TYPE$ $PROP_NAME$ {" & vbCrLf _
& vbTab & "get { return $MEMBER_NAME$; }" & vbCrLf _
& vbTab & "set { $MEMBER_NAME$ = value; }" & vbCrLf _
& "}" & vbCrLf & vbCrLf

Dim results(memberCount) As String
For i As Integer = 2 To parts.Length - 1
Dim propName As String
propName = parts(i).Substring(0, 1).ToUpper() & parts(i).Substring(1)
results(i - 2) = basicOutput.Replace("$MEMBER_NAME$", parts(i))
results(i - 2) = results(i - 2).Replace("$PROP_NAME$", propName)
results(i - 2) = results(i - 2).Replace("$TYPE$", parts(1))
Next

Dim entryLine As Integer = DTE.ActiveDocument().Selection.BottomLine + 1
DTE.ActiveDocument().Selection.GotoLine(entryLine)

For i As Integer = 0 To results.Length - 1
DTE.ActiveDocument().Selection.Insert(results(i))
Next
End Sub
End Module