Weird fix no longer works for "Workflow.Targets(127,5): error : Compilation failed. Unable to load one or more of the requested types"
We have an x86 VS2008 project for .Net 3.5 SP1 using Workflow Foundation. On some computers it will compile, but others fail with:
Workflow.Targets(127,5): error : Compilation failed. Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Google brings up many solutions to different situations that can result in this error, but the only one I've found which worked for us is this: swap the order of the two <Import Project... />
tags in the .csproj file. Why this works is a mystery but the change allowed the project to compile and work on the computers which it wouldn't before (though it also caused problems on one machine that never required the change).
Is there any information about this problem and this weird fix? Lately the "fix" has become unusable. The project had been on the shelf for about a year, and now if the project is compiled with the tags swapped we get a run-time error when the workflow is initialized:
Cannot initialize 'StateMachineWorkflowActivity' that does not define a valid 'InitialStateName' property
If compiled without the tags swapped (using one of the machines that is capable of compiling it regardless of whether the tags are swapped), this run-time error no longer occurs and everything runs perfe开发者_如何学编程ctly.
Google again brings up many solutions to different situations that can result in this runtime error, but I've not found one that works for us and solving the original problem so that we don't have to swap the tags in the first place feels like a better direction to be looking in. The project was being compiled successfully a year ago (with the tags swapped), so things that have changed since then would include later versions of the dot net framework being installed in addition to 3.5 SP1 - the computers have all had the dotnet updates applied (but some computers are newer than others so would have got them all together). The project isn't set up on enough machines for meaningful patterns to be observable, given the number of confounding variables. One machine that can build it is a x64 Win7 with VS2008 and VS2010 installed (updating its VS2008 RTM to VS2008 SP1 didn't change it), one machine that can't build it is an x86 WinXP first using MSBuild, then with VS2008 installed, then with both VS2008 and VS2010 installed. MSBuild was able to build it a year ago and can still build with the tags swapped.
There is a hotfix that patches a couple of situations that cause the compile-time "Compilation failed. Unable to load one or more of the requested types."
problems, but while our project seemed to matched the description in kb2023579 the hotfix that replaces it did not help - one of the many solutions that did not work for us.
(We need to solve this because the build server is one of the machines it doesn't compile on)
For this issue:
Cannot initialize 'StateMachineWorkflowActivity' that does not define a valid 'InitialStateName' property
Try to check your namespace in the XOML file
namespace MyAssembly.SomeNamepace
{
class Foo{}
}
then your x:class attribute should be x:class="MyAssembly.SomeNamepace.Foo"
精彩评论