Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 不带visual studio 2015版本的引用dll_C#_Dll_Visual Studio 2015_Version_Assembly Binding Redirect - Fatal编程技术网

C# 不带visual studio 2015版本的引用dll

C# 不带visual studio 2015版本的引用dll,c#,dll,visual-studio-2015,version,assembly-binding-redirect,C#,Dll,Visual Studio 2015,Version,Assembly Binding Redirect,我有一个引用dll的应用程序,该dll将不断更改为新版本(具有向后兼容性) 我的应用程序(内置于visual studio 2015)将与任何版本一起工作-问题是-我需要引用dll而不指定版本bec最新版本的dll将不断替换我项目中的dll(office要求),我不希望每次更新dll时都重新编译我的项目 我尝试了以下方法: AppDomain.CurrentDomain.AssemblyResolve += (sender, argsAssembly) => {

我有一个引用dll的应用程序,该dll将不断更改为新版本(具有向后兼容性)

我的应用程序(内置于visual studio 2015)将与任何版本一起工作-问题是-我需要引用dll而不指定版本bec最新版本的dll将不断替换我项目中的dll(office要求),我不希望每次更新dll时都重新编译我的项目

我尝试了以下方法:

AppDomain.CurrentDomain.AssemblyResolve += (sender, argsAssembly) =>
            {
                if (argsAssembly.Name.StartsWith the name of your dll)
                    return Assembly.Load(load the dll);
                return null;
            };
  • 在my.csproj文件中设置
    true


  • 我真的不知道该把我试过的第二件东西放在哪里,但似乎什么都不起作用

    用一种方法解决了它-但我仍在寻找更好的答案-

    我通过加载dll从程序集创建了一个类

    像-

    Assembly assemblyInstance=Assembly.Load(dll);
    Type[] asseblyTypes=assemblyInstance.GetTypes();
    
    foreach(Type t in asseblyTypes)
    {
        if(t.fullName.Equals(name of class i want))
        {
            try to get the method info by t.GetMethod(name,type of parameter)
            and then do methodInfo.Invoke...
        }
    }
    

    工作。。。但是我想要一个更好的答案

    更简洁的方法是使用AssemblyResolve事件-

    如下所示:

    AppDomain.CurrentDomain.AssemblyResolve += (sender, argsAssembly) =>
                {
                    if (argsAssembly.Name.StartsWith the name of your dll)
                        return Assembly.Load(load the dll);
                    return null;
                };
    

    发行版本是否编号?通常小版本不会引起问题,大版本会。在引用属性中,是否将“特定版本”设置设置为false?你看过绑定重定向吗?您是否试图在同一目录中同时拥有多个DLL副本?否-它不是次要版本-它是一个经常更新为全新版本的DLL。我试着将特定的版本设置为false-这不起作用。我读到这只是为了编译时。不尝试拥有dll的多个副本-一个不断更新的dll。请帮忙!这是强签名的“将不断更改的dll”吗?是的,它是强签名的