Unable to add NetVips via NuGet in my VS project - visual-studio

I'm trying to use the NetVips library in my VB.NET project, i've added the NetVips.Native.win-x86 in my project from NuGet, the issue is that instead of adding the reference to the Bin folder it's add the NetVips.Native.win-x86 in a folder inside bin called packages and when i'm trying to reference to the library methods in the project i'm unable to...
And if i try manually to add the references to all the NetVips dll i get the error that it's unable to reach assembly or COM.
So how can i make NetVips work?

It is normal behavior.
The NetVips.Native.win-x86 nuget package's runtimes folder's dlls are not the type of COM. Only COM dlls can be referenced under the project. They are native binaries.
And these three dlls are not for assembly references from the author's design.
And that is the folder runtimes folder's function. See this document.
These three dlls from the runtimes folder provide the necessary services for your application when your project is running and deployed. It is just that these three dlls are not the type of COM, which caused your problem.
Instead, you should use NetVips nuget package. The dlls from it are the type of COM. And you can use it.
Update
use Release mode, then move dlls like libvips-42.dll ... from runtimes folder into bin folder, get it.

Related

How to make sure nuget assemblies are added by package rather than only reference to DLL file?

I have noticed many times that developers tend to reference assemblies directly by browsing to the .dll file under the .\packages folder (installed by another project) and adding that to project references instead of installing the nuget package on that project. In that case, even though it compiles, but the Nuget Package Manager does not know that the referenced assembly is from a package, and so updating the package solution-wide does not update those references in that project. If you are doing a Service Oriented architecture where each piece of feature in your application is a separate project in the solution, then you probably have hundred of projects, and managing those references would become a nightmare. Is there any way to prevent developers from referencing assemblies directly if they belong to a nuget package? For example is there any MSBuild task to verify all references to package assemblies require the package to be installed on the project?
If your team uses resharper, they have a plugin to help with this:
http://blog.jetbrains.com/dotnet/2012/11/20/add-packages-not-references-a-nuget-plugin-for-resharper/
I'm guessing the issue is caused by people using resharper without it, since by default VS won't know to include that DLL but Resharper will find it and reference it (and not update package config without the plugin)
Also get used having people using nuget at the solution level, not project level. That will force people to update all nuget packages across the solution, and not leave you with V 1.1.1.0 on Project A and v 1.1.2.0 on Project B.

How do I take a dependency on a COM object without an interop assembly?

When I add a reference (Common properties, framework and references, add new reference) to Microsoft internet controls/SHDocVw.dll and compile the project, a new file is created in the release folder of the project. The file (Interop.SHDocVw.1.1.dll) needs to be in the same folder as the program for it to run.
How do I make my program use the SHDocVw.dll located in system32 instead of the Interop.SHDocVw.1.1.dll in my programs folder?
A primary interop assembly is not used instead of the native DLL, it's a .NET binding layer that loads the native DLL. The Windows DLL is still doing all the hard work.

How to reference assembly from GAC?

I have installed the strong named assembly TestReflection into the GAC (I am using .NET 4.0 and VS 2010).
Different versions of the TestReflection DLL are in GAC of .NET 4.0 (C:\WINDOWS\Microsoft.NET\assembly\GAC_32\TestReflection\), however, the assembly does not appear in the "Project" -> "Add reference" box of VS 2010.
How can I refer to my assembly deployed in GAC at design time from another project?
This page says that:
You cannot add references from the Global Assembly Cache (GAC), as it is strictly part of the run-time environment.
Referring to this statement, I would like to know how to make your project's DLL shared assembly for other consumers if it's the requirement?
The dll's shown in the .Net tab of the "Add references" dialog are not actually the ones registered in the GAC. They are found by searching a few paths on your filesystem.
The paths being searched are located by Visual Studio by looking up the following registry entries:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetFramework\{Version}\AssemblyFoldersEx\
There should be some keys added there already, so if you want your own dll to show up on the .Net tab, you can add it to one of the folders defined there. You could also add a new registry key pointing to a custom folder, which would only contain your own dll's.
The GAC is only meant for loading assemblies at runtime after your application has been deployed, so I don't think you should use it while developing. When you deploy your app, make sure to set "Copy local" to false on your reference so the dll won't be copied to the bin folder, and then install it into the GAC and it will be loaded from there instead.
Another simple option would be to manually edit the project file as XML in visual studio (You will have to unload the project first), and simply add node <Reference Include="<name of dll>" /> in MSBuild project file. After reloading the project, VS will pick up the reference without problem.
If you want to add Global Assembly Cache references to your VS2010 project, there is an extension you can use: Muse.VSExtensions.
It has some quirks but does a decent job. Check it out...
The answer is the Reference Paths in the property windows, you have to set it with the GAC path
Please see my post here:

Where should I store referenced DLL binaries in my visual studio solution

When writing programs (C#.NET) I'll commonly use external libraries I've downloaded from various websites such as custom WinForm controls, or other libraries. Even if the source is available I usually prefer to reference the compiled DLL files rather then create another whole project in my solution for the 3rd party library or control.
So my question is where would people typically store external DLLs like this in the solution? The referencing project folder? The solution folder? Another folder?
I always create a lib folder at the same level of the src folder and put all external DLLs there. They are referenced through a relative path.

Find out why Visual Studio decides to copy DLLs into a bin directory

I have a web application project. I am trying to find out why certain DLLs are being copied into the bin directory of the web application. As far as I can see there are no references to the DLLs under the list of references.
Whilst I don't think it should make a difference, I have been through all the DLLS of the projects that the web application depends upon and selected Copy Local=False.
But still when I build the solution, the DLLs turn up in the bin directory. I don't want them there. How can I find out what is putting the DLLs there?
An indirect reference perhaps?
That is, you reference assembly A and it references assembly B and C. Presto! B.dll and C.dll are in your bin folder. Use reflector or ildasm to check the references of the assemblies you have referenced in you project.
Check out your Post-build events which you can find in Project Properties->Build Events->Post-build event. There might a command-line instruction to copy a DLL into your bin directory.

Resources