The product release changes the name of the library, how to be compatible with the old and new?

We have a product that uses a link from a third-party vendor. With the release of their new product, they renamed this Link to a new name.

We want one version of our application to be compiled so that it can work with both the old and the new library name.

Basically there are no changes, only one method is renamed between the parts of the library that we use, but I have no idea how to develop our application to handle both.

If I need, we can deploy the code to work with both, but I would really like to have some kind of adapter that goes through all the calls, and then goes to the old or new.

After installing a new application, it deletes the old library, so the old code will not compile.

Any pointers to what I can try, and how can I get around this problem?

In addition, the application was developed in C # using Visual Studio 2005.

+3
source share
2 answers

See Redirecting assembly bindings ... You can redirect old DLL links to a new one. You will need to write a wrapper method for the renamed method. This is a real pain in the butt. I'm going to spit it off my head, so I do not guarantee accuracy or compilation, but you can consider it a pseudo-code ...

private bool _useOldMethodName = false;
public void MethodAlias(string arg1)
{
    if (_useOldMethodName)
    {
        Reference.OldFunctionName(arg1);
    }
    else
    {
        try
        {
            Reference.NewFunctionName(arg1);
        }
        catch (MethodNotFoundException mnfe)
        {
            _useOldMethodName = true;
        }
    }
}

Something like that. This is not perfect anyway.

, ? DLL , ...

+3

:

  • , , , ( - )
  • Reflection , , . , . :

    type = .GetType(); MemberInfo [] mbrInfoArray = type.GetMethods();

Invoke.

+1

Source: https://habr.com/ru/post/1711785/


All Articles