How to load several mscorlib.dll and call their internal functions separately?

This is for research purposes. I have .NET Framework 2.0 installed and I want to dynamically load mscorlib.dll 1.1 in order to execute its specific internal function.

When I wrote this code in C #:

   static void Main(string[] args)
    {
        Assembly assem = Assembly.LoadFrom("C:\\mscorlib_my_private_1.1.dll");
        System.Type type = assem.GetType("System.Console");
        Type[] typeArray =new Type[1];
        typeArray.SetValue(typeof(string),0);
        System.Reflection.MethodInfo info = type.GetMethod("WriteLine", typeArray);
        object[] param = new object[1];
        param[0] = assem.FullName;
        type.InvokeMember("WriteLine",
        System.Reflection.BindingFlags.InvokeMethod, System.Type.DefaultBinder,
        "", param);
    }

Output: mscorlib, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089 "Not expected version 1.1 .

After a lot of googling, I know that mscorlib.dll is very special, but is it impossible?

+3
source share
4 answers

: mscorlib.dll .NET, . , .NET.

, - .NET mscorlib.dll, , , ( , ).

+2

mscorlib, .NET framework, . , , . mscorlib .

+1

. , .NET framework, , .

0

.NET 2.0 mscorlib.dll 1.1. , mscorlib 1.1, , pre-build script, DLL bin ( ), mscorlib.dll, . $(Location of mscorlib.dll)\mscorlib.dll $(TargetDir) .

0

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


All Articles