diff --git a/src/GetDocumentInsider/Commands/GetDocumentCommandWorker.cs b/src/GetDocumentInsider/Commands/GetDocumentCommandWorker.cs
index 752d65861f..020aca39d5 100644
--- a/src/GetDocumentInsider/Commands/GetDocumentCommandWorker.cs
+++ b/src/GetDocumentInsider/Commands/GetDocumentCommandWorker.cs
@@ -56,7 +56,23 @@ public static bool TryProcess(GetDocumentCommandContext context, IServiceProvide
try
{
- var serviceType = Type.GetType(serviceName, throwOnError: true);
+ Type serviceType = null;
+ foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
+ {
+ serviceType = assembly.GetType(serviceName, throwOnError: false);
+ if (serviceType != null)
+ {
+ break;
+ }
+ }
+
+ if (serviceType == null)
+ {
+ // As part of the aspnet/Mvc#8425 fix, make this an error unless the file already exists.
+ Reporter.WriteWarning(Resources.FormatServiceNotFound(serviceName));
+ return true;
+ }
+
var method = serviceType.GetMethod(methodName, new[] { typeof(TextWriter), typeof(string) });
var service = services.GetRequiredService(serviceType);
diff --git a/src/GetDocumentInsider/Properties/Resources.Designer.cs b/src/GetDocumentInsider/Properties/Resources.Designer.cs
index eaec18f2fe..32dbb0e128 100644
--- a/src/GetDocumentInsider/Properties/Resources.Designer.cs
+++ b/src/GetDocumentInsider/Properties/Resources.Designer.cs
@@ -220,6 +220,20 @@ internal static string MissingEntryPoint
internal static string FormatMissingEntryPoint(object p0)
=> string.Format(CultureInfo.CurrentCulture, GetString("MissingEntryPoint"), p0);
+ ///
+ /// Unable to find service type '{0}' in loaded assemblies.
+ ///
+ internal static string ServiceNotFound
+ {
+ get => GetString("ServiceNotFound");
+ }
+
+ ///
+ /// Unable to find service type '{0}' in loaded assemblies.
+ ///
+ internal static string FormatServiceNotFound(object p0)
+ => string.Format(CultureInfo.CurrentCulture, GetString("ServiceNotFound"), p0);
+
private static string GetString(string name, params string[] formatterNames)
{
var value = _resourceManager.GetString(name);
diff --git a/src/GetDocumentInsider/Resources.resx b/src/GetDocumentInsider/Resources.resx
index fffabb44f3..ae23a2aa32 100644
--- a/src/GetDocumentInsider/Resources.resx
+++ b/src/GetDocumentInsider/Resources.resx
@@ -162,4 +162,7 @@
Assembly '{0}' does not contain an entry point.
+
+ Unable to find service type '{0}' in loaded assemblies.
+
\ No newline at end of file
diff --git a/src/dotnet-getdocument/Properties/Resources.Designer.cs b/src/dotnet-getdocument/Properties/Resources.Designer.cs
index f2b9084ae1..28501e7880 100644
--- a/src/dotnet-getdocument/Properties/Resources.Designer.cs
+++ b/src/dotnet-getdocument/Properties/Resources.Designer.cs
@@ -305,7 +305,7 @@ internal static string FormatOutputDescription()
=> GetString("OutputDescription");
///
- /// Unable to retrieve '{0}' project metadata. Ensure '{1}' is set.
+ /// Unable to retrieve '{0}' project metadata. Ensure '$({1})' is set.
///
internal static string GetMetadataValueFailed
{
@@ -313,7 +313,7 @@ internal static string GetMetadataValueFailed
}
///
- /// Unable to retrieve '{0}' project metadata. Ensure '{1}' is set.
+ /// Unable to retrieve '{0}' project metadata. Ensure '$({1})' is set.
///
internal static string FormatGetMetadataValueFailed(object p0, object p1)
=> string.Format(CultureInfo.CurrentCulture, GetString("GetMetadataValueFailed"), p0, p1);