如何测试.net程序所需的所有.dll是否可用?

时间:2011-01-21 11:14:51

标签: reflection dll c++-cli

我正在尝试为C ++ - CLI程序测试加载所有必需的.dll,以确保没有丢失,但看起来这样做的简单方法似乎不起作用:

    // First make sure we have all the .dlls we need
    Assembly^ assembly = Assembly::GetEntryAssembly();
    array<System::Reflection::AssemblyName^>^ referencedAssemblies = assembly->GetReferencedAssemblies();
    for each(System::Reflection::AssemblyName^ referencedAssemblyName in referencedAssemblies)
    {
        String^ strName = referencedAssemblyName->Name;
        assembly->Load(strName);
    }

...给了我一个例外Could not load file or assembly 'System' or one of its dependencies. The system cannot find the file specified.

1 个答案:

答案 0 :(得分:0)

知道了:

    // First make sure we have all the .dlls we need
    Assembly^ assembly = Assembly::GetEntryAssembly();
    array<System::Reflection::AssemblyName^>^ referencedAssemblies = assembly->GetReferencedAssemblies();
    for each(System::Reflection::AssemblyName^ referencedAssemblyName in referencedAssemblies)
    {
        assembly->Load( referencedAssemblyName );
    }

那里不需要中间字符串: - )