Kbase P150793: 4GL/ABL: Is there a way to dynamically change the location of the assemblies.xml?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  8/10/2009 |
|
Status: Unverified
GOAL:
4GL/ABL: Is there a way to dynamically change the location of the assemblies.xml?
GOAL:
Can the directory of the assemblies.xml file be changed programmatically at runtime?
FACT(s) (Environment):
OpenEdge 10.2A
Windows
OpenEdge Category: Language (4GL/ABL)
FIX:
One way to do this is to use the standard System.Assembly:Load() and System.Assembly:LoadFrom() methods, which are part of .NET. This method does not require using an assembly.xml file. The developer needs to make sure these methods are called before running any r-code that depends on these assemblies. For more details on these methods, see the following link: http://msdn.microsoft.com/en-us/library/1009fa28.aspx .
Another way to do this is to change the path of the assemblies.xml file in order to force a reload of the file. The drawback to this method is that any assemblies that are currently loaded will NOT be unloaded. Following is the procedure OpenEdge Architect uses to force the AVM to reload the assemblies file. This code is provided as is and subject to the following caveats:
1. If an assembly is already loaded, this code will not unload and reload from a different place or version of the assembly.
2. Using this approach is neither documented nor supported.
3. The OpenEdge assembly loading mechanisms and APIs are subject to change without notice..
/* this class tells the AVM to reload the assemblies.xml file from the one that is under the control of the visual designer */
USING Progress.ClrBridge.AssemblyStore FROM ASSEMBLY.
DEFINE INPUT PARAMETER pcParams AS CHARACTER NO-UNDO.
DEFINE VARIABLE assemblyStore AS Progress.ClrBridge.AssemblyStore NO-UNDO.
DEFINE VARIABLE oldAssemblyDir AS CHARACTER NO-UNDO.
assemblyStore = Progress.ClrBridge.AssemblyStore:Instance.
oldAssemblyDir = assemblyStore:AssembliesPath.
IF LENGTH(pcParams) > 0 THEN DO:
assemblyStore:AssembliesPath = pcParams.
END.
assemblyStore:Load() NO-ERROR.
assemblyStore:AssembliesPath = oldAssemblyDir.
IF VALID-OBJECT(assemblyStore) THEN
DELETE OBJECT assemblyStore.
IF ERROR-STATUS:error THEN
RETURN ERROR-STATUS:GET-MESSAGE(1).
ELSE
RETURN "OK".