Friday, July 26, 2013

Solve CLR error - .NET Frameworks

The reason of the problem is that the .NET Framework 4.0 has different requirement for app.config.

Solution: Change App.config

.NET 4.0 require config Sections in the App.config. If this section is missing in a app.config file, the program will crash at start. Details see http://msdn.microsoft.com/en-us/library/ms228245.aspx The following code example shows how to define a custom configuration section and define settings for that section.

I also found there is error when I compile the setup project.

Because the VS2010 has no support for .NET Framework 2.0. It gives warning or error in compilation for .NET Framework 2.0 component. If a project needs it for setup as "Launch condition", these things need to be changed. Step 1. Change .vdproj file 1)Unload the installer or solution 2) open the .vdproj file in notepad and find the section "LaunceCondition" and update to:
"FrameworkVersion" = "8:.NETFramework,Version=v4.0"
or "FrameworkVersion" = "8:.NETFramework,Version=v4.0,Profile=Client" 

"LaunchCondition"
 {               
     {
"Name" = "8:.NET Framework"
"Message" = "8:[VSDNETMSG]"
 "FrameworkVersion" = "8:.NETFramework,Version=v4.0"
"AllowLaterVersions" = "11:FALSE"
 "InstallUrl" = "8:http://go.microsoft.com/fwlink/?LinkId=131000"
     }
 }
Step 2.
Copy the bootstrapper package to VS2010
If you take the .NET 2.0 package from the VS2008 bootstrapper packages folder and copy it to the corresponding location for VS2010, it works fine. I tested it in a virtual machine running Windows XP and no .NET. On Vista or Windows 7, the VS2008 packages are here: c:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFX (this is .NET 2.0)
On Vista or Windows 7, the VS2010 packages are here: c:\Program Files\Microsoft SDKs\Windows\v7.0A\BootStrapper\Packages
Then the setup won't give error any more.