Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / March 2007

Tip: Looking for answers? Try searching our database.

my Visual Studio install refuse to load any addins

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
stax - 05 Mar 2007 12:51 GMT
Hello,

my Visual Studio install refuse to load any addins, nothing shows up in the addin manager. I tried wizard created addins and some I found in the internet. Apart from reinstalling Visual Studio is there anything I can try? I think I've used addins before so it got broke somehow.

Normally I prefer macros but it's problematic with the design time because the macro IDE runs in another process, what I want to do is adding a DesignerActionList (the smart tag thingy) to any control after the designer host has loaded a form or control. Maybe anybody with deep knowledge about extensibility, automation, design time, AppDomain etc. can give me some hints, my knowledge about all this is only sketchy. My macro code where I'm stuck looks like this:

Sub WindowEvents_WindowCreated(ByVal Window As EnvDTE.Window) Handles WindowEvents.WindowCreated
    MsgBox(1)
    Dim h As IDesignerHost = Window.Object
    Dim s As IServiceProvider = h.GetService(GetType(IServiceProvider))
    MsgBox(2)
End Sub

the second message box isn't displayed so it terminates silently

My current why to setup my DesignerActionLists is putting a custom control on my form which overrides OnParentChanged to iterate then over all controls to retrieve the designer of the control to add the DesignerActionList to the designer. What I don't like about that approach is I have to put a dummy control on every form only to get my design time code running.

Some things I don't understand, when I override the Text property of a form, it doesn't ever get called when the designer host loads the form.

thx
stax

Public Class DesignModeDummyControl
    Inherits Label

    'when the designer puts this control on a form a init method is called
    Protected Overrides Sub OnParentChanged(ByVal e As EventArgs)
        MyBase.OnParentChanged(e)
        InitSmartTags()
    End Sub

    Private DesignerActionUIService As DesignerActionUIService

    'the init method puts a the DesignerActionLists on all controls
    'and creates a event handler to add the the lists if new controls are added to the form
    Public Sub InitSmartTags()
        Dim s As IComponentChangeService = DirectCast(GetService(GetType(IComponentChangeService)), IComponentChangeService)

        If Not s Is Nothing Then
            AddHandler s.ComponentAdded, AddressOf OnComponentAdded
            AddLists(Me)
        End If
    End Sub

    Private Sub OnComponentAdded(ByVal sender As Object, ByVal e As ComponentEventArgs)
        AddLists(e.Component)
    End Sub

    'check if the list was already added to the designer
    Private Function ContainsList(ByVal designer As ControlDesigner, ByVal type As Type) As Boolean
        For Each i As DesignerActionList In designer.ActionLists
            If i.GetType Is type Then
                Return True
            End If
        Next
    End Function

    'add the lists to the designer
    Private Sub AddLists(ByVal c As IComponent)
        Dim host As IDesignerHost = DirectCast(c.Site.GetService(GetType(IDesignerHost)), IDesignerHost)

        If TypeOf host.RootComponent Is Form Then
            Dim cd As ControlDesigner = DirectCast(host.GetDesigner(host.RootComponent), ControlDesigner)

            If Not ContainsList(cd, GetType(FormActionList)) Then
                cd.ActionLists.Add(New FormActionList(host.RootComponent))
            End If
        End If

        For Each i As Component In host.RootComponent.Site.Container.Components
            If TypeOf i Is Control Then
                If TypeOf host.GetDesigner(i) Is ControlDesigner Then
                    Dim cd As ControlDesigner = DirectCast(host.GetDesigner(i), ControlDesigner)

                    If TypeOf i Is TextBox OrElse TypeOf i Is Label OrElse _
                        TypeOf i Is ComboBox OrElse TypeOf i Is CheckBox OrElse _
                        TypeOf i Is GroupBox Then

                        If Not ContainsList(cd, GetType(CommonActionList)) Then
                            cd.ActionLists.Clear()
                            cd.ActionLists.Add(New CommonActionList(i))
                        End If
                    End If
                End If
            End If
        Next
    End Sub
End Class

Public Class CommonActionList
        Inherits DesignerActionList

        Private Items As New DesignerActionItemCollection()
        Private DesignerActionService As DesignerActionService

        Public Sub New(ByVal component As IComponent)
            MyBase.New(component)
            DesignerActionService = DirectCast(GetService(GetType(DesignerActionService)), DesignerActionService)
        End Sub

        Protected Function FixControlName(ByVal value As String) As String
            Dim ret As String = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(value)

            For Each i As Char In value
                If Not Char.IsLetterOrDigit(i) Then
                    ret = ret.Replace(i, "")
                End If
            Next

            Return ret
        End Function

        Protected Sub RefreshComponent()
            DirectCast(GetService(GetType(DesignerActionUIService)), DesignerActionUIService).Refresh(Component)
        End Sub

        Public Sub SetValue(ByVal propertyName As String, ByVal value As Object)
            Dim pd As PropertyDescriptor = TypeDescriptor.GetProperties(Component)(propertyName)
            pd.SetValue(Component, value)
        End Sub

        Public Function GetValue(Of T)(ByVal propertyName As String) As T
            Dim pd As PropertyDescriptor = TypeDescriptor.GetProperties(Component)(propertyName)
            Return DirectCast(pd.GetValue(Component), T)
        End Function

        Private Function GetPrefix() As String
            Dim ret As String = ""

            For Each i As Char In GetComponent.GetType.Name
                If Char.IsUpper(i) Then
                    ret += i
                End If
            Next

            Return ret.ToLower
        End Function

        Private Function GetComponent() As Component
            Return DirectCast(Component, Component)
        End Function

        Public Property Text() As String
            Get
                Return GetValue(Of String)("Text")
            End Get
            Set(ByVal Value As String)
                SetValue("Text", Value)
                SetValue("Name", GetPrefix() + FixControlName(Value))
                RefreshComponent()
            End Set
        End Property

        Public Property Name() As String
            Get
                Return GetValue(Of String)("Name")
            End Get
            Set(ByVal value As String)
                SetValue("Name", value)
            End Set
        End Property

        Public Property Multiline() As Boolean
            Get
                Return GetValue(Of Boolean)("Multiline")
            End Get
            Set(ByVal value As Boolean)
                SetValue("Multiline", value)
            End Set
        End Property

        Public Property Anchor() As AnchorStyles
            Get
                Return GetValue(Of AnchorStyles)("Anchor")
            End Get
            Set(ByVal Value As AnchorStyles)
                SetValue("Anchor", Value)
            End Set
        End Property

        Public Property TextAlign() As ContentAlignment
            Get
                Return GetValue(Of ContentAlignment)("TextAlign")
            End Get
            Set(ByVal Value As ContentAlignment)
                SetValue("TextAlign", Value)
            End Set
        End Property

        Public Property AutoSize() As Boolean
            Get
                Return GetValue(Of Boolean)("AutoSize")
            End Get
            Set(ByVal Value As Boolean)
                SetValue("AutoSize", Value)
            End Set
        End Property

        Public Property DropDownStyle() As ComboBoxStyle
            Get
                Return GetValue(Of ComboBoxStyle)("DropDownStyle")
            End Get
            Set(ByVal value As ComboBoxStyle)
                SetValue("DropDownStyle", value)
            End Set
        End Property

        Public Sub AddPropertyItem(ByVal name As String, ByVal ParamArray t As Type())
            For Each i As Type In t

                If GetComponent.GetType Is i OrElse _
                    GetComponent.GetType.IsSubclassOf(i) Then

                    Items.Add(New DesignerActionPropertyItem(name, name))
                End If
            Next
        End Sub

        Public Overrides Function GetSortedActionItems() As DesignerActionItemCollection
            items.Clear()

            AddPropertyItem("Text", _
                GetType(TextBox), _
                GetType(GroupBox), _
                GetType(Label), _
                GetType(CheckBox))

            AddPropertyItem("Name", GetType(Control))
            AddPropertyItem("TextAlign", GetType(Label))
            AddPropertyItem("AutoSize", GetType(Label))
            AddPropertyItem("Multiline", GetType(TextBox))
            AddPropertyItem("DropDownStyle", GetType(ComboBox))
            AddPropertyItem("Anchor", GetType(Control))

            Return items
        End Function
    End Class
stax - 08 Mar 2007 11:21 GMT
the solution was to instal MSXML6

> Hello,
>
> my Visual Studio install refuse to load any addins, nothing shows up in
> the addin manager. I tried wizard created addins and some I found in the
> internet. Apart from reinstalling Visual Studio is there anything I can
> try? I think I've used addins before so it got broke somehow.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.