问题
I'm making two trivial C++/CLI projects, one is an executable and the other is a DLL. In the executable, I write
#using "DllLibName.dll"
and it gives me error c1107, which I though would be easy to solve. I googled for LIBPATH and went to Linker, General, Additional Library Directories and added the folder containing DllLibName.dll and it still wouldn't work. Same error.
I tried replacing the directive with
#using "D:\AbsolutePath\DllLibName.dll"
and everything works. I don't wanna have to type in the full absolute path. What am I missing? This feels so stupid.
回答1:
Probably in your case the path must be set for the compiler, not the linker.
Properties -> C/C++ -> General -> "Resolve #using References" or see the documentation for the AI-flag
回答2:
Are the two projects in the same Solution? If so, then don't use #using, add a reference to the other project, and let Visual Studio take care of the paths.
- Right click on the executable project, select "Properties".
- In the properties window, select "Common Properties" at the top of the list at the left.
- Click the "Add New Reference" button.
- Select your DLL project from the "Projects" tab.
来源:https://stackoverflow.com/questions/14179382/error-c1107-could-not-find-assembly-please-specify-the-assembly-search-path-usin