Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error handling when looking for an class in different name spaces #1066

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ internal static Type GetHandlerType(string assemblyName, string className)
try
{

objType = GeneXus.Metadata.ClassLoader.FindType(assemblyName, className, null);
objType = GeneXus.Metadata.ClassLoader.FindType(assemblyName, className, null, false, true);
if (objType == null)

objType = Assembly.Load(new AssemblyName(assemblyName)).GetType(className);
Expand Down
19 changes: 12 additions & 7 deletions dotnet/src/dotnetframework/GxClasses/Helpers/GXMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ static public void Execute(object instance, string mthd, Object[] args)
}
}
static ConcurrentDictionary<string, Type> loadedAssemblies = new ConcurrentDictionary<string, Type>();
static public Type FindType(string defaultAssemblyName, string clss, Assembly defaultAssembly, bool ignoreCase = false)
static public Type FindType(string defaultAssemblyName, string clss, Assembly defaultAssembly, bool ignoreCase = false, bool ignoreError=false)
{
return FindType(defaultAssemblyName, string.Empty, clss, defaultAssembly, ignoreCase);
return FindType(defaultAssemblyName, string.Empty, clss, defaultAssembly, ignoreCase, ignoreError);
}
//ns = kb Namespace
//clssWithoutNamespace = fullname genexus object (includes module), p.e. genexus.sd.synchronization.offlineeventreplicator
static public Type FindType(string defaultAssemblyName, string ns, string clssWithoutNamespace, Assembly defaultAssembly, bool ignoreCase = false)
static public Type FindType(string defaultAssemblyName, string ns, string clssWithoutNamespace, Assembly defaultAssembly, bool ignoreCase = false, bool ignoreError = false)
{

string clss = string.IsNullOrEmpty(ns) ? clssWithoutNamespace : string.Format("{0}.{1}", ns, clssWithoutNamespace);
Expand Down Expand Up @@ -143,7 +143,7 @@ static public Type FindType(string defaultAssemblyName, string ns, string clssWi
{
if (ns != appNS)
{
return FindType(defaultAssemblyName, appNS, clssWithoutNamespace, defaultAssembly);
return FindType(defaultAssemblyName, appNS, clssWithoutNamespace, defaultAssembly, ignoreCase, ignoreError);
}
}
if (objType == null)
Expand All @@ -168,7 +168,7 @@ static public Type FindType(string defaultAssemblyName, string ns, string clssWi
defaultAssemblyName = parts[1];
clss = parts[0];
}
return FindType(defaultAssemblyName, string.Empty, clss, defaultAssembly);
return FindType(defaultAssemblyName, string.Empty, clss, defaultAssembly, ignoreCase, ignoreError);
}
}

Expand Down Expand Up @@ -207,8 +207,13 @@ static public Type FindType(string defaultAssemblyName, string ns, string clssWi
}
if (objType == null)
{
GXLogging.Error(log, "Failed to load type: " + clss + " from currentdomain");
throw new GxClassLoaderException("Failed to load type: " + clss);
if (ignoreError)
GXLogging.Warn(log, "Failed to load type: " + clss + " from currentdomain");
else
{
GXLogging.Error(log, "Failed to load type: " + clss + " from currentdomain");
throw new GxClassLoaderException("Failed to load type: " + clss);
}
}
return objType;

Expand Down
Loading