- VB.NET
- Windows Forms
- Thread starteraaaron
- Start dateJan 17, 2021
A
aaaron
Well-known member
- Joined
- Jan 23, 2011
- Messages
- 219
- Programming Experience
- 10+
- Jan 17, 2021
- #1
I'm converting to Net5. I have 40 out of 41 projects converted OK
The remaining project will not let me reference System.WindowsForms.
There are two versions of System.WindowsForms, I've been using 2.4 routinely (I hope that's what I should be doing).
I tried them both in the troublesome procedure.
What happens is: I select Project/Add COM Reference and then check System.WindowsForms.
Close the dialog and reopen it and see that the check is gone.
I did this because checking it did not have any effect on the error I was trying to fix.
I'm using System.Windows.Forms.StatusBarPanel. Could that be a problem in Net5?
BTW. I also tried including:
VB.NET:
<ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> <Import Include="System.Collections" /> <Import Include="System.Collections.Generic" /> <Import Include="System.Data" /> <Import Include="System.Drawing" /> <Import Include="System.Diagnostics" /> <Import Include="System.Windows.Forms" /> <Import Include="System.Linq" /> <Import Include="System.Xml.Linq" /> <Import Include="System.Threading.Tasks" /> </ItemGroup>
In that case I also checked System.WindowsForms (I'm not sure it would show checked) but it was not checked.
Last edited:
Solution
-
JohnH
- Jan 17, 2021
aaaron123@roadrunner.com said:
I'm using System.Windows.Forms.StatusBarPanel. Could that be a problem in Net5?
StatusBarPanel Class (System.Windows.Forms)
Represents a panel in a StatusBar control. This class is not available in .NET 5 and later versions. Use the ToolStripStatusLabel control instead, which replaces and extends the StatusBarPanel control.
docs.microsoft.com
This class is not available in .NET 5.0 and later versions. Use the StatusStrip control instead, which replaces and extends the StatusBar control.
MenuStrip/ToolStrip/StatusStrip were introduced as replacements for Menu/ToolBar/StatusBar in .Net 2.0.
Sort by dateSort by votes
JohnH
VB.NET Forum Moderator
Staff member
- Joined
- Dec 17, 2005
- Messages
- 15,809
- Location
- Norway
- Programming Experience
- 10+
- Jan 17, 2021
- #2
aaaron123@roadrunner.com said:
I'm using System.Windows.Forms.StatusBarPanel. Could that be a problem in Net5?
StatusBarPanel Class (System.Windows.Forms)
Represents a panel in a StatusBar control. This class is not available in .NET 5 and later versions. Use the ToolStripStatusLabel control instead, which replaces and extends the StatusBarPanel control.
docs.microsoft.com
This class is not available in .NET 5.0 and later versions. Use the StatusStrip control instead, which replaces and extends the StatusBar control.
MenuStrip/ToolStrip/StatusStrip were introduced as replacements for Menu/ToolBar/StatusBar in .Net 2.0.
Upvote0Downvote
Solution
JohnH
VB.NET Forum Moderator
Staff member
- Joined
- Dec 17, 2005
- Messages
- 15,809
- Location
- Norway
- Programming Experience
- 10+
- Jan 17, 2021
- #3
aaaron123@roadrunner.com said:
The remaining project will not let me reference System.WindowsForms.
There are two versions of System.WindowsForms, I've been using 2.4 routinely (I hope that's what I should be doing).
I tried them both in the troublesome procedure.
What happens is: I select Project/Add COM Reference and then check System.WindowsForms.
No, you shouldn't. When <UseWindowsForms> is added to SDK project file the Microsoft.WindowsDesktop.App.WindowsForms framework dependency is added, this includes .Net 5 version of System.Windows.Forms.dll. Expand Dependencies in Solution Explorer and you'll see it.
Upvote0Downvote
JohnH
VB.NET Forum Moderator
Staff member
- Joined
- Dec 17, 2005
- Messages
- 15,809
- Location
- Norway
- Programming Experience
- 10+
- Jan 17, 2021
- #4
The Import Includes in project file is for importing namespaces (at project level) for existing referenced assemblies by the way.
Upvote0Downvote
ProtekNickz
Well-known member
- Joined
- Oct 22, 2009
- Messages
- 130
- Location
- UK
- Programming Experience
- 1-3
- Jan 18, 2021
- #5
It should just be "Import System.Windows.Forms" less the quotation marks and remebering the "." period(s).
Upvote0Downvote
jmcilhinney
VB.NET Forum Moderator
Staff member
- Joined
- Aug 17, 2004
- Messages
- 15,078
- Location
- Sydney, Australia
- Programming Experience
- 10+
- Jan 18, 2021
- #6
ProtekNickz said:
It should just be "Import System.Windows.Forms" less the quotation marks and remebering the "." period(s).
Nope. That's just importing a namespace at the file level. It's only tangentially related to referencing an assembly.
Upvote0Downvote
ProtekNickz
Well-known member
- Joined
- Oct 22, 2009
- Messages
- 130
- Location
- UK
- Programming Experience
- 1-3
- Jan 18, 2021
- #7
jmcilhinney said:
Nope. That's just importing a namespace at the file level. It's only tangentially related to referencing an assembly.
Ah well he/she did state in their first post that:
aaaron123@roadrunner.com said:
There are two versions of System.WindowsForms, I've been using 2.4 routinely (I hope that's what I should be doing).
and I just seen they missed a period, so ty for correcting me .
ProtekNickz xD
Upvote0Downvote
A
aaaron
Well-known member
- Joined
- Jan 23, 2011
- Messages
- 219
- Programming Experience
- 10+
- Jan 18, 2021
- #8
Microsoft.Common.CurrentVersion.targets(2701,5): warning MSB3290: Failed to create the wrapper assembly for type library "{215d64d2-031c-33c7-96e3-61794cd1ee61}". Type library 'System_Windows_Forms' was exported from a CLR assembly and cannot be re-imported as a CLR assembly.
JohnH said:
No, you shouldn't. When <UseWindowsForms> is added to SDK project file the Microsoft.WindowsDesktop.App.WindowsForms framework dependency is added, this includes .Net 5 version of System.Windows.Forms.dll. Expand Dependencies in Solution Explorer and you'll see it.
Thanks for the above. I'm getting use to looking at the Dependencies!
If I understand what you told me I have duplicates WindowsForms entries in the code below.
I think this {215d64d2-031c-33c7-96e3-61794cd1ee61} related to windowsforms (where is there a list of such Guids?)
And I think it is there because I added the reference to remove an error message.
If I now remove it I get many WindowsForms error messages again.
Like: MessageBox is not declared.
I'd appreciate any suggestions related to fixing the below.
BTW. It works as is but I want to take you reply seriously.
I'm still working on the other's replies!
VB.NET:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <RootNamespace>Cag.TextEditor</RootNamespace> <TargetFramework>net5.0-windows</TargetFramework> <UseWindowsForms>true</UseWindowsForms> <MyType>WindowsForms</MyType> </PropertyGroup> <ItemGroup> <COMReference Include="{215d64d2-031c-33c7-96e3-61794cd1ee61}"> <WrapperTool>tlbimp</WrapperTool> <VersionMinor>4</VersionMinor> <VersionMajor>2</VersionMajor> <Guid>215d64d2-031c-33c7-96e3-61794cd1ee61</Guid> </COMReference> <COMReference Include="tom.dll"> <WrapperTool>tlbimp</WrapperTool> <VersionMinor>0</VersionMinor> <VersionMajor>1</VersionMajor> <Guid>8cc497c9-a1df-11ce-8098-00aa0047be5d</Guid> <Lcid>0</Lcid> <Isolated>false</Isolated> </COMReference> <COMReference Include="{bee4bfec-6683-3e67-9167-3c0cbc68f40a}"> <WrapperTool>tlbimp</WrapperTool> <VersionMinor>4</VersionMinor> <VersionMajor>2</VersionMajor> <Guid>bee4bfec-6683-3e67-9167-3c0cbc68f40a</Guid> </COMReference> </ItemGroup> <ItemGroup> <ProjectReference Include="..\BitmapEditor\BitmapEditor.vbproj" /> <ProjectReference Include="..\ColorUtilities\ColorUtilities.vbproj" /> <ProjectReference Include="..\FractionUpDown\FractionUpDown.vbproj" /> <ProjectReference Include="..\LibraryCs2\LibraryCs2.csproj" /> <ProjectReference Include="..\LibraryDisk1\LibraryDisk1.vbproj" /> <ProjectReference Include="..\LibraryGraphic2\LibraryGraphic2.vbproj" /> <ProjectReference Include="..\LibraryNative0\LibraryNative0.vbproj" /> <ProjectReference Include="..\LibraryPrinter1\LibraryPrinter1.vbproj" /> <ProjectReference Include="..\LibraryTextEditor2\LibraryTextEditor2.vbproj" /> <ProjectReference Include="..\LibraryVb0\LibraryVb0.vbproj" /> <ProjectReference Include="..\LibraryVb1\LibraryVb1.vbproj" /> <ProjectReference Include="..\LibraryVb3\LibraryVb3.vbproj" /> <ProjectReference Include="..\UpDowns\UpDowns.vbproj" /> </ItemGroup></Project>
Upvote0Downvote
JohnH
VB.NET Forum Moderator
Staff member
- Joined
- Dec 17, 2005
- Messages
- 15,809
- Location
- Norway
- Programming Experience
- 10+
- Jan 18, 2021
- #9
You're missing the namespace imports at project level. (the Import Include)
In case you didn't know, you add references to assemblies (dll libraries) which in this case is part of single huge dependency package so that they can be loaded when your app loads, and import namespaces in order to use classes within those libraries. One dll can have many classes/types organized into namespaces. Some namespaces are imported at project project level because they are used all over the place, for example the System.Windows.Forms namespace, others that you use more occationally in a single code file you import with the Imports statement at top of the code file.
Upvote0Downvote
A
aaaron
Well-known member
- Joined
- Jan 23, 2011
- Messages
- 219
- Programming Experience
- 10+
- Jan 18, 2021
- #10
JohnH said:
You're missing the namespace imports at project level. (the Import Include)
1)Are you refering to
<OutputType>WinExe</OutputType>
What I should have included but didn't is the fact that in the file that works under Dependencies / Frameworks there is
MicrosoftWindowsDesktop.App.WindoesForms and, in the project file I have 215d64d2-031c-33c7-96e3-61794cd1ee61
I think I shouldn't need nor want two references to WindowsForms.
2)If I now remove {215d64d2-031c-33c7-96e3-61794cd1ee61} I get many WindowsForms error messages again.
Like: MessageBox is not declared.
I may have misinterpreted your earlier message but I thought MicrosoftWindowsDesktop.App.WindoesForms was what I needed.
Upvote0Downvote
JohnH
VB.NET Forum Moderator
Staff member
- Joined
- Dec 17, 2005
- Messages
- 15,809
- Location
- Norway
- Programming Experience
- 10+
- Jan 18, 2021
- #11
No I said
Import Include. As explained to be able to use a library it must be referenced that is that <UseWindowsForms> does, it add a bunch of libraries. Then you must import the namespaces, if not every type used in code must be qualified with the namespace, for example you can't write MessageBox
, it must be System.Windows.Forms.MessageBox
. Obviously a form with lots of Forms types in generated code will not compile.
This is also explained in point 3 of VB extras in the migration guide that I posted before: Migrate a Windows Forms app to .NET 5 - Windows Forms .NET
Upvote0Downvote
Similar threads
F
- Locked
- Question
QuestionAdd reference for winSCP DLL not working in Production Server
- FirasKassim
- Apr 29, 2015
- Third Party/Add-Ins
- Replies
- 1
- Views
- 10K
Apr 29, 2015
JohnH
J
- Question
Reference in the manifest does not match the identity of the downloaded assembly
- JA12
- May 16, 2014
- Deployment
- Replies
- 6
- Views
- 15K
Feb 18, 2015
JeremyLeach
J
G
- Question
Not set to instance of object for Service Reference
- GrexD
- May 22, 2012
- VB.NET General Discussion
- Replies
- 2
- Views
- 2K
May 23, 2012
GrexD
G
- Question
Problem with MDAC registration/registry problem, cannot add reference to ADO 6.0.
- Herman
- Feb 22, 2012
- VS.NET General Discussion
- Replies
- 0
- Views
- 2K
Feb 22, 2012
Herman
E
- Question
custom VBproj MSBuild project
- Evan1993
- Nov 3, 2009
- VB.NET General Discussion
- Replies
- 0
- Views
- 3K
Nov 3, 2009
Evan1993
E
Share this page
Latest posts
ResolvedGraphics in paint only?
- Latest: jmcilhinney
Graphics/GDI+
How can I validate Date.Now?
- Latest: genesix
VB.NET General Discussion
Salesforce CPQ - Product Rules Firing Timing
- Latest: vivansai1
Training, Conferences, Events
Questionwhat conftest.py should look like?
- Latest: jmcilhinney
Web Services
A
Questionhow to calculate in vb.net the nth root for biginteger
- Latest: andrews
VB.NET General Discussion
- VB.NET
- Windows Forms