Compartir a través de


Early Mistakes: Not Setting Target Framework Correctly

As implied in my introduction, I made a few mistakes early on in my project development.  I am new to Visual Studio and new to .NET, but I jumped in with both feet and used the Visual Studio wizard to build an MVC2 project.  By default it sets the target framework to .NET Framework 4.0.

I happily commenced development using NerdDinner as the overall architecture template for my application.  I got quite a long way into development when I realized that GoDaddy only supported 3.5, so I went back and modified the target framework to 3.5, but unfortunately I was so far in (having already developed my database schema and LINQ to SQL classes) that everything started going horribly wrong, with error messages on compile like:

------ Build started: Project: HarrietsMembers, Configuration: Debug Any CPU ------
C:\Local Copies\HarrietsMembers\Controllers\MembersController.cs(33,29): error CS0029: Cannot implicitly convert type 'HarrietsMembers.Models.Member' to 'HarrietsMembers.Member'
C:\Local Copies\HarrietsMembers\Controllers\MembersController.cs(45,29): error CS0029: Cannot implicitly convert type 'HarrietsMembers.Models.Member' to 'HarrietsMembers.Member'
C:\Local Copies\HarrietsMembers\Controllers\MembersController.cs(58,29): error CS0029: Cannot implicitly convert type 'HarrietsMembers.Models.Member' to 'HarrietsMembers.Member'
C:\Local Copies\HarrietsMembers\Controllers\MembersController.cs(65,70): error CS1061: 'HarrietsMembers.Member' does not contain a definition for 'MemberNumber' and no extension method 'MemberNumber' accepting a first argument of type 'HarrietsMembers.Member' could be found (are you missing a using directive or an assembly reference?)
C:\Local Copies\HarrietsMembers\Controllers\MembersController.cs(69,53): error CS1061: 'HarrietsMembers.Member' does not contain a definition for 'GetRuleViolations' and no extension method 'GetRuleViolations' accepting a first argument of type 'HarrietsMembers.Member' could be found (are you missing a using directive or an assembly reference?)
C:\Local Copies\HarrietsMembers\Controllers\MembersController.cs(112,29): error CS0029: Cannot implicitly convert type 'HarrietsMembers.Models.Member' to 'HarrietsMembers.Member'
C:\Local Copies\HarrietsMembers\Controllers\MembersController.cs(122,29): error CS0029: Cannot implicitly convert type 'HarrietsMembers.Models.Member' to 'HarrietsMembers.Member'
C:\Local Copies\HarrietsMembers\Controllers\MembersController.cs(124,13): error CS1502: The best overloaded method match for 'HarrietsMembers.Models.MemberRepository.Delete(HarrietsMembers.Models.Member)' has some invalid arguments
C:\Local Copies\HarrietsMembers\Controllers\MembersController.cs(124,23): error CS1503: Argument 1: cannot convert from 'HarrietsMembers.Member' to 'HarrietsMembers.Models.Member'

Compile complete -- 9 errors, 0 warnings
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

I did some research but couldn’t find anything that would help me resolve these errors, so in the end decided to:

  1. Start with a fresh project, and this time set the target framework to 3.5 before doing anything else!
  2. Test deployment of the skeleton application to see if it would work on GoDaddy before doing any more coding (should have done this first, right?).  The MVC sample deployed fine, excepting that I had to include the MVC framework in my application for deployment since they are not installed by default on my hosted server.