@ -106,11 +106,20 @@ namespace ICSharpCode.FormsDesigner.Services
this . formSourceFileName = formSourceFileName ;
this . formSourceFileName = formSourceFileName ;
}
}
static readonly Dictionary < IProjectContent , object > projectContentsCurrentlyLoadingAssembly = new Dictionary < IProjectContent , object > ( ) ;
/// <summary>
/// <summary>
/// Loads the assembly represented by the project content. Returns null on failure.
/// Loads the assembly represented by the project content. Returns null on failure.
/// </summary>
/// </summary>
public static Assembly LoadAssembly ( IProjectContent pc )
public static Assembly LoadAssembly ( IProjectContent pc )
{
{
// prevent StackOverflow when project contents have cyclic dependencies
// Very popular example of cyclic dependency: System <-> System.Xml (yes, really!)
if ( projectContentsCurrentlyLoadingAssembly . ContainsKey ( pc ) )
return null ;
projectContentsCurrentlyLoadingAssembly . Add ( pc , null ) ;
try {
// load dependencies of current assembly
// load dependencies of current assembly
foreach ( IProjectContent rpc in pc . ReferencedContents ) {
foreach ( IProjectContent rpc in pc . ReferencedContents ) {
if ( rpc is ParseProjectContent ) {
if ( rpc is ParseProjectContent ) {
@ -124,6 +133,9 @@ namespace ICSharpCode.FormsDesigner.Services
}
}
}
}
}
}
} finally {
projectContentsCurrentlyLoadingAssembly . Remove ( pc ) ;
}
if ( pc . Project ! = null ) {
if ( pc . Project ! = null ) {
return LoadAssembly ( ( ( IProject ) pc . Project ) . OutputAssemblyFullPath ) ;
return LoadAssembly ( ( ( IProject ) pc . Project ) . OutputAssemblyFullPath ) ;