I have a test declared as:
[Test]
[ExpectedException(typeof(FaultException<ArgumentException>))]
public void ShouldNotBeAbleToDeleteASystemList()
When I run this in VS2008 targeting .net 3.5 it all works fine and the test passes as the exception is thrown.
I have migrated the solution to VS2010 and changed the target framework to 4.0 and now the test fails with the following details:
System.ServiceModel.FaultException`1[[System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b开发者_Go百科77a5c561934e089]] was expected
When I write the actual message to the console it is:
System.ServiceModel.FaultException`1[System.ArgumentException]: This is a system list and cannot be deleted (Fault Detail is equal to System.ArgumentException: Value does not fall within the expected range.).
I have checked and all projects are targeting .net 4.0.
What is going wrong?
For anyone else who might suffer such a problem. The reason for this error was that the exception was being thrown by a 3rd party component that was compiled against the .net 2.0 framework and the exception thrown was a .net 2.0 class. My code was not interpreting this as the same class. The solution was to change the config of the 3rd party component to add a <supportedRuntime ... />
line to the <startup>
section.
精彩评论