When upgrading different beta versions of .NET MF 4.0 or doing final upgrade to RTM, one can experience problems in Vsual Studio during compilation. Typically this compilation error is shown:
Error 1 The "Microsoft.SPOT.Tasks.GetDeviceFrameworkPaths" task could not be loaded from the assembly Microsoft.SPOT.Tasks,Version=4.0..,Culture=neutral,PublicKeyToken=2670f5f21e7f4192. Could not load file or assembly 'Microsoft.SPOT.Tasks, Version=4.0, Culture=neutral, PublicKeyToken=2670f5f21e7f4192' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, and that the assembly and all its dependencies are available. C:\Program Files (x86)\MSBuild\Microsoft\.NET Micro Framework\v4.0\Device.targets 101 9
Error message points to C:\Program Files (x86)\MSBuild\Microsoft.NET Micro Framework\v4.0\Device.targets where everything seems to be fine. But Device.targets imoprts Tasks.settings from the same directory, which is very important. This files basicaly defines the name of TaskAssembly, which consists of two registry keys. And this is the problematic place. The necessary registry keys are sometimes not created or updated by the installation process (don’t know why).
<PropertyGroup> <CurBuildNumber>$(Registry:HKEY_LOCAL_MACHINE\Software\Microsoft\.NETMicroFramework\v4.0@BuildNumber)</CurBuildNumber> <CurRevNumber>$(Registry:HKEY_LOCAL_MACHINE\Software\Microsoft\.NETMicroFramework\v4.0@RevisionNumber)</CurRevNumber> <TasksAssembly>Microsoft.SPOT.Tasks,Version=4.0.$(CurBuildNumber).$(CurRevNumber),Culture=neutral,PublicKeyToken=2670f5f21e7f4192</TasksAssembly> </PropertyGroup>
To fix the problem, it’s necessary to change the registry value to proper its values. Specifically InstallRoot, BuildNumber, RevisionNumber. Following code snipet is .reg file that works for the .NET Micro Framework 4.0 SDK final version. In case of different version of the .NET MF, check the version value of C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.0\Tools\Microsoft.SPOT.Tasks.dll, to obtain proper BuildNumber and RevisionNumber.
32-bit system version
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETMicroFramework\v4.0] @="" "InstallRoot"="C:\\Program Files\\Microsoft .NET Micro Framework\\v4.0\\" "BuildNumber"="1681" "RevisionNumber"="0"
64-bit system version
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETMicroFramework\v4.0] @="" "InstallRoot"="C:\\Program Files (x86)\\Microsoft .NET Micro Framework\\v4.0\\" "BuildNumber"="1681" "RevisionNumber"="0"