|
-
Dec 18th, 2021, 07:02 PM
#1
UserControl and .NET 5
I just tried to use a usercontrol I've been using in a variety of Framework applications. I get no errors, I add it to the designer file, set the properties, add it to the panel that it will be displayed on...and then it just quietly goes away. I never get a compiler error or anything like that. Even more interesting, it leaves the designer file incrementally.
In the designer file, there are four places that a control can be found.
1) There is the declaration, which is usually at the bottom of the .designer.vb file. This line looks like:
Code:
Friend WithEvents fsFishSlider As SlideFish
This is the one line that is never quietly deleted.
2) There is the place where the control is created, which is generally at the beginning of InitializeComponents(). The relevant line looks like this:
Code:
Me.fsFishSlider = New SlideFish
At unpredictable times, this line simply vanishes.
3) There is the place where the control is added to the panel that holds it, which looks like:
Code:
Me.pFishNumbers.Controls.Add(Me.fsFishSlider)
At unpredictable times, this line also simply vanishes, sometimes with the control creation line, sometimes without it.
4) There is a block of property settings, which look like this:
Code:
'
'hsNumberOfFish
'
Me.fsFishSlider.LargeChange = 200
Me.fsFishSlider.Location = New System.Drawing.Point(0, 216)
Me.fsFishSlider.Maximum = 100000
Me.fsFishSlider.Minimum = 0
Me.fsFishSlider.Name = "fsFishSlider"
Me.fsFishSlider.Size = New System.Drawing.Size(520, 25)
Me.fsFishSlider.SmallChange = 100
Me.fsFishSlider.TabIndex = 8
Me.fsFishSlider.Value = 0
To be fair, I've used a variety of different property settings. Originally, I used a trackbar, then changed it over to be a SlideFish. This block tends to go away, as well.
None of these blocks ever show any errors, and the project builds without complaint. However, if I go over to look at the form, the panel is there, all the other controls are visible on the panel, but the slide fish doesn't show up. It doesn't show on the designer and it doesn't show as one of the controls on the form in the properties panel. Sometimes, just looking at the properties panel causes one or more of the blocks listed above to simply vanish from the designer file. I haven't seen any pattern as to which part vanishes.
If I try to look at the Document Outline view, that seems to wipe out all blocks from the designer.
The user control is defined in a dll that is targeting FW 4.5, so I thought that might be the problem. Therefore, I imported the user control into this project (which targets .NET5), but that didn't change the behavior. The user control builds just fine, but parts drop out of the designer file anyways.
The control is being quietly rejected, and I can't figure out why. Any suggestions?
My usual boring signature: Nothing
 
-
Dec 18th, 2021, 07:53 PM
#2
Re: UserControl and .NET 5
Can I see what the actual UserControl code is? Depending on the complexity of a UserControl, you can sometimes induce a lot of conflict with the Visual Studio designer if you don't account for it correctly. It's been a while since I wrote any custom control code but hopefully I remember enough to spot a problem
-
Dec 18th, 2021, 08:12 PM
#3
Re: UserControl and .NET 5
Does it matter that the user control is used in other dlls in the project as well as other forms in the dll that it is defined in? I compared the use to a form in a different dll that has been using the control for years. The only differences were these:
1) In this new form, I had the control on a panel...but I just decided that it doesn't even belong on the form (nor does the panel), so that's a change I'll be making tomorrow.
2) This new project is .NET5, whereas the usercontrol was originally built against FW 4.0, which was then migrated to 4.5.
This is largely a foray into seeing what issues, if any, I run into using .NET5 plugins in a FW based application. I might end up moving the whole project into .NET5, but am taking my time. Thus far, this is the only issue I have seen, and I don't know that it has anything to do with .NET5.
I've shut that down for the day. I'll pick it up again tomorrow.
My usual boring signature: Nothing
 
-
Dec 18th, 2021, 08:35 PM
#4
Re: UserControl and .NET 5
I wrote quite a bit of custom controls in previous years and I used to get problems with the designer making thing disappear all the time. Most of the time it used to be because I didn't implement certain things properly. Your problem might be different though.
Usually with problems like this, what I'd do is start simple and keep adding things until I encounter a problem. So for example, I'd just start with a blank empty UserControl and see if the same thing happens. If nothing happens then I'd add things to it one by one until I have something resembling the complete UserControl. This step by step approach is very tedious but sometimes this is what it takes to solve problems like this.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|