1

我正在开发一个自定义 PowerShell 管理单元,它引用了解决方案中的另一个项目。
当我尝试调试管理单元时(按照 [这些说明][1]),程序集无法加载,并且我的 cmdlet 失败并显示消息“无法加载文件或程序集...”

您如何指导 PowerShell 如何定位程序集,或者如何指定管理单元所需的程序集的位置?

我宁愿避免在 GAC 中注册程序集,至少在开发期间是这样。

4

2 回答 2

1

SOLUTION (Posting it here as suggested by one of the comments to my question)

My problem was rather specific, as I'm developing on a 64 bits server machine, but I'm posting the solution in case it could help someone else as well.

Using fuslogvw as suggested, I saw that the dependent assembly was being searched using the machine.config file under C:\Windows\Microsoft.NET\Framework64 and then the binding failed; launching the project with "start without debugging", instead, the machine.config file under C:\Windows\Microsoft.NET\Framework was taken (notice the missing 64 at the end).

I thought that the problem could be due to the image format, and infact the dependent assembly was being compiled with x86 as CPU target; I changed it to "Any CPU" and now the assembly is loaded correctly.

于 2009-10-13T06:11:46.727 回答
1

不确定确切的行为,但我会尝试并使用fuslogvw来查看运行时在哪里寻找有问题的程序集。这将为您提供有关如何将它们复制到构建时的正确位置的线索。Scott Hanselman 的这篇文章非常有用,是官方文档。

如果您找到解决方案,请添加答案,因为这一定是常见情况。

于 2009-10-09T10:01:24.940 回答