简体   繁体   中英

How do I expose class libraries referenced by a class library, which is then included as a project reference in Visual Studio?

I'm working on my first Visual Studio 2010 solution that has multiple projects. I'm finding myself with some project reference confusion.

I'm trying to create an API project that exposes methods to clients. This API references a project containing my business models. I want other projects to be able to reference the API dll and get access to those business models. Currently, in my test project that tests the API, I have to make a reference to both the API project and the business model project separately.

Any thoughts?

If you want to incorporate an N-Tier model into your application by which business models are only exposed to a single layer you are going to have to create methods and objects at the API level which are responsible for interacting with the business layer and then communicate this information back to your tests or to any other project/person that wishes to plug into your API.

If you are trying to create a level of abstraction between your business models and other projects then you definitely don't want to directly expose your business model logic to everything. Kind of defeats the purpose.

The Wikipedia article on multi-tier architecture might prove helpful to you.

Currently, in my test project that tests the API, I have to make a reference to both the API project and the business model project separately

This is normal, you need to reference both if your "API" project exposes Types from your "business model" project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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