diff --git a/src/System.ComponentModel.Composition/System.ComponentModel.Composition.sln b/src/System.ComponentModel.Composition/System.ComponentModel.Composition.sln
index 8bfa5e87791e..98f7b86c610e 100644
--- a/src/System.ComponentModel.Composition/System.ComponentModel.Composition.sln
+++ b/src/System.ComponentModel.Composition/System.ComponentModel.Composition.sln
@@ -7,6 +7,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.ComponentModel.Compo
{2D694AC8-A12F-4622-9405-74E20EC40C3A} = {2D694AC8-A12F-4622-9405-74E20EC40C3A}
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.ComponentModel.Composition.Noop.Assembly", "tests\System.ComponentModel.Composition.Noop.Assembly\System.ComponentModel.Composition.Noop.Assembly.csproj", "{396D6EBF-60BD-4DAF-8783-FB403E070A56}"
+ ProjectSection(ProjectDependencies) = postProject
+ {2D694AC8-A12F-4622-9405-74E20EC40C3A} = {2D694AC8-A12F-4622-9405-74E20EC40C3A}
+ EndProjectSection
+EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.ComponentModel.Composition", "src\System.ComponentModel.Composition.csproj", "{2D694AC8-A12F-4622-9405-74E20EC40C3A}"
ProjectSection(ProjectDependencies) = postProject
{DD3B8052-CE03-4159-8311-1CE1382C51B0} = {DD3B8052-CE03-4159-8311-1CE1382C51B0}
@@ -30,6 +35,10 @@ Global
{59F4682D-C41D-45A7-9798-16C75525BB1D}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{59F4682D-C41D-45A7-9798-16C75525BB1D}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
{59F4682D-C41D-45A7-9798-16C75525BB1D}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
+ {396D6EBF-60BD-4DAF-8783-FB403E070A56}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
+ {396D6EBF-60BD-4DAF-8783-FB403E070A56}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
+ {396D6EBF-60BD-4DAF-8783-FB403E070A56}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
+ {396D6EBF-60BD-4DAF-8783-FB403E070A56}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
{2D694AC8-A12F-4622-9405-74E20EC40C3A}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{2D694AC8-A12F-4622-9405-74E20EC40C3A}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{2D694AC8-A12F-4622-9405-74E20EC40C3A}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
@@ -44,6 +53,7 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{59F4682D-C41D-45A7-9798-16C75525BB1D} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
+ {396D6EBF-60BD-4DAF-8783-FB403E070A56} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
{2D694AC8-A12F-4622-9405-74E20EC40C3A} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
{DD3B8052-CE03-4159-8311-1CE1382C51B0} = {2E666815-2EDB-464B-9DF6-380BF4789AD4}
EndGlobalSection
diff --git a/src/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AssemblyCatalog.cs b/src/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AssemblyCatalog.cs
index d501f5c8504b..f05d654ce2e3 100644
--- a/src/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AssemblyCatalog.cs
+++ b/src/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AssemblyCatalog.cs
@@ -8,6 +8,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Globalization;
+using System.IO;
using System.Reflection;
using System.Threading;
using Microsoft.Internal;
@@ -566,7 +567,15 @@ private static Assembly LoadAssembly(string codeBase)
assemblyName.CodeBase = codeBase;
}
- return Assembly.Load(assemblyName);
+ try
+ {
+ return Assembly.Load(assemblyName);
+ }
+ //fallback attempt issue https://github.com/dotnet/corefx/issues/27433
+ catch (FileNotFoundException)
+ {
+ return Assembly.LoadFrom(codeBase);
+ }
}
}
}
diff --git a/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Noop.Assembly/Configurations.props b/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Noop.Assembly/Configurations.props
new file mode 100644
index 000000000000..77a4b65bc94a
--- /dev/null
+++ b/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Noop.Assembly/Configurations.props
@@ -0,0 +1,9 @@
+
+
+
+
+ netstandard;
+ netcoreapp;
+
+
+
\ No newline at end of file
diff --git a/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Noop.Assembly/System.ComponentModel.Composition.Noop.Assembly.csproj b/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Noop.Assembly/System.ComponentModel.Composition.Noop.Assembly.csproj
new file mode 100644
index 000000000000..12c34c5bbbd0
--- /dev/null
+++ b/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Noop.Assembly/System.ComponentModel.Composition.Noop.Assembly.csproj
@@ -0,0 +1,15 @@
+
+
+
+
+ {396D6EBF-60BD-4DAF-8783-FB403E070A56}
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Noop.Assembly/TestClass.cs b/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Noop.Assembly/TestClass.cs
new file mode 100644
index 000000000000..75e7475012f5
--- /dev/null
+++ b/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Noop.Assembly/TestClass.cs
@@ -0,0 +1,11 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.ComponentModel.Composition.Noop.Assembly
+{
+ [Export]
+ public class TestClass
+ {
+ }
+}
diff --git a/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Tests.csproj b/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Tests.csproj
index 72fe4fde46f7..4fa3445ffbeb 100644
--- a/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Tests.csproj
+++ b/src/System.ComponentModel.Composition/tests/System.ComponentModel.Composition.Tests.csproj
@@ -187,5 +187,15 @@
+
+
+
+
+
+ false
+ content
+ PreserveNewest
+
+
-
\ No newline at end of file
+
diff --git a/src/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/Hosting/AssemblyCatalogTests.cs b/src/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/Hosting/AssemblyCatalogTests.cs
index cd37556d0518..b5e8d4cb9ec3 100644
--- a/src/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/Hosting/AssemblyCatalogTests.cs
+++ b/src/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/Hosting/AssemblyCatalogTests.cs
@@ -1081,5 +1081,18 @@ public void ToString_ShouldReturnICompositionElementDisplayName()
Assert.Equal(catalog.DisplayName, catalog.ToString());
}
}
+
+ [Fact]
+ public void NonStaticallyReferencedAssembly()
+ {
+ string testAssembly = "System.ComponentModel.Composition.Noop.Assembly.dll";
+ var directory = TemporaryFileCopier.GetNewTemporaryDirectory();
+ Directory.CreateDirectory(directory);
+ var finalPath = Path.Combine(directory, testAssembly);
+ var sourcePath = Path.Combine(Directory.GetCurrentDirectory(), testAssembly);
+ File.Copy(sourcePath, finalPath);
+ var assemblyCatalog = new AssemblyCatalog(finalPath);
+ Assert.NotEmpty(assemblyCatalog);
+ }
}
}
diff --git a/src/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/Hosting/DirectoryCatalogTests.cs b/src/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/Hosting/DirectoryCatalogTests.cs
index 0ffb17cb9717..5d7613c36931 100644
--- a/src/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/Hosting/DirectoryCatalogTests.cs
+++ b/src/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/Hosting/DirectoryCatalogTests.cs
@@ -343,6 +343,19 @@ public void LoadedFiles_ContainsMultipleDllsAndSomeNonDll_ShouldOnlyContainDlls(
cat.LoadedFiles);
}
+ [Fact]
+ public void LoadedFiles_NonStaticallyReferencedAssembly()
+ {
+ string testAssembly = "System.ComponentModel.Composition.Noop.Assembly.dll";
+ var directory = TemporaryFileCopier.GetNewTemporaryDirectory();
+ Directory.CreateDirectory(directory);
+ var finalPath = Path.Combine(directory, testAssembly);
+ var sourcePath = Path.Combine(Directory.GetCurrentDirectory(), testAssembly);
+ File.Copy(sourcePath, finalPath);
+ var catalog = new DirectoryCatalog(directory, "*.dll");
+ Assert.NotEmpty(catalog);
+ }
+
[Fact]
public void Constructor_InvalidAssembly_ShouldBeFine()
{