1

My c# application uses two different pre-packaged parsers, that each use a different strong version of Antlr.Runtime.dll.

The application throws a FileLoadException, apparently because it correctly loaded only one of the versions and could not find the other.

The <app>\bin\x86\Debug directory contains only one copy of the dll.

Note that I cannot use assembly aliases since my code doesn't directly call the versioned assemblies - they are only indirectly called via the parser assemblies.

Is this a matter of instructing Visual Studio to place the differently versioned dlls in separate directories since they have the same name? I'd like to avoid using the GAC as far as possible.

I've read many "side by side" and related articles, but none seem to address this question.

4

2 回答 2

1

我绝不是 SxS 专家,但在我的公司,当这种情况发生时,他们会为每个程序集创建一个不同的文件夹,并创建一个清单来加载它们。

于 2011-02-01T12:04:33.817 回答
0

通过挂钩 AppDomain.AssemblyResolve 解决了这个问题:

AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
{
    Assembly result = null;

    if (e.Name ==
        @"Antlr3.Runtime, Version=3.1.3.42154, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7")
        result = Assembly.LoadFile(
             @"C:\src\NHibernate-3.0.0.GA\lib\net\3.5\Antlr3.Runtime.dll");

    return result;
};   
于 2011-02-01T12:20:43.990 回答