Extending existing answers here. You will comment that you do not want to change the existing code. You do not have to do this.
[DllImport("one.dll", EntryPoint = "_test_mdl")] public static extern string _test_mdl1(string s); [DllImport("two.dll", EntryPoint = "_test_mdl")] public static extern string _test_mdl2(string s); public static string _test_mdl(string s) { if (condition) return _test_mdl1(s); else return _test_mdl2(s); }
You continue to use _test_mdl in your existing code and just put the if statement in the new version of this method, invoking the correct base method.
source share