how to set the folder of destination when I use local copy? - c#

I have a project in Visual Studio 2010 and in this project I have a "lib" foleder in which I have the external dll that I need. In this case, the libraries of SQLite.
Well, I can set hte reference to the principal dlls, SQLite.dll and SQLite.Linq.dll. In this case, the dll are copy in the main folder of the application.
However, I need also the SQLiteinterop.dll. I have tried to add a reference to this dll, but I get the error that it is not a valid COM component. So the way that I find to copy the dll is marked as local copy in the properties of the dll that is in the "lib" folder.
However, this copies the dll in a subfolder "lib" in the main application folder and I need to copy in the main folder.
Is there any way to set in visual studio where to copy each dll?
Thanks.

I would suggest using a Build Event, retrievable in the Properties of the Project.
Here you can make a Post-build event which copies the file to the Build folder.
Something like:
copy /Y "$(SolutionDir)lib\$(ProjectName)\sqllitefile.dll" "$(TargetDir)\$(ProjectName)\sqllitefile.dll"

Related

BLL and DLL are not founded, when I move them somewhere except source repos(Visual Studio 2019)

I have 3-layer MVVM project, my solution folder, DLL folder and BLL folder are inside 'source > repos >' and project loads normally
But if I move BLL or DLL(or both) to some other folder, or Desktop for example, my project doesn't load correctly and file moved to Desktop defined as not founded in solution explorer
How could I fix it? I need put all this three project folders(DLL, BLL, View) to one folder, because I need to share it as one big project, but I can't, because any movement with files or folder finishes with error 'Files not founded'
Sadly can not send images here, in y question(
Thanks in advance for your answers!
Check for that in your project: is it in the references list? If it is, check that it's built for the same CPU type as your project, and that the Reference properties option "Copy Local" is set to true.
If it isn't, try adding it. If that works, try rebuilding. If it doesn't, then it's probably a Native Library, and you need to ensure that the DLL is either in the EXE folder, or in a folder on the current PATH that Windows uses to locate executables.
You Need to compile the DLL project into a dll file and then refer to the compiled dll file.
Or just use project references to add your DLL project and BLL project.

Visual studio: Build action=Content causes error for dll file

I am trying to build a project in C# which uses some unmanaged dll files (MSVCRT.DLL, DFORRT.DLL, ...). There is no direct reference to the MSVCRT.DLL file in the project(this file is referenced by another dll and not directly by my program)
I want this dlls to be copied to bin directory. if i set build action to Content i get this error on run time:
The procedure entry point _wcstoui64 could not be located in dynamic link library msvcrt.dll.
Which is weird. I cant use other build actions because i want my dlls to be published too(Build action=None wont cause any error but doesn't let me to publish my dlls)
If i completely remove all references to all the dlls and treat them like data files, or pictures(files that are not used in code but should be copied to the output) again i get the same error.
What is causing the problem? how can i publish my dlls?

VS2013: never put bin directory in source control, but it caused build fail

I'm new in Visual Studio 2013 (C#). I know in general it should be avoid putting bin directory in source control. However, in my bin directory, there are lots of dll files. Without this dlls, I can't build my project.
I thought maybe I should create a directory, such as 'lib' to store the dlls. But the fact is NuGet always put dll into the bin directory. Should I manually move the dll from bin to lib?
All I want is to simply put all source codes, resource files and dll files to source control (git). Then my team-mates can pull the project then build it in their machine.
edit on 1/4/2015: provide further details
For example, I installed log4net thru NuGet. After finished, I found 3 new files existed in bin directory:
log4net.dll
log4net.xml
log4net.dll.refresh
I tried to remove bin directory from my project, then rebuild my project, and hope to see that a new bin directory would be built and all dll/pdb/etc files would come back. But unfortunately it didn't happen.
In my understanding, the ideal process would be:
add reference/install package, then certain config info would be recorded and according files would be installed to bin directory;
when build, according lib files would be referenced from bin, if such files not found, VS would get the reference info from some place other than bin and download them again. So that's one of the reasons why we don't need to put bin into source control.
However, I found that's not true in my project.
Actually according to the official .gitignore, I found bin directory as build results is filtered ([Bb]in/). That is to say, even VS knows such directory should be ignored.
Maybe some wrong setting within my project?

Placing dlls in bin directory after successfull build

I was working on a project , I needed to add a folder inside my application which consists some usefull dlls
under properties of my dll , I have changed the Copy to output directory field to copy always
On successfull build of my project I am getting the bin folder as :
After building the project I found out that my dll is placed inside DLL folder
but I do not want such folder , I want it to be inside the bin folder only , how can I achieve that.
simply delete the dll folder in both vs and the windows folder, then add them as references for your project and set there properties to copy always
you still may copy them manually the first time to make sure everything is going just fine
IF the project has a reference to the DLL already VS will copy the dll to the bin folder.

Can Visual Studio compile project references into a different folder then the main .exe

I have a WPF Application project with several project references within a single solution in VS 2008. When I compile my solution, all of the referenced dlls are output into the same folder that the main .exe is output into.
Is it possible to configure my main .exe project build to output all references in a sub folder relative to my .exe?
I would like the final result to be something like this:
MyApp.exe
MyApp.exe.config
Lib\SomeReference.dll
Lib\SomeReference2.dll
(I assume if this is possible, it would be possible with any .exe).
Thanks!
Jon
It looks like its a fairly intensive process.
First set the reference's Copy Local property to false so that the .dlls aren't copied to the bin\Debug folder .
Then create an assemblyBinding\probing element in your app.config to instruct the runtime to look for dlls in the Lib folder
Then create a post-build action to copy the necessary dlls to the \bin\Debug\Lib folder.

Categories

Resources