Q:

Reflection using generic types when class is unknown

I'm loading a model with reflection:
private void LoadAssemblies()
{
    Assembly assembly = Assembly.LoadFrom(modelDll);
    var types = assembly.GetTypes();

    inputType = assembly.GetType(types.Where(x => x.FullName.Contains("Input")).FirstOrDefault().FullName);
    outputType = assembly.GetType(types.Where(x => x.FullName.Contains("Output")).FirstOrDefault().FullName);

    inputModel = Activator.CreateInstance(inputType);
    outputModel = Activator.CreateInstance(outputType);

    inputModel = JsonConvert.DeserializeObject(jsonPredict);
}

Then I need to call a method with two generic types
// I can't convert this model loaded at runtime into a type to this generic method
var predEngine = mlContext.Model.CreatePredictionEngine<typeof(inputModel), typeof(outputModel)>(mlModel); 

I've tried
var instance = Activator.CreateInstance(typeof(ModelOperationsCatalog)); 

/* I get an error:
System.MissingMethodException: 'No parameterless constructor defined for this object.'

instance.GetType()
        .GetMethod("CreatePredictionEngine")
        .MakeGenericMethod(inputType, outputType)
        .Invoke(this, new object[] { });
*/

A:

Create a context
var mlContext = new MLContext();

Get the model
var model = mlContext.Model;

And then call the generic method on it passing it the instance and the parameters:
 typeof(ModelOperationsCatalog)
            .GetMethod("CreatePredictionEngine")
            .MakeGenericMethod(inputType, outputType)
            .Invoke(instance, new object[] { param1, param2 });*/

