Skip to content

Commit

Permalink
Improve error handling in GXMetadata.cs when looking for an class in …
Browse files Browse the repository at this point in the history
…different name spaces.
  • Loading branch information
Claudia Beatriz Murialdo Garrone committed Sep 17, 2024
1 parent 4c87d15 commit 5becd8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
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

0 comments on commit 5becd8b

Please sign in to comment.