Loading 3rd party dlls for common use in Visual Studio 2012, C++ - dll

I have glut32.dll file which needs to be in the Debug folder whenever I compile a source. It's very frustrating to manually put in the Debug folder of each project file to have it run properly.
Is it possible I can put it in some folder and point the project to it?
I am a newbie with Visual Studio 2012.
Before this question being tagged as a duplicate, I want to add I keep seeing suggestions Referencing third party dlls, but I couldn't get it.
Any help appreciated !

If you add a project reference to this DLL, I believe it should be copied to the Debug folder automatically.

Related

libIEC61850 Microsoft.VisualStudio.ProjectSystem.References.UnresolvedBuildDependencyProjectReference" reference could not be resolved?

Hello i im running Visual studio 2022 professional. I have downloaded libiec61850-1.5.1 libIEC61850 I have compiled the code whit cmake. I have then opened it in visual studio code. The problem is that the References in the example projects could not be resolved.
I have tried the following things.
Remove the references then add them again save and rebuild project.
Remove the references the save rebuild project, closed and started visual studio again
the tried add the references.
Tried edit the path directly in vcxproj file.
I downloaded the libIEC61850 a second time to make sure there was no corrupt files. Made
a new compile whit cmake. still got the same problem,
Updated the visual studio to the newest update.
Anybody that have a idea what the problem can be. I have searched the a found nothing that could help. i have checked this post also
The problem was that Link to library dependencies was not set to "True".
After i changed this the reference error did go away.

Add a dependency / reference to your own DLL project in Visual Studio 2013

I have been working on a few different applications and I want them all to share the same DLL library. The shared DLL is one that I created, so really I want each application to have a dependency on the DLL so that the DLL gets built in the same solution as the application. Then the DLL should copy itself to the application's bin folder before the application runs.
After figuring out how to do this, it seems that it should have only taken about 5 minutes, but unfortunately it took me an hour to figure out. That's partly because similar questions were referring to older versions of Visual Studio, or referring to 3rd party DLLs. So I thought I'd post the steps here.
You should already have one existing project and solution for your DLL. Open your solution for your new application that depends on your DLL
Highlight the top line in your Solution Explorer (your solution name), then go to the File menu and choose Add > Existing Project...
Browse to the project file for your DLL and select it. That will add the DLL project to your solution
Although your projects are now in the same solution, that didn't actually create a reference for your main project. So now right-click on your original project (should be 2nd line in your Solution Explorer) and choose Add > Reference...
The Reference Manager will appear. Be sure that you have Solution > Projects selected on the left. Then you should see your DLL project listed on the right. When you hover over it, a checkbox will appear. Select the check box. Click OK.
Last, be sure that your Project Dependencies are set correctly. Again, right-click on your Solution in Solution Explorer (top line). Choose Project Dependencies...
In the Projects drop down, make sure your main project is selected. Then in the Depends On list below, check the box for your DLL project.
Now when you Build your solution, it will first build the DLL, then copy it to your applications bin folder, then build your application. The Reference will also allow you to refer to the DLL in your code files, for example with "using MyLib;" for C#, or "Imports MyLib" for VB
Now when you Build your solution, it will first build the DLL, then copy it to your applications bin folder, then build your application.
Thank you for explaining this. I did all the steps (Visual Studio 2015) and I noticed that "Build solution" command builds all the DLLs, but it does not copy them to the right bin folder. To achieve that I need to build the active project (right-click on the active project, then "Build").

How to add libraries to dll project in VS2013?

I've got a code in C++ built with some libraries like vtk, fltk, pcl and kinect SDK in Visual Studio 2010. My task is taking this project and integrate it into another C#.NET project with Visual Studio 2013.
I was told to do a new project for the dlls and copy the code I need there to make a wrap. My current problem is that I do not know how to add the references so my code can find the includes for the libraries and compile. I have tried to add the .h and .lib manually but does not work. May you give me any hint?
Thank you.
I'm not entirely clear what your question is, but try this:
Right click on your project in the solution explorer and go to Properties -> Configuration Properties -> Linker -> Input.
In the additional dependencies field, add your .lib file(s).
remember to #include the corresponding header files in your source file.

Visual Studio won't find references

I'm working with some application handed over by another person in which I must document the requirements, build and deploy processes.
The problem here is that Visual Studio (2005) is throwing a lot of errors since it can't find the references for the dlls.
This obviously won't let VS build the project.
Everything works fine on the persons computer but not on mine, even though the project references the same folder where the dlls are, the bin folder.
How can I circumvent these problems and get VS to properly reference the dlls?
The following printscreen shows the references screen for the project.
My guess is that your DLL uses a more recent .NET framework than your application does.
Check the properties for your DLL source (right-click on the DLL code in the solution explorer and choose Properties). Go to Application - Target .NET framework and compare the version to the one the application itself uses (right-click on the project code). Note: under your application properties check both the settings under Application - Target .NET framework AND under Publish - Prerequisites.
For what it's worth, even after changing the .vbproj file and removing many lines about hard coded values,
I eventually checked out the project again removed all references to the given DLL and then added it using the GUI.
Lesson learned, don't try to change out one DLL for a newer version without using VB2005 GUI.
The easiest solution will probably be to transfer everything to another project. It will be incredibly time consuming to find where visual studio has left the hard coded path at.
WOOT!!!! Compile the DLL file to a lower version of the .NET framework, and it will fix the problem!!!!
The paths in the project file cannot be the same or the assemblies referenced have a different version.
It might be worth unloading your project and the editing it to inspect where it's looking and for what version.
I had the same problem with an older Visual Studio Project that I opened in Visual Studio 2008. I tried to add new references to the project and got permanent errors that the dll's cannot be found. After the migration of the Project to Visual Studio 2010 I got the following error message when I tried to add a new reference:
'mySample.dll' or one of its dependencies, requires a later version of the .NET Framework than the one specified in the project. You can change ...
After changing the projects .NET Framework to a newer version everything works fine.
Good suggestions in other answers. In my case, it was because the libraries weren't copied (downloaded) successfully: the files existed, but were 0 kB.
Did a clean, which removed all the DLL's and then VS2008 complained it couldn't find the references (Duh!!!) and wouldn't rebuild....luckily I had and old version of the dll's and replaced them in the directory AND THEN did a rebuild to replace them...all references are now OK and we're back to normal....good old VS 2008

Old DLL file keeps being used

I have a seemingly random problem where my project will run using an old version of a DLL file that no longer exists. Sometimes the real version of the DLL file will be used, other times an ancient version of the DLL file will be used. Who knows where Visual Studio is getting this DLL file from - it's months out of date!
I know that it is using the old DLL file, because when the application runs I start getting weird 'TypeLoadExceptions', complaining that methods don't exist or don't have implementations.
The following actions will sometimes help, sometimes not:
Restarting Visual Studio
Restarting the computer
Cleaning and rebuilding the solution
Deleting everything in \WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
Searching for and deleting instances of the DLL file in \Documents and Settings\username\Local Settings\Temp
Sometimes I perform all of the above steps, and it still uses an old copy of the DLL file. Where is it hiding it?!
The same issue exists on our TeamCity server which is using MSBuild. When TeamCity tries to run unit tests it uses an old DLL file.
Now, I know that I can use assembly redirection in the web.config file, but the version number of the DLL file hasn't changed (I don't bother to update it, so it just stays at version 1). I don't want to have to start versioning the DLL files just to solve this problem. I would just like to know which particular caches I need to clear so that I can get on with developing.
It hides it in the GAC. There it may reside indefinitely. Using a more recent version may indeed solve the problem, but there is an outstanding bug in Visual Studio that has to do with choosing the correct version of DLL files. (If DLL Hell wasn't bad enough, the Visual Studio team is making it worse!)
Finding it in the GAC is tricky, and I cannot advise you on how to do that, but once the old version is deleted from there, it will not be found again. Sometimes, even though you are pointing the compiler at a newer version (by date), it will use the older version, because it has the same version level (by version). That is its bug.
Who knows where Visual Studio is getting this dll from - it's months
out of date!
The Modules Window is your friend...
It'll tell you exactly where that file is coming from. You can even use it with arbitrary processes if you attach the debugger.
I too would guess that they're hiding in the GAC.
You can look in 'C:\Windows\assembly' to see all the dlls and unregister yours from there.
The problem may exists with the build order or your projects.
If your Test project is built before the application project, this cause the behaviour you describe. To fix this: right click on your main project in VS and select the Project Dependencies... option and check the build order. Changes to the build subsequence can be made here by correctly setting these dependencies.
I had a similiar problem (but without Visual Studio). I am loading a .NET dll using UnsafeLoadFrom.
On one computer (a terminal server) the old file still remains being used, regardless of updated version numbers, etc.
The reason is simple: As long as a program instance is running, which has already loaded the old dll, the new dll will never be used. All further UnsafeLoadFrom will become the old dll although the old version doesn't exist on the harddisk anymore, because it has already loaded some time ago.
The solution is to shut down all running instances of the application or even restart the computer. Then all new instances will get the updated dll.
In my case, this was caused switching to Release mode, which had a different configuration (that used different location of the DLL).
In my case, I use Visual Studio to Publish Website, and though I check the reference of the dll file has changed, but the published dll still is old. Finally I new a Publish Web Profile and choose the right configuration (such as Debug - x86 / Release - Any CPU), publish again then the dll is corrected.
While this question is old, maybe someone will stumble upon it again in his/her quest for finding a solution.
In my case i got a CS0433 error for an ASP.Net page. After deleting the content in the obj\ and bin\ folders of the project, it worked again. Probably has to be done with a closed Visual Studio. Maybe also clean out those folders in referenced projects in the same solution (if used in the project and not pulled via Nuget).
In my case, the old DLL was in
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\MyDLL\MyDLL.dll
It DID NOT show up in c:\Windows\assembly.
I did a search of my drive for MyDLL, and it showed up as indicated above. I was debugging my test app at the time, and tried to delete the offending folder...no go...it was locked by Visual Studio. I had to stop debugging my app, close Visual Studio, and then delete the folder. Problem solved!! I don't know how my DLL got there, but it hasn't showed up there since I deleted it.
It's possible that the DLL is being referenced from another folder. It could even be on a network drive if you have one in your PATH environment variable. Here's how Windows searches for DLLs:
http://msdn.microsoft.com/en-us/library/7d83bc18%28v=vs.80%29.aspx
In My Visual Studio 2015, I ensured that the offending Visual Studio project's Reference Path Listing is empty:
If you find such problem ,delete your Reference dll and pdb extensionfile add new references and rebuild your project .This often happens due to no rebuild of project,commit and updates.
The fix for me was making sure that the virtual directory in IIS was pointing to the correct directory. I have two projects on my system, a v4 and a v5. The virtual directory on my dev system was pointing to the v4 bin directory instead of my v5 bin directory - oops!
The file that was being cached in the dll, I couldn't trace the file, so I ended up renaming the file. This might not resolve the problem mentioned here but this was the fix that worked for me related to this question.
I tried a ton of things including re-installing VS 2107.
You can see where the DLL files are being loaded from in your Output window. After going through all mine looking for project DLL, I found it.
Clearing this worked for me.
C:\Users\YourUser\AppData\Local\assembly\dl3\222Q4G1T.8AT\JBEAR7PB.E3J\8bfcf9ab\6e61cbd5_30acd401\YourDLL.dll'
I actually deleted all the files in:
C:\Users\YourUser\AppData\Local\assembly\
Holy Crow! I had an old, old suite of applications including 2 web services and a bunch of class libraries and a click once application. Well, click once stopped publishing for VS 2005 with a bunch of 'not found' errors. So, rather than hack away at my registry as suggested on this site, I figured it was time to upgrade the projects to 2017. Well, when I did this, the projects references in my web service projects got lost. Then, rather than helpfully just telling me that with errors, VS 2017 must have went to some cached file in C:\Users\XXX\AppData\Local\Temp\WebSitePublish or C:\Users\XXX\AppData\Local\Microsoft\VisualStudio\8.0\ProjectAssemblies or C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root and 'helpfully' just used those files instead! I had to do a hardcore search with a custom program to find all the files on my C:\ drive and delete them before I finally got the errors!