Code generation ... Object variable or With block variable not set

Discussion in 'Visual Basic .Net' started by DN Admin, Apr 25, 2012.

  1. DN Admin

    Staff Member

    Country:
    United States
    Joined:
    Aug 7, 2010
    Location:
    Joliet, IL U.S.A.
    I'm having trouble tracking down what is wrong and causing the above error. This only occurs when saving the design view in VS 2012. The code builds and runs fine.
    Full error text:
    Code generation for property 'CompanyValue' failed. Error was: 'Property accessor 'CompanyValue' on object 'ContactViewUC1' threw the following exception: 'Object variable or With block variable not set."
    CompanyValue definition in ContactViewUC:
    Public Property CompanyValue<br/>
    Get<br/>
    Return LeadsViewBindingSource.Current("CompanyID")<br/>
    End Get<br/>
    Set(value)<br/>
    LeadsViewBindingSource.Filter = "CompanyID = " & value<br/>
    End Set<br/>
    End Property
    And the only place it is referenced from:
    Private Sub LeadsViewBindingSource_PositionChanged(sender As Object, e As System.EventArgs) Handles LeadsViewBindingSource.PositionChanged<br/>
    If Not LeadsViewBindingSource.Count = 0 Then<br/>
    ContactViewUC1.CompanyValue = LeadsViewBindingSource.Current("CompanyID")<br/>
    CompanyDetailUC1.CompanyValue = LeadsViewBindingSource.Current("CompanyID")<br/>
    End If<br/>
    End Sub
    Yes, I get the same error on the other user control.
    This is just a designer problem, but it's a real pain when I try to save the project. Note that if I have not opened the parent window in VS2010, I do not get he error. Even if I open the code for the window, make changes, and then save I do not get the
    error. The error occurs anytime I open the degin view for the form and then try and save without making any changes.
    I would appreciate any clues as to what is going on.

    View the full article
     
    #1

Share This Page