Friday, March 23, 2012

MSB3247 or System.ArgumentOutOfRangeException - window not showing

Sometimes when searching for a solution to a problem you may find that you should be searching for something that after all, it's not what you think it caused the problem.
Imagine you are getting an error message like the following:
here's what it says:
An Unhandled Exception has occurred
Click here to reload the designer
Details:
System.ArgumentOutOfRangeException
startIndex cannot be larger than length of string.Parameter name: startIndex
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) at MS.Internal.Host.PersistenceSubsystem.ExtractSourceFileInfo(Uri uri) at MS.Internal.Host.PersistenceSubsystem.FormatInnerXamlParseException(Exception ex) at MS.Internal.Host.PersistenceSubsystem.ReportException(Exception ex, TextModel model, Int64 sourceVersion) at MS.Internal.Host.PersistenceSubsystem.Load() at MS.Internal.Host.Designer.Load() at MS.Internal.Designer.VSDesigner.Load() at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load() at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView view) at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view) at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view) at MS.Internal.Host.Isolation.IsolatedDesigner.Load() at MS.Internal.Designer.DesignerPane.LoadDesignerView(Boolean isReload)
------------------------------------------------------------------------------------------------------------------
Now, the fun part is that when you do what the IDE says "Click here to reload the designer", nothing new happens. You get stuck with the same error all the time :( Sad, isn't it?
Well, i'll suggest the following first.
1) load the project in Microsoft Expression Blend, if you access to it;
2) Download SharpDevelop
You can find it in the following location:
If everything works has i expect, then everything should be working on MS Expression Blend, and you should be seeing the window as it is, but in SharpDevelop you should be receiving an error message too, like in the Visual Studio IDE. The error message should say something like:
"Build started.
Warning MSB3247: Found conflicts between different versions of the same dependent assembly.
Build finished successfully."
So once again you can't see the window but you can compile. But now you have a new information about the problem: "MSB3247"
So, why didn't the VS IDE warned you about this issue? well, first you have to tell him (VS IDE) that you are a pro and that you want to have full access to the information given in the output when compiling. So,... go to
Tools -> Options ->Projects and Solutions -> Build and Run
There's an option saying:
MSBuild project buil output verbosity.
change this option so that it reads:
"Detailed"
Ok, so now, you became a "pro" to Visual Studio :)
Compile the project and you should see new information in the output window.
But what are you going to do with all that information in the output window (depeding on your project size)? Well, since you installed SharpDevelop and saw that the problem had to do with MSB3247, then you should search the output window for "MSB3247". When you do it, you'll sould read something like:
"warning MSB3247: Found conflicts between different versions of the same dependent assembly."
Double-click on this line and you should be taken to the "Microsoft.Common.targets" file, to the "ResolveAssemblyReference" node.
The way you can solve this issue is to use the "ildasm" tool, from the "Microsoft Windows SDK Tools", by searching for the reference and in which files it's being used. Replace the ".dll's", if it's the case, by another ones with other versions, or remove them from the project, in the project explorer

No comments:

Post a Comment