Search code examples
vb.netvisual-studiowinformswindows-forms-designerwindows-forms-core

Having trouble with set-up of Windows Forms appication (VB.NET) in Visual Studio


I have been asked to work on a piece of software. I am an intern developer and there are no other developers at this company. I was given a folder of C# source code that includes other folders as well as a .sln file.

I clicked the .sln file and learned that this was a Windows Forms application that was not written in C# but in Visual Basic using the .NET framework (VB.NET) if I understand correctly. I noticed at the top that the solution configurations was set to "Release" so I switched that to debug.
There was also a second project/ item in the solution that was not loading. It is called nameofsoftware_Installed. I downloaded an extension that detects dependencies so that it would load, but It appears that there is no code and maybe doesn't need to be in this folder.

I created a new Windows Forms Application using Visual Studio and I do not have the same amount of extra files.

View of the Solution Explorer:

enter image description here

When I hit start with or without debugging the code works. It did give me the option to turn off Only My Code.

I am still unsure as to whether or not I have set up everything correctly. There are some resource files that are showing up as greyed out as they are not "included" in project. Should I be right clicking on these and including them?

I am considering just taking each file and re-creating the project. However, as I am unfamiliar with this software, I don't know if there are any special configurations needed. The original creator of the software was a contractor who is too busy to speak with me to get me started. I know what I need to do in the code, but am struggling with setup and no one is able to help me.

I tried retargeting and rebuilding the solution, deleting the .suo files, and including every file in the solution explorer in the project.

I expected to either receive files to put into a VS project myself, as we do when college professors provide some header files and starter code, OR to be given a .sln that I could click on an get started. At the very least, I hoped to have some documentation on the software, how its works, how it is implemented. And maybe some basic guidance on getting started.

.vbproj opened in notepad

    <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProductVersion>
    </ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{3D798AFD-8946-4631-8CF5-12FA5B7468BF}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <StartupObject>_8816_Controller.My.MyApplication</StartupObject>
    <RootNamespace>_8816_Controller</RootNamespace>
    <AssemblyName>RATA Data Ware</AssemblyName>
    <FileAlignment>512</FileAlignment>
    <MyType>WindowsForms</MyType>
    <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
    <TargetFrameworkProfile />
    <IsWebBootstrapper>false</IsWebBootstrapper>
    <PublishUrl>publish\</PublishUrl>
    <Install>true</Install>
    <InstallFrom>Disk</InstallFrom>
    <UpdateEnabled>false</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>true</MapFileExtensions>
    <ApplicationRevision>0</ApplicationRevision>
    <ApplicationVersion>2.4.0.%2a</ApplicationVersion>
    <UseApplicationTrust>false</UseApplicationTrust>
    <BootstrapperEnabled>true</BootstrapperEnabled>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <PlatformTarget>x86</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <DefineDebug>true</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <OutputPath>bin\Debug\</OutputPath>
    <DocumentationFile>RATA Data Ware.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    <PlatformTarget>x86</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <DefineDebug>false</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DocumentationFile>RATA Data Ware.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup>
    <OptionExplicit>On</OptionExplicit>
  </PropertyGroup>
  <PropertyGroup>
    <OptionCompare>Binary</OptionCompare>
  </PropertyGroup>
  <PropertyGroup>
    <OptionStrict>Off</OptionStrict>
  </PropertyGroup>
  <PropertyGroup>
    <OptionInfer>On</OptionInfer>
  </PropertyGroup>
  <PropertyGroup>
    <ApplicationIcon>WispRefresh.ico</ApplicationIcon>
  </PropertyGroup>
  <PropertyGroup>
    <ApplicationManifest>My Project\app.manifest</ApplicationManifest>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Windows.Forms.DataVisualization" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <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" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="CalibrationSequence.Designer.vb">
      <DependentUpon>CalibrationSequence.vb</DependentUpon>
    </Compile>
    <Compile Include="CalibrationSequence.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="ChannelEditor.Designer.vb">
      <DependentUpon>ChannelEditor.vb</DependentUpon>
    </Compile>
    <Compile Include="ChannelEditor.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="ChartWindow.Designer.vb">
      <DependentUpon>ChartWindow.vb</DependentUpon>
    </Compile>
    <Compile Include="ChartWindow.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="Common.vb" />
    <Compile Include="Error_Form.Designer.vb">
      <DependentUpon>Error_Form.vb</DependentUpon>
    </Compile>
    <Compile Include="Error_Form.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="Error_Log.vb" />
    <Compile Include="MainForm.Designer.vb">
      <DependentUpon>MainForm.vb</DependentUpon>
    </Compile>
    <Compile Include="MainForm.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="My Project\AssemblyInfo.vb" />
    <Compile Include="My Project\Application.Designer.vb">
      <AutoGen>True</AutoGen>
      <DependentUpon>Application.myapp</DependentUpon>
      <DesignTime>True</DesignTime>
    </Compile>
    <Compile Include="My Project\Resources.Designer.vb">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <Compile Include="My Project\Settings.Designer.vb">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
    <Compile Include="Storage.vb" />
    <Compile Include="Working_Data.Designer.vb">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Working_Data.xsd</DependentUpon>
    </Compile>
    <Compile Include="Working_Data.vb">
      <DependentUpon>Working_Data.xsd</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="CalibrationSequence.resx">
      <DependentUpon>CalibrationSequence.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="ChannelEditor.resx">
      <DependentUpon>ChannelEditor.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="ChartWindow.resx">
      <DependentUpon>ChartWindow.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="Error_Form.resx">
      <DependentUpon>Error_Form.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="MainForm.resx">
      <DependentUpon>MainForm.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="My Project\Resources.resx">
      <Generator>VbMyResourcesResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.vb</LastGenOutput>
      <CustomToolNamespace>My.Resources</CustomToolNamespace>
      <SubType>Designer</SubType>
    </EmbeddedResource>
  </ItemGroup>
  <ItemGroup>
    <None Include="app.config" />
    <None Include="bin\Debug\RATA Data Ware.exe.config" />
    <None Include="bin\Release\RATA Data Ware.exe.config" />
    <None Include="My Project\app.manifest" />
    <None Include="My Project\Application.myapp">
      <Generator>MyApplicationCodeGenerator</Generator>
      <LastGenOutput>Application.Designer.vb</LastGenOutput>
    </None>
    <None Include="My Project\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <CustomToolNamespace>My</CustomToolNamespace>
      <LastGenOutput>Settings.Designer.vb</LastGenOutput>
    </None>
    <None Include="Working_Data.xsc">
      <DependentUpon>Working_Data.xsd</DependentUpon>
    </None>
    <None Include="Working_Data.xsd">
      <SubType>Designer</SubType>
      <Generator>MSDataSetGenerator</Generator>
      <LastGenOutput>Working_Data.Designer.vb</LastGenOutput>
    </None>
    <None Include="Working_Data.xss">
      <DependentUpon>Working_Data.xsd</DependentUpon>
    </None>
  </ItemGroup>
  <ItemGroup>
    <None Include="Resources\delete-icon24.jpg" />
    <None Include="Resources\Delete-icon.png" />
    <None Include="Resources\edit-icon.png" />
    <None Include="Resources\add-icon24.png" />
    <None Include="Resources\Refresh.ico" />
    <Content Include="bin\Debug\RATA Data Ware.exe" />
    <Content Include="bin\Debug\RATA Data Ware.pdb" />
    <Content Include="bin\Debug\RATA Data Ware.xml" />
    <Content Include="bin\Debug\Resources\WispRefresh.ico" />
    <Content Include="bin\Release\RATA Data Ware.exe" />
    <Content Include="bin\Release\RATA Data Ware.pdb" />
    <Content Include="bin\Release\RATA Data Ware.xml" />
    <Content Include="bin\Release\Resources\WispRefresh.ico" />
    <Content Include="Resources\back-icon48.png" />
    <Content Include="Resources\clipboard-icon_Pastel32.png" />
    <Content Include="Resources\Clock-icon32.png" />
    <Content Include="Resources\delete-icon48.png" />
    <Content Include="Resources\Excel-icon24.png" />
    <Content Include="Resources\forward-icon48.png" />
    <Content Include="Resources\save-icon32.png" />
    <Content Include="Resources\Time-icon.png" />
    <Content Include="Resources\WispRefresh.ico">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="WhyDoesntInstallerWork.txt" />
    <Content Include="WispRefresh.ico" />
  </ItemGroup>
  <ItemGroup>
    <BootstrapperPackage Include=".NETFramework,Version=v4.0">
      <Visible>False</Visible>
      <ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
      <Visible>False</Visible>
      <ProductName>Windows Installer 3.1</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>


Solution

  • The following isn't an answer, but may be helpful in ensuring that you've setup your Visual Studio environment correctly.

    Before getting started ensure that the correct workloads and individual components have been installed.

    Ensure that you have the correct VS Workloads and Individual Components installed.

    The following assumes that you've already installed Visual Studio 2022.

    Visual Studio Installer (Win 10):

    • In the Windows search box, type Visual Studio Installer. Click it to open it:

      enter image description here

    • Click Modify

    enter image description here

    • Click Workloads tab

    enter image description here

    • Ensure .NET desktop development is checked, if not, check it.

      enter image description here

    • Click Individual components

      enter image description here

    • Check desired .NET Framework SDK's and targeting pack (ex: .NET Framework 4.8 SDK, and.NET Framework 4.8 targeting pack). To see the .NET Framework version, open the project in Visual Studio. Then click Project => <project name> Properties. On left side click Application. Look at Target framework. Alternatively, open the .vbproj file using Notepad to find what the value is for TargetFrameworkVersion. Ensure that you select the .NET Framework SDK and .NET Framework targeting pack that matches the TargetFrameworkVersion. It's okay to install additional ones, such as v4.8.

      enter image description here

    • Check .NET Framework project and item templates

      enter image description here

    • Check .NET SDK

    • Check ClickOnce Publishing

    • Check NuGet package manager

    • Check Visual Studio SDK

    • Check Windows 10 SDK (10.0.xxxxx.0)

    • If you made any changes, in lower-right corner, select Download all, then install. Then click Modify (If no changes are made the button will show "Close" instead).

    Note: If you forgot to change from Install while downloading, don't interrupt it - let it complete. As long as your network is stable the result will be the same.


    Open Visual Studio 2022

    Note: The first time you open Visual Studio 2022, you may be prompted to select your desired configuration settings. Once configuration is complete, you'll be able to use Visual Studio 2022.

    In order to ensure that you see the main Visual Studio 2022 screen, as shown in the video, close Visual Studio. Then open Visual Studio 2022 again.

    You should see:

    enter image description here

    Since this is a new installation, let's complete some more configuration prior to beginning.

    • On the lower right, click enter image description here

    • In Visual Studio menu, click Tools

    • Select Options...

    Projects and Solutions:

    • Expand Project and Solutions

    • Select Locations

    • If desired, change the location for your projects by clicking the button with the three dots in it to the right of the TextBox.

      enter image description here

    • Select VB Defaults

    • For Option Explicit select On. For Option Strict, select On.

    Text Editor:

    • Expand Text Editor
    • Expand C#
    • Select General
    • On right side, check Line numbers
    • Expand Visual Basic
    • Expand Code Style
    • Select Intellisense
    • On right side, under Enter key behavior, select Only add new line on enter after end of fully typed word

    NuGet Package Manager:

    • Expand NuGet Package Manager

    • Select General

    • On right side, under Package Management, for Default package management format, select PackageReference

      Note: If working on an existing project, this setting should be set to match the existing package management format.

      How to determine if one's project uses Packages.config or PackageReference:

      Open the .vbproj file using Notepad. As an example, let's assume that NuGet package Newtonsoft.Json has been added to the project.

      If PackageReference is used, one will see:

      <ItemGroup>
        <PackageReference Include="Newtonsoft.Json">
          <Version>13.0.3</Version>
        </PackageReference>
      </ItemGroup>
      
      

      However, for Packages.config one sees:

      <None Include="packages.config" />
      

      and in one's solution folder (or project folder) one sees a folder named packages.

    • Click OK


    Since Visual Studio is already open, and we've clicked Continue without code, to create a new project one can do the following:

    • In the Visual Studio (VS) menu, click File

    • Select New

    • Select Project

    • To make it easier to find the desired project template, one can filter them by choosing the desired filter. We'll choose:

      enter image description here

    • Choose Windows Forms App (.NET Framework)

    • Click Next

    • Enter desired project name, location, and select desired Framework from drop-down. Then click Create.


    Open Solution Explorer

    • In VS menu, click View
    • Select Solution Explorer

    Open Properties Window

    • In VS menu, click View
    • Select Properties Window

    Open Toolbox

    • In VS menu, click View

    • Select Toolbox

      Note: The Toolbox is only available, when the form Design window is showing (ex: Form1.cs [Design] or Form1.vb [Design]).

    To Switch Between Code View and Designer View:

    • In Solution Explorer, expand <project name>. Then right-click Form1.vb (or Form1.cs). Select View Code or View Designer.

    To See Resources:

    • In VS menu, click Project
    • Select <project name> Properties
    • On left side, click Resources

    Update:

    To see a form's designer code, in Solution Explorer expand the form name (ex: Form1.vb). Then expand the child element (ex: Form1). Double-click Dispose (Boolean). Alternatively, one can use Notepad to open Form1.Designer.vb