Adding DLL as a reference to my SharpSSH C# project - c#

I have downloaded SharpSSH Binaries from the link. When i extracted it i found 3 .DLL files (and also a EXE file).
1.) DiffieHellman.dll
2.) Org.Mentalis.Security.dll
3.) Tamir.SharpSSH.dll
I need to add these as Referece to the project. I need to know which one of these .DLL files i need to add as Reference to the project.
And also can you let me know how i should add References to my C# project.
Note: what i want to do is to upload, download file from a FTP site through SFTP connection.

If you want to add a reference you your project, right click and select Add Reference and navigate to the respective dll(s).

I know this is a fairly old question but we still use the SharpSSH library and the only dll you need to reference is Tamir.SharpSSH.dll, the other 2 dll's will automatically be included.

Related

References can not be reinitialized after check-in from visual studio team service

I did check-in to download source code for the first time, but i got some missing references. I've tried following ways but it doesnt work for me:
Add references: Right click -> add references then find references (after adding the references, there is nothing change, you can see in the photo below)
Dlls were set to Copy Local (I even can not change the copy local to
true)
Adding namespaces to both web.configs did nothing.
I used VS2015. is there any way to update it correctly? thanks
Generally, source code does not contain dll's, since they are vey big files. So I would not normally expect to get dll's from source control. You would usually have to build the solution and hope that Nuget is enabled to download the dll's from where they are stored.
However, the dll's you are showing come with the .net framework, so this should not be an issue, unless of course, the solution file is expecting to find the dll's in some /bin directory.
You can find which directory the dll's are expected to be in by right clicking on the missing dll and then clicking on 'properties'. This should show you the referenced dlls path in the properties window.
If the dll is not in that path you can do one of 2 things:
Delete the reference and add a new reference to the dll, where it actually exists
paste the dll in the path that is being referenced by the solution.

Visual Studio 2013 C# configuration settings

I want to add include directories and libraries in my c# project like i can in my c++ project
C++ Project : There are options to include directories and linker dependencies.
C# Project
There does not appear to be an option in the project settings to add those settings. I added the path in reference path, but my debugger throws an error. Right now i've added all the dll in my project\bin\debug directory and its working, but i don't want to do it for all the projects. Where i can link these diretories ?
you can add reference of library files which you want to add into your project by right clicking the project under solution explorer and then "add reference" and then browse or select from the list of dlls..
You can't. You have to include references to code files and assemblies one by one.
The linker and compiler for .NET works different than you are used to with c++. That's why you can't just link an entire directory containing some code files / assemblies.
Add reference to your existing dll for every project which will be use it
http://msdn.microsoft.com/en-us/library/7314433t(v=vs.90).aspx
https://www.google.it/search?q=add+reference+c%23&es_sm=122&source=lnms&tbm=isch&sa=X&ei=P-2fU472Bcr00gX-tYAw&ved=0CAoQ_AUoAw&biw=1920&bih=955

How to add FreeImage.dll to C# project

I have successfully added other .dll files to other C# project this way:
Right click Reference > Add Reference > Browse > Double click the .dll file
but Microsoft Visual Studio 2008 issues the following complaint:
A reference to ...\dll\FreeImage.dll could not be added.
Please make sure that the file is accessible,
and that it is a valid assembly or COM component.
I am using .NET Framework 3.5. I believe this is a 32bit dll (it downloaded with FreeImage3151Win32) so I changed the configuration of the project to x86.
What is the correct method to add FreeImage.dll to a C# project?
Use the wrapper provided in the download. There are C# samples in the \Wrapper\FreeImage.NET\cs\Samples directory.
The FreeImage.dll isn't a .Net dll. You need to write a wrapper in .Net which call the methods of the unmaged code. There is an example here but they also supply a .net wrapper in the binary distribution here
I've seen this before with files downloaded from the Internet that are "blocked" by the file system. Try going into the file's properties and clicking the "Unblock" button.
In the current release (3.15.4), have to build the project in FreeImage\Wrapper\FreeImage.NET\cs to produce the DLL for C#. Then you find it in FreeImage\Wrapper\FreeImage.NET\cs\Library\bin\Release or Debug.
Save the file into the Bin folder and click Project > Add Reference > Browse > Double click the .dll file
C# sharp helps link

How do I resolve "Please make sure that the file is accessible and that it is a valid assembly or COM component"?

I am building a project with OpenCV in C#. It requires a dll file called cvextern.dll. but, when adding this file as a reference, this message appears :-
a reference "cvextern.dll" can't be added, Please make sure that the file is accessible and that it is a valid assembly or COM component.
I get tired from searching, I spent the past 2 days in searching for a solution for that problem
the file is a native DLL which means you can't add it to a .NET project via Add Reference... you can use it via DllImport (see http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx)
In my case I had to register the .dll.
To do so, open cmd.exe (the console) with admin rights and type:
regsvr32 "foo.dll"
Make sure the required dlls are exported (or copied manually) to the bin folder when building your application.
'It' requires a dll file called cvextern.dll . 'It' can be either your own cs file or some other third party dll which you are using in your project.
To call native dlls to your own cs file, copy the dll into your project's root\lib directory and add it as an existing item. (Add -Existing item) and use Dllimport with correct location.
For third party , copy the native library to the folder where the third party library resides and add it as an existing item.
After building make sure that the required dlls are appearing in Build folder. In some cases it may not appear or get replaced in Build folder. Delete the Build folder manually and build again.
I had the same program, I hope this could help.
I your using Windows 7, open Command Prompt-> run as Administrator. register your <...>.dll.
Why run as Administrator, you can register your <...>.dll using the run at the Windows Start, but still your dll only run as user even your account is administrator.
Now you can add your <...>.dll at the Project->Add Reference->Browse
Thanks
Look here for the answer by TheMattster. I implemented it and it worked like a charm. In a nutshell, his solution suggests to add the COM dll as a resource to the project (so now it compiles into the project's dll), and upon the first run write it to a file (i.e. the dll file I wanted there in the first place).
The following is taken from his answer.
Step 1) Add the DLL as a resource (below as "Resources.DllFile"). To do this open project properties, select the resources tab, select "add existing file" and add the DLL as a resource.
Step 2) Add the name of the DLL as a string resource (below as "Resources.DllName").
Step 3) Add this code to your main form-load:
if (!File.Exists(Properties.Resources.DllName))
{
var outStream = new StreamWriter(Properties.Resources.DllName, false);
var binStream = new BinaryWriter(outStream.BaseStream);
binStream.Write(Properties.Resources.DllFile);
binStream.Close();
}
My problem was that not only I had to use the COM dll in my project, I also had to deploy it with my app using ClickOnce, and without being able to add reference to it in my project the above solution is practically the only one that worked.
In my case I also have unmanaged dll's (C++) in workspace and if you specify:
<files>
<file src="bin\*.dll" target="lib" />
</files>
nuget would try to load every dll as an assembly, even the C++ libraries! To avoid this
behaviour explicitly define your C# assemblies with references tag:
<references>
<reference file="Managed1.dll" />
<reference file="Managed2.dll" />
</references>
Remark: parent of references is metadata -> according to documentation
https://learn.microsoft.com/en-us/nuget/reference/nuspec#general-form-and-schema
Documentation: https://learn.microsoft.com/en-us/nuget/reference/nuspec

C# lib install?

I downloaded two different packages, they both came with an .XML and a .DLL file. I used some of their source code and couldn't get it to work (missing namespace). How do I install the XML file and the DLL file? I know the dll should go into system32/system but what do I do with the xml file?
You don't need to install the DLL at all, actually. Just add it as a Reference to your project, then use it as normal.
The XML file isn't specifically necessary. It can be used to generate documentation for the DLL, if you so desire.
EDIT: Also make sure that "Copy Local" (or something similar, can't recall the exact wording) is set to True in the properties of the reference. This will ensure that the DLL is in the same directory as your exe. Otherwise it probably won't be in the load path and then your app won't run.
You don't need to put it on any particular place (that system32 comment is an older technology).
Based on the issue you mentioned (missing namespace -> when compiling), you just need to add the reference to your project (right click on project->add reference->browse->select the .net dll).

Categories

Resources