简体   繁体   English

我如何在没有任何公共成员的情况下引用dll?

[英]How can I reference a dll without any public members?

I'm working on an integration test harness that offers developers the ability to execute methods either against our integration database or against a SQLite in-memory database. 我正在开发一个集成测试工具,使开发人员能够对我们的集成数据库或SQLite内存数据库执行方法。

Because none of the actual SQLite code is referenced by my harness, I have to add dummy code to ensure that msbuild copies the DLLs: 由于我的工具束未引用任何实际的SQLite代码,因此我必须添加伪代码以确保msbuild复制DLL:

namespace References {
    internal interface IReferenceUnusedDependencies {
        SQLiteException e { set; } // Reference System.Data.SQLite.dll
        IMappingEngineRunner r { set; } // Reference AutoMapper.dll
    }
}

However, I can't figure out how to reference code from System.Data.SQLite.Linq.dll - all of the classes and interfaces it contains are internal. 但是,我无法弄清楚如何从System.Data.SQLite.Linq.dll引用代码-它包含的所有类和接口都是内部的。

Is it possible to make these references somehow? 是否可以以某种方式做出这些引用?

Add this assembly property to your main project 将此装配属性添加到您的主项目中

using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo( "MyTestDLLName" )]

Re-reading the problem, do you simply need to copy the referenced assemblies to your bin? 重新阅读问题,您是否只需要将引用的程序集复制到bin中?

If so you can choose the copy to property in Visual studio (which in turn uses MSBuild) under the Item's Properties from the Solution explorer. 如果是这样,则可以在解决方案资源管理器中“项目”的“属性”下的Visual Studio(依次使用MSBuild)中选择“复制到”属性。

Select the reference in the References folder, and then choose copy local. 在“引用”文件夹中选择引用,然后选择“本地复制”。 (Other MSBuild properties are available there as well) (其他MSBuild属性也可以在那里获得)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM