I suspect the problem is that you've got a different Input
class. You're loading SimFile.dll dynamically, but creating an instance of Input
statically. That means the Input
class you're creating isn't the same as the one in the assembly you're invoking the method in.
If you already have a reference to SimFile.dll
in your code, you shouldn't load it explicitly - that's just going to confuse things. If you don't have a reference to SimFile.dll
in your project, then presumably you're creating an instance of a completely different Input
type.
Either way, you should be able to fix the problem by using the Input
class within the dynamically-loaded assembly:
Type inputType = assembly.GetType("Input")
object input = Activator.CreateInstance(inputType);
inputType.GetProperty("Numberi").SetValue(input, -5);
// Rest of code as before