开发者

What is the correct way to add references to libraries in C++/CLI?

开发者 https://www.devze.com 2022-12-14 05:57 出处:网络
I am writing a lib in C++/CLI, and one of the functions is returning a System::Drawing::Color object.I added System.Drawing as a project reference.It works.

I am writing a lib in C++/CLI, and one of the functions is returning a System::Drawing::Color object. I added System.Drawing as a project reference. It works.

I then created a test application to link to this lib and added my created lib as a reference. Everything linked fine, but then I tried to the run the application and I had the error "Unit Test Adapter threw exception: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.." (I don't know how to access this LoaderException property).

This problem was fixed by adding a second reference, in the test project,开发者_开发百科 to System.Drawing, but it seems cheesy. Consumers of my library should not have to know about the dependencies on the lib. Why didn't adding a reference to my lib know about the dependancy to System.Drawing? I feel I am doing something wrong.

Thank you for your advice.


I rephrased the question in more language agnostic design terms: here. The general consensus seems to be to remove dependencies on other libraries, and then this problem won't exist.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号