I have two projects. First is a Windows Forms Application project and second is a class library project. Сlass library project works with FANN. Windows Forms is Startup Project.
I should have Fann.Net.dll and fanndoubleMT.dll to work with the FANN. I downloaded these libraries and put their in a folder lib, located in the root of the solution.
I added Fann.Net.dll as external dll to the class library project. I compiled the project. I got an error that says "Unable to load DLL 'fanndoubleMT.dll'. I fixed this error by adding fanndoubleMT.dll to the folder Windows_Forms_Application\bin\Debug.
I think this is a terrible solution to the problem, because I use git, and every time you need to transfer dll to this folder on the new workplace.
Sincerely, Denis.
On Windows you do not link with a . dll file directly – you must use the accompanying . lib file instead. To do that go to Project -> Properties -> Configuration Properties -> Linker -> Additional Dependencies and add path to your .
Yes, dumpbin.exe is very useful to figure out /dependents and /imports . You can also use it on other machines if you copy link.exe along with it and make sure the corresponding x86 Visual C++ Runtime Redistributable ( msvcr120. dll for Visual Studio 2013) is available on the target machine.
You may try this:
Suggested in the link http://social.msdn.microsoft.com/Forums/en-US/1b1b316a-8648-4243-a651-84de51fd2508/reference-native-dll-from-managed-c-project?forum=vssmartdevicesvbcs.
You can add the native dll as a linked item, and use "Copy if newer".
The problem with native dlls, is that sometimes you'll want to use different dlls according to the project's configuration (Debug/Release or platform).
You can edit the project's .csproj and link the native dll conditionally:
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
<Content Include="..\..\..\..\..\bin\Win32\Release\fanndoubleMT.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
<Content Include="..\..\..\..\..\bin\Win32\Debug\fanndoubleMT_d.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<Content Include="..\..\..\..\..\bin\x64\Debug\fanndoubleMT_d.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<Content Include="..\..\..\..\..\bin\x64\Release\fanndoubleMT.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Note the copy option is set to PreserveNewest which means "copy if newer".
The above solution written by liang works only for flat project structure! You may want to organize all your DLLs in your solution into one folder named "Dependecies". But beware that files are copied relatively to project structure in the Solution Explorer. (tested with Visual Studio 2015)
Now you should have following Solution Explorer structure:
Your Project
- class1.cs
- Dependencies\Fann.Net.dll
- Dependencies\fanndoubleMT.dll
Add postbuild step:
xcopy "$(TargetDir)\Dependencies" "$(TargetDir)" /s /e /h /Y
This solution combining adding files to project and creating post build step has following advantages:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With