有关使用IMetaDataAssemblyImport :: FindAssembliesByName方法的说明 [英] Instructions on using IMetaDataAssemblyImport::FindAssembliesByName method

查看:96
本文介绍了有关使用IMetaDataAssemblyImport :: FindAssembliesByName方法的说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用IMetaDataAssemblyImport提供的FindAssembliesByName()方法.我正在使用它将程序集文件加载到内存中.该功能的文档在这里.

I am trying to use FindAssembliesByName() method provided by IMetaDataAssemblyImport. I am using it to load an assembly file into memory. The documentation of the function is here.

https://msdn.microsoft.com/zh-cn/library/ms230985(v = vs.110).aspx

https://msdn.microsoft.com/en-us/library/ms230985(v=vs.110).aspx

现在,第一个参数应该包含要在其中查找汇编文件的根目录的绝对路径,第二个参数应该包含子目录列表.我在源代码中按如下方式调用该函数.

Now, the first argument should contain the absolute path to the root directory where to look for the assembly file, and the second argument should contain a list of subdirectories. I call the function in the source code as follows.

FindAssembliesByName(CSettings :: GetTorchCallBackPath(),NULL,pstrAssemblyName,
   vpAssembliesIUnk.GetData(),PREFERRED_DUPLICATED_ASSEMBLY_COUNT和& nAssembliesCount);

FindAssembliesByName(CSettings::GetTorchCallBackPath(), NULL, pstrAssemblyName,
  vpAssembliesIUnk.GetData(), PREFERRED_DUPLICATED_ASSEMBLY_COUNT, &nAssembliesCount);

在这里我作为第一个参数给出包含要加载到内存中的汇编文件的目录的绝对路径.但是,即使那样,该功能也无法找到程序集文件.

where I give as the first argument the absolute path to the directory containing the assembly file I want to be loaded in memory. However, even with that, the function is unable to locate the assembly file.

如果该函数无法找到该程序集,则该函数在GAC(全局程序集缓存)中查找该程序集.如果在执行此程序之前将程序集放置在GAC中,则该功能可以找到该程序集.所以我认为 我调用此函数的方式有问题.

If the function is unable to locate the assembly, then the function looks for the assembly in the GAC (Global Assembly Cache). If I place the assembly in the GAC before executing this program, then the function is able to locate the assembly. So, I think there is something wrong in the way I am calling this function.

有人有使用此功能的经验吗?你能帮我吗?我无法在线找到使用说明.

Does anyone have any experience using this function? Can you help me out here? I could not find usage instructions online.

推荐答案

Hi MigrationUser1,

Hi MigrationUser1,

谢谢您在这里发布.

对于您的问题,如果可以从GAC中获取程序集,则函数的参数(路径除外)是正确的.

For your question, if you could could get the assembly from GAC, the parameter of the function except the path is right.

是否可以提供有关CSettings :: GetTorchCallBackPath()的更多信息?此方法返回的值是什么?方法返回的类型是什么?

Could do provide more information about the CSettings::GetTorchCallBackPath()? What is the value of this method return? What is the type of this from the method return?

如果您的CSettings :: GetTorchCallBackPath()返回包含程序集文件的路径,则可能会导致问题.请使路径不包含汇编文件.

If your CSettings::GetTorchCallBackPath() return a path contain assembly file, maybe it cause the problem. Please make a path do not contain the assembly file.

或者您可以将szAppBase设置为Null,FindAssembliesByName将直接在GAC中查找该程序集.

Or you could set the szAppBase to Null, FindAssembliesByName will look in the GAC for the assembly directly.

最好的问候,

温迪


这篇关于有关使用IMetaDataAssemblyImport :: FindAssembliesByName方法的说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆