c# - ReflectionTypeLoadException for Microsoft.Web.Administration running Test Project in VS2010 -
We have recently upgraded our VS2008 projects to VS2010 Our code base is still targeting the 3.5 version , But I'm sure most of you will know that the test project should be upgraded to framework version 4.0.
We have a special test that does not work yet that the testing project is targeting 4.0 framework. It tests all the test codes which are doing some type of reflection. Through some debugging I managed to reduce the problem.
The following code for any reason in the upgraded test project:
AppDomain.CurrentDomain.GetAssemblies ();
A reference will be returned for "Microsoft.VisualStudio.Enterprise.AspNetHelper". If I call
GetTypes ()
on this assembly again, then it says that this "Microsoft.Web.Administration" assembly loads does not make.
So I think there are some types in Microsoft. Visual Studio Enterprise. Aspen Heller ", which is in other kind of context in Microsoft or has some context, web administration.I have read something and realize that the administration DLL is part of the IIS 7. I am developing on XP and IIS7 is not installed
My real question is - Why is Microsoft.Visual Studios.In Enterprise.Assnet Heller VS2010 tests in my APP domain, but VS200 Not in 8 tests? Creating a simple console app that does the same thing is not a problem - only with test projects. How do I see it?
It is a bit trick, but the trick is:
<<> <<> AppDomain.CurrentDomain.GetAssemblies (). Where (a =>! IgnoredAssembly (a))
Where
Private bool isIgnoredAssembly (Assembly Assembly) {// TODO - Removing "System" Assemblies from Automatic Registration Find a better way to ignore Check = E-List & lt; Func & lt; assembly, bool & gt; & gt; () {asm = & gt; Asm.FullName.StartsWith ("Microsoft.", StringComparison.InvariantCulture), asm = & gt; Asm.FullName.StartsWith ("System.", String Comparison, Inverarnecture), ASM = & gt; Asm.FullName.StartsWith ("System,", String Comparison. Invertechnique), ASM = & gt; Asm.FullName.StartsWith ("CR_ExtUnitTest", String Comparion, Inverarnecture), ASM = & gt; Asm.FullName.StartsWith ("mscorlib,", String Comparison. Invertechnique), ASM = & gt; Asm.FullName.StartsWith ("CR_VSTest", StringComparison.InvariantCulture), asm = & gt; Asm.FullName.StartsWith ("DevExpress.CodeRush", StringComparison.InvariantCulture), asm = & gt; Asm.FullName.StartsWith ("IronPython", String Companion. Invertechniculture), ASM = & gt; Asm.FullName.StartsWith ("IronRuby", StringComparison.InvariantCulture)}}; Foreign currency (irregular checks in unseen investigation) {If (inquiry (assembly)) is true; } return false; }
(Taken - All credits for Steven Robbins.)
I think TODO says all this .. But I did not find a better way to heaven yet: -)
Comments
Post a Comment