locked
Help needed on error message: invocation of the constructor threw an exception RRS feed

  • Question

  • Hi all,

    In my project I get the following error message:

    "The invocation of the constructor on type 'PersoonBanner.PersoonBannerViewModel' that matches the specified binding constraints threw an exception"

    This error is caused on the line (see complete class code below)

         MijnEvent.Subscribe(AddressOf VerwerkOntvangstVanData)

    Here is the complete listing of the Class PersoonBannerViewModel:

     

    <ModuleExport(GetType(PersoonBannerViewModel))> Public Class PersoonBannerViewModel
        Inherits Basis_ViewModel
    
        <Import()> Private Property MijnServiceAgent As IServiceAgent_Persoon
        <Import()> Public MijnEventAggregator As IEventAggregator
    
        Private _Persoon As New Persoon
        Public Property ActievePersoon() As Persoon
            Get
                Return _Persoon
            End Get
            Set(ByVal value As Persoon)
                _Persoon = value
                ObjectGewijzigd("ActievePersoon")
            End Set
        End Property
    
        Public Sub New()
            Me.New(New EventAggregator)
        End Sub
    
        <ImportingConstructor()> Public Sub New(<Import()> parEventAggregator As IEventAggregator)
            If Not IsDesignTime Then
                If Not IsNothing(parEventAggregator) Then
                    MijnEventAggregator = parEventAggregator
                    Dim MijnEvent As Event_ClientSelectie = MijnEventAggregator.GetEvent(Of Event_ClientSelectie)()
                    MijnEvent.Subscribe(AddressOf VerwerkOntvangstVanData)
                End If
                MijnServiceAgent = New ServiceAgent_Persoon 
                OphalenPersoon()
            End If
        End Sub
    
        Private Sub OphalenPersoon()
            MijnServiceAgent.LeesPersonen(Sub(s, e) ActievePersoon = e.Result.FirstOrDefault)
        End Sub
    
        Private Sub VerwerkOntvangstVanData(ByVal OntvangenData As CommData)
            ActievePersoon = OntvangenData.KopieObject
        End Sub
    End Class
    

    The innerexception text is:

    Attempt by method 'Microsoft.Practices.Prism.Events.DelegateReference.TryGetDelegate()' to access method 'PersoonBanner.PersoonBannerViewModel.VerwerkOntvangstVanData(WayPoint7_CodeBasis.CommData)' failed.

    Does anyone have any idea on what goes wrong here?

    Saturday, July 23, 2011 2:38 PM

Answers

  • You are trying to access a private member.  The Silverlight runtime does not allow you to access private members through Reflection which is what MEF, Unity, and other frameworks use to access members.  Either declare the culprit public, or internal and give the component model access to your assembly.  See this blog post for details on how to do this.

    Monday, July 25, 2011 1:17 AM

All replies

  • You are trying to access a private member.  The Silverlight runtime does not allow you to access private members through Reflection which is what MEF, Unity, and other frameworks use to access members.  Either declare the culprit public, or internal and give the component model access to your assembly.  See this blog post for details on how to do this.

    Monday, July 25, 2011 1:17 AM
  • Thanks Stephen it was really help full.

    -Arun

    Tuesday, August 2, 2016 11:23 AM