CreateObject

Joe

Administrator
Staff member
FoxPro:
WITH this
    TRY
        loObj = CREATEOBJECT(.cProcessObj, .lRunProcessorTest)
    CATCH
    ENDTRY
ENDWITH
C#:
using System.Reflection;
try
{
    Type ObjectType = null;
    foreach (Assembly Asmb in AppDomain.CurrentDomain.GetAssemblies())
    {
        if (Asmb.FullName.ToUpper().Contains("QUALSET"))
        {
            Type[] Types = Asmb.GetTypes();
            foreach (Type t in Types)
            {
                if (t.IsClass && t.Name.ToUpper() == ProcessObj.ToUpper())
                {
                    ObjectType = t;
                    break;
                }
            }
        }
        if (ObjectType != null)
            break;
    }
    if (ObjectType != null)
    {
        Obj = Activator.CreateInstance(ObjectType, new Object[] { RunProcessorTest });
    }
    else
    {
        Error.LogError("Selector.Process()", "Cannot find processor in assemblies to create:  " + ProcessObj);
        return false;
    }
}
catch (Exception e)
{
    LogError("Processor Creation during Process()", e.Message, e.StackTrace);
    return false;
}
 
Last edited:

Joe

Administrator
Staff member
From VFPToolkit.NET:
        public static void CreateObject(){}

        /// <summary>
        /// Please refer further documentation in the .NET Framework on:
        /// Activator.CreateInstance() and Activator.CreateComInstance()
        /// Note: Please review GetInterface() to see how an Excel.Application can
        /// be created in .NET
        /// </summary>
 
Top