Results 1 to 6 of 6

Thread: [RESOLVED] Designer File Going Solo

  1. #1

    Thread Starter
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Resolved [RESOLVED] Designer File Going Solo

    I have a project that creates a DLL. It's been around for many years and through several iterations, so some of the history has been lost, but I'm now seeing something very odd. The forms work fine, but the .designer.vb file isn't under the form in the project, but off on it's own node in Solution Manager, rather than being a sub-node beneath the form. Since the forms work fine, the partial class in the designer.vb file is clearly being seen correctly. The one issue is that the designer doesn't work. That's not much of an issue, because I don't need to change the design, but I'd still like to correct it.

    InitializeComponents in the constructor still goes to the right place, which is the implementation in the .designer.vb file, so the controls that are on the form do show up right, it's just the designer that seems to have lost track of them.

    Out of curiosity, I tried adding a button onto the form, which appears to be blank in the designer. That worked, so I clicked on the button to generate the click event handler, which took me to a reasonably right place in the .vb file behind the form, but right above there was a new InitializeComponents implementation. So, the designer couldn't find the existing .designer.vb file (though the compiler clearly can), and created a new one to position that button. The button was added as a form level member, as well.

    Back before partial classes were added in VS2005, this is how all forms worked. The designer code lived in the same code file as everything else. I didn't realize that the designer was still willing to do that. I knew it COULD, because code is just code, but I didn't realize the designer would say, "hmmm, I can't find a .designer.vb file to work with, I guess I'll just put the code in the file I do have." It's a surprising choice.

    Is there a way to get the designer to recognize the .designer.vb file again?
    My usual boring signature: Nothing

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,632

    Re: Designer File Going Solo

    I would start by examining the project file in your preferred text editor, and look for where the designer file is referenced and go from there. Compare against a "normal" project file to see what might be different. Shouldn't be too hard to track down and fix. Of course, make backups beforehand because you can bork a project if you don't know what you are doing in the project file directly.

  3. #3
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,958

    Re: Designer File Going Solo

    I have seen this happen when the filenames get out of sync e.g. Form1.vb and Form2.Designer.vb (but normally not so obvious, usually after a rename or something went awry) - other than that I am out of ideas.

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,398

    Re: Designer File Going Solo

    I've had this happen on failed find and replace attempts, fortunately for me it was still early enough to start over with a new project. I would think that OptionBase1's approach is probably the best place to start.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  5. #5

    Thread Starter
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: Designer File Going Solo

    I'll give that a try tomorrow, which is when I'll be able to get back to the project.
    My usual boring signature: Nothing

  6. #6

    Thread Starter
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: [RESOLVED] Designer File Going Solo

    It was in the <project>.vbproj file.

    The issue was that something was missing. What should be there would look like this:
    Code:
         <Compile Include="SomeForm.designer.vb">
          <DependentUpon>SomForm.vb</DependentUpon>
        </Compile>
        <Compile Include="SomeForm.vb">
          <SubType>Form</SubType>
        </Compile>
    What was missing was the <DependentUpon> line for each form affected. Further down, there was a similar issue where the resx file was also not dependent upon the form, but that is harder to see in the designer. After all, the code was working, so the compiler didn't need that dependency relationship, it was only the designer that did.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width