@ -106,23 +106,35 @@ 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 )
{
{
// load dependencies of current assembly
// prevent StackOverflow when project contents have cyclic dependencies
foreach ( IProjectContent rpc in pc . ReferencedContents ) {
// Very popular example of cyclic dependency: System <-> System.Xml (yes, really!)
if ( rpc is ParseProjectContent ) {
if ( projectContentsCurrentlyLoadingAssembly . ContainsKey ( pc ) )
LoadAssembly ( rpc ) ;
return null ;
} else if ( rpc is ReflectionProjectContent ) {
projectContentsCurrentlyLoadingAssembly . Add ( pc , null ) ;
ReflectionProjectContent rrpc = ( ReflectionProjectContent ) rpc ;
if ( rrpc . AssemblyFullName ! = typeof ( object ) . FullName
try {
& & ! FileUtility . IsBaseDirectory ( GacInterop . GacRootPath , rrpc . AssemblyLocation ) )
// load dependencies of current assembly
{
foreach ( IProjectContent rpc in pc . ReferencedContents ) {
if ( rpc is ParseProjectContent ) {
LoadAssembly ( rpc ) ;
LoadAssembly ( rpc ) ;
} else if ( rpc is ReflectionProjectContent ) {
ReflectionProjectContent rrpc = ( ReflectionProjectContent ) rpc ;
if ( rrpc . AssemblyFullName ! = typeof ( object ) . FullName
& & ! FileUtility . IsBaseDirectory ( GacInterop . GacRootPath , rrpc . AssemblyLocation ) )
{
LoadAssembly ( rpc ) ;
}
}
}
}
}
} finally {
projectContentsCurrentlyLoadingAssembly . Remove ( pc ) ;
}
}
if ( pc . Project ! = null ) {
if ( pc . Project ! = null ) {