Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.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# bin文件夹中的DLL在IIS中有效,但在visual studio 2012中无效_C#_Visual Studio 2012_Dll - Fatal编程技术网

C# bin文件夹中的DLL在IIS中有效,但在visual studio 2012中无效

C# bin文件夹中的DLL在IIS中有效,但在visual studio 2012中无效,c#,visual-studio-2012,dll,C#,Visual Studio 2012,Dll,我有一个网站,我使用此函数加载第三方DLL,这是我从使用相同DLL的开源项目获得的: public static void LoadCodecs(string path = null, string search = null) { if (path == null) path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var catalog = (search == nu

我有一个网站,我使用此函数加载第三方DLL,这是我从使用相同DLL的开源项目获得的:

public static void LoadCodecs(string path = null, string search = null) {
    if (path == null)
        path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    var catalog = (search == null) ?
        new DirectoryCatalog(path) :
        new DirectoryCatalog(path, search);
    var container = new CompositionContainer(catalog);
    foreach (var lazy in container.GetExports<ICodec>()) {
        var codec = lazy.Value;
        _codecs[codec.TransferSyntax] = codec;
    }
}

但是,只有在我将正确的版本放在Bin目录中时,这仍然有效。有更优雅的解决方案吗?

您的dll可能是32位(不管您的系统是32位还是64位,由.net framework决定是以32位还是64位运行您的进程),请尝试专门为每个CPU体系结构配置您的项目,以便您能够确定哪一个真正起作用,或者使用测试dll您是否尝试启用fusion日志@yms-我的DLL是64位的-我也有一个32位版本,但只有64位版本在IIS中工作(除非我在应用程序池中设置了“允许32位”标志)。看起来我的问题是Visual Studio正在运行一个32位的web托管环境-当我放置32位版本的DLL时,它工作正常。谢谢yms为我指出了正确的方向。请将你的发现作为答案发布,并接受它。
string file = "Codecs";//name of 32 bit DLL minus extension
if (Environment.Is64BitProcess)
{
    file += "64";//64 bit dll is Codecs64
}
file += ".dll";
LoadCodecs(file);//just illustrative, actually need correct path here