Linqpad查询需要不受管理的部署项目 [英] Linqpad Query Needs Unmanaged Deployment Item

查看:92
本文介绍了Linqpad查询需要不受管理的部署项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在运行Linqpad查询时包括非托管程序集?

How do I include an unmanaged assembly with the running of a Linqpad query?

我正在运行最新的测试版(v4.42.06).我通过f4 Query属性添加了对工作中的托管程序集的引用.我在Linqpad中放入代码以访问该程序集中的类和方法,然后单击运行时,我得到一个内部理解(从我的托管程序集而不是Linqpad),指出它无法打开(在这种情况下真的找到了)一个依赖项. 非托管程序集,通常与目录中的托管程序集一起驻留.

I am running the latest beta (v4.42.06). I have added a reference to a working managed assembly via the f4 Query properties. I put in code to access classes and methods from that assembly in Linqpad and when I hit run I get an internal exeception (from my managed assembly not Linqpad) stating that it could not open (really find in this case) a dependent unmanaged assembly which normally resides with the managed assembly in the directory.

现在,我通过Linqpad浏览到的非托管程序集确实存在非托管程序集,并且我可以以相同的方式(f4)添加非托管程序集,但它不会影响流程的结果.

Now the unmanaged assembly does exist with the added managed assembly which I had Linqpad browse to, and I can add the unmanaged assembly in the same fashion (f4) but it does not affect the outcome of the process.

当我在Visual Studio中对该模块进行单元测试时,我会附加属性

When I unit test this module in Visual Studio I append the attribute DeploymentItem to the unit test method and am able to execute the code.

如何使Linqpad与非托管程序集部署项一起执行?

How can I have Linqpad execute with an umanaged assembly deployment item?

推荐答案

请勿隐藏程序集引用"设置为true(在 Edit/Preferences/Advanced 中)

Set 'Do not shadow assembly references' to true (in Edit/Preferences/Advanced)

Shadowing意味着将dll复制到另一个文件夹并从那里加载.但是每个dll都复制到一个单独的文件夹中,这意味着托管dll与非托管dll不再位于同一文件夹中,因此它们彼此找不到.

Shadowing means the dlls are copied to another folder and loaded from there. But each dll is copied to a separate folder which means the the managed dll is no longer in the same folder as the unmanaged dll and hence they can not find each other.

通过设置不隐藏程序集引用的选项,可以从原始位置加载dll.

By setting the option not to shadow the assembly references, the dlls are loaded from their original locations.

这篇关于Linqpad查询需要不受管理的部署项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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