"Error HRESULT E_FAIL" using Class Designer in Visual Studio 2015 - vb.net

I am trying to show association relationships in my code using the Class Designer in Visual Studio 2015 (VB.NET). I am right clicking properties in my class and selecting Show as Association, which works correctly, and shows the association arrow.
However, when I try to use Show as Collection Association to show my many-to-one associations, I see the following dialog:
Error Dialog
I have searched for Error HRESULT E_FAIL has been returned from a call to a COM component, but the common issues with this seem to be during compilation, or issues with the designer. Others with this problem report it appearings in the output window, rather than pop up in a message box like my error.
Things I have tried:
repairing Visual Studio from Programs and Features in the Control Panel
Creating a new class diaram, and trying to use the Collective Association feature
suggestions from this thread: Error HRESULT E_FAIL when pasting references in Visual Studio
Any help with this issue would be much appreciated!

I had the exact same error trying to show a class diagram for a Xamarin.iOS project, while my Portable Class Libraies worked fine.
My low tech solution was to copy my classes to a temporary class library and make the diagram there...

Related

Visual Studio custom component design exception on Type property

I'm having a problem with a custom component in the VisualStudio designer.
This is a TextEdit in which I manage a property of type Type.
Code sample here
When I drop my custom TextEdit into a UserControl, no problem. I fill in the property, same thing. I can close my code and reopen it without worry.
If I close VisualStudio and reopen it, the design gives me an error.
Error
After much research it seems that it comes from the designer serializer class which inherits from CodeDomSerializers.
Do you have any ideas to solve this problem or already encountered this case?

VB in Visual Studio Adding a class module will it have access for the form.vb I've built?

Hello thanks for reading my question, I've build a user form with controls to control equipment via RS232 and USB. I've also added a separate class module "class.vb" to hold miscellaneous functions like writing to an ini file.
When I'm in the code section of the Form.vb and I type txb for text boxes that I have in the form visual studio pops up a nice list of all things in the form that start with txb.
However, when I do the same thing in my class.vb it does not do this and even if I type the whole thing such as txbModulation and then add the dot after it does not come up with the list of properties.
Does the class.vb have access to Form1.vb controls?
When I'm in the code section of the Form.vb and I type txb for text
boxes that I have in the form visual studio pops up a nice list of all
things in the form that start with txb.
This is because when you start typing a variable name, Visual Studio starts looking for a match. It looks in block scope first (a for or while loop maybe), then at local (function/sub) scope, and finally at class level (a form is a class). It will also look for any matches in Modules if you have them. See Scope in Visual Basic for more info.
Since the Form and your INI Class are different, they cannot see each other unless you pass references or somehow pass values via parameters to subs/functions.

Use Form(Of T) on VS Designer

I'm using vb.net (vs2010). I'm moving some winforms to a dll. I have a form that inherits from the one which has some subs and functions (like a test app).
My original form is: (.designer)
Partial Class Form1(Of T)
Inherits System.Windows.Forms.Form
....
End Class
Form itself contains code and a toolbar.
My test form is: (.designer)
Partial Class TestForm
Inherits Form1(Of Class1)
I get "Cannot create an instance of Form1`1[T] because Type.ContainsGenericParameters is true" when VS try to load the designer. App is usable. I can build and run the project without errors, but I need to add controls and some code to each new form.
I tried many ways:
Visual Studio 2008 Winform designer fails to load Form which inherits from generic class
How can I get Visual Studio 2008 Windows Forms designer to render a Form that implements an abstract base class?
http://www.codeproject.com/Questions/419770/Csharp-reflection-GetValue-from-a-field-in-generic
http://madprops.org/blog/Designing-Generic-Forms/
All examples are for C#, and I don't know if I'm missing something...
Is this a bad design ? I know this is a VS bug but still it seems everyone fixed it by these links.
EDIT:
I'm building a DLL. Form1 is on this DLL and TestForm is in a new project. Those links works if I'm in the same project (a.k.a. the dll).
Thanks!
Is this a bad design ? I know this is a VS bug
Bad design, not a VS bug. What you are trying to do is fundamentally incompatible with the way the Winforms designer works. It has strong WYSIWYG support, the designer creates an instance of the form's base class and allows code in that base class to run at design time. Which is why, for example, you can set the BackgroundImage property and it is immediately visible in the designer. The Form.OnPaintBackground() method paints it. The designer is not involved at all, it just sets the property.
To make that work, it must be able to create the base class object. It can't in your code, it doesn't know what kind of T to use. Not an issue when you design Form1, the T isn't needed yet since it derives from Form and creating an instance of Form is not a problem. Big issue when you design TestForm.
You'd probably argue that it should use Class1 as the T. It doesn't, the odds that it can use Reflection to discover the generic type argument from TestForm are exceedingly low. That requires the type to be compiled first. That's a chicken-and-egg problem at design time, the TestForm class gets compiled after you design it, not before or while you design.
It's not like you completely cannot use your approach. It builds and runs just fine. You just have to live without design time support for TestForm. That's usually a deal breaker, you have to re-consider your design.

Upgrading VB6 to VB.NET - Usercontrol not available because I could not compile the project

I have upgrade a VB6 project with the upgrade wizard to VB.NET.
I think I am in a vicious circle now:
There is one user control in my main form that is accessed from many other forms.
The IDE tells me that it shows the maximum amount of errors (102), and those shown are all like:
ucPage is not a member of prjMyProject.frmMain
ucPage is not a member of prjMyProject.frmMain
ucPage is not a member of prjMyProject.frmMain
EB1 is not a member of prjMyProject.frmMain
EB1 is not a member of prjMyProject.frmMain
I need to replace EB1 with a standard control, but I can not load the frmMain in the designer because the IDE is still mocking about the missing ucPage control on the form.
And the user control "ucPage" is not available in the toolbox because I have not been able to compile the project yet, so I can not even put it on my form.
This is a vicious circle, I think.
Does anybody have any suggestions on how to resolve it?
If you are converting VB6 projects to VB.NET (especially with UI), be prepared to encounter a lot of errors, because many VB6 tricks are not compatible with VB.NET. There is a way to manually edit form designer code in VB.NET:
Solution Explorer - Show All Files. Notice your form file in Solution Explorer can now be expanded.
Expand the form in question, and double-click Designer.vb file.
If designer file is not there, chances are designer code is sitting in the vb file under #Region "Form Designer generated code", usually on the very top.

VB.NET UserControl

I am trying to create a UserControl in VB.net, under VS2010. I have the code for the UserControl and I would like to add it to a form. My problem is that, according to every book and forum I have seen, after I build the UserControl, it should show up in the Toolbox. It doesn't. I even downloaded code from a book, the code executes perfectly, but their TrafficLight control doesn't go in the Toolbox (even though the book says it should - and that the only way to set its properties and to add it to the form is through the Control properties). I have tried to add the control to the form manually, by declaring it
Dim myObj As New SomeClass.SomeControl
and in the Designer.vb, identical with the buttons on the form:
Friend WithEvents myObj As SomeClass.SomeControl
With both, I get an error saying
'myObj' is already declared as 'Friend WithEvents myObj As SomeControl' in this class.
And either way, I get an error when I try to look at the design:
Could not find type 'SomeClass.SomeControl'. Please make sure that the assembly that contains this type is referenced. If this type is part of your development project, make sure the project has been successfully built using settings for your current platform or AnyCPU.
The control by itself builds and shows up in design view (not in the Toolbox though, even though it Imports System.ComponentModel and Inherits System.Windows.Forms.UserControl and... what else ? I tried to build it in a separate project, to see if I creating a separate dll will make a difference, though I really want it in the same project.
Please help ! (BTW I have reinstalled VS2010 and it did no good)
Thank you.
Look in Tools / Options / Windows Forms Designer and set "AutoToolboxPopulate" to True (but note that this can take a noticeable amount of time if you haver many (i.e. dozens) of user controls.