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

发布于 2024-10-13 22:29:20 字数 588 浏览 1 评论 0原文

我正在尝试测试加载 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);
    }

...给了我一个例外其中表示无法加载文件或程序集“系统”或其依赖项之一。系统找不到指定的文件。

I'm trying to test-load all the required .dlls for a C++-CLI program to make sure none are missing, but what looked like a simple method to do this doesn't seem to work:

    // 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);
    }

...gives me an exception which says Could not load file or assembly 'System' or one of its dependencies. The system cannot find the file specified.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴情换悲伤 2024-10-20 22:29:20

明白了:

    // 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 );
    }

不需要中间字符串:-)

Got it:

    // 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 );
    }

Didn't need the intermediate string in there :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文