C SHARP AND MYSQL DATABASE CRUD TUTORIAL 22 How To Connect To MySql Database Part 3 Changing The Target Framework

C# AND MYSQL DATABASE CRUD TUTORIAL #22 – How To Connect To MySql Database – Part 3 Changing The Target Framework

VIDEO TUTORIAL

C# AND MYSQL DATABASE CRUD TUTORIAL #22 – How To Connect To MySql Database – Part 3 Changing The Target Framework

This Tutorial Shows How To Connect To MySql Database – Part 3 Changing The Target Framework In C Sharp .Net Windows Forms Application using visual studio 2010.

I had to change the configuration xml file targeted framework to 4.5.2 from 4.0 because i was getting this error “The primary reference “MySql.Data” could not be resolved because it was built against the “.NETFramework,Version=v4.5” framework. This is a higher version than the currently targeted framework “.NETFramework,Version=v4.0”.”.

How To Change The Target Framework In Visual Studio 2010 by updating the .csproj Xml File
How To Change The Target Framework In Visual Studio 2010 by updating the .csproj Xml File

How To Change The Target Framework In Visual Studio 2010 by updating the .csproj Xml File

This solution fixes the above error.

I have .NETFramework Version=v4.5.2 already installed in windows 7. Am going to point my project to this version in my settings.

How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File - FW 452
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – FW 452

To Check currently selected framework version right click on your project then select properties.

How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File - Properties
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – Properties

Click on application tab and check the target framework. You can choose different framework from the drop down list.

How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File - Target Framework
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – Target Framework

Right click on your project and select “Unload Project”.

How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File - Unloading project
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – Unloading project

Right click on unloaded project and select edit (ProjectName) .csproj.

How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File - Edit .csproj
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – Edit .csproj

Change The following sections to targeted framework version.

How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File - Before Changing FW
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – Before Changing FW

In this case am targeting .NET Framework version 4.5.2

How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File - XML File
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – XML File

Save your settings the right click on project name and select “Reload Project”.

How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File - Reload Project
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – Reload Project

Click Okay When you are prompted to close open document.

How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File - Close Open Doc
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – Close Open Doc

Project is reloaded, And it’s available in solution explorer.

How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File - Project Reloaded
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – Project Reloaded

Try to run your project again and it should run without any problem.

.CSPROJ XML FILE AFTER RECTIFYING THE ERROR.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.5.2" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProductVersion>8.0.30703</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{8C91C6DC-A0DD-4EA2-AA0E-5C49F949BC67}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>JAVAANDMYSQLDATABASECRUD</RootNamespace>
    <AssemblyName>JAVAANDMYSQLDATABASECRUD</AssemblyName>
    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
    <TargetFrameworkProfile>
    </TargetFrameworkProfile>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <PlatformTarget>x86</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    <PlatformTarget>x86</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup>
    <StartupObject>
    </StartupObject>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="MySql.Data, Version=8.0.17.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\..\Downloads\mysql-connector-net-8.0.17-noinstall (1)\v4.5.2\MySql.Data.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Form1.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="Form1.Designer.cs">
      <DependentUpon>Form1.cs</DependentUpon>
    </Compile>
    <Compile Include="MySQLDatabaseConnection.cs" />
    <Compile Include="Person.cs" />
    <Compile Include="PersonData.cs" />
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <EmbeddedResource Include="Form1.resx">
      <DependentUpon>Form1.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
      <DesignTime>True</DesignTime>
    </Compile>
    <None Include="app.config" />
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
    <Compile Include="Properties\Settings.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <None Include="Resources\x-button.png" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Resources\plus-1.png" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Resources\refresh-24.png" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Resources\x-button1.png" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Resources\clear.png" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>

Leave a Reply

Your email address will not be published. Required fields are marked *