1. On Saturday September 3RD, 2016 this community will be shutdown permanently.

    The time has come to close this community. I no longer have any interest in Visual Studio programming and my efforts to find someone to take over the community has failed.

    If anyone is interested in acquiring the database contact me and I will make it available for you.

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

    DN Admin Administrator
    Staff Member

    United States
    Aug 7, 2010
    Likes Received:
    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/>
    Return LeadsViewBindingSource.Current("CompanyID")<br/>
    End Get<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

Share This Page