Use a class library DLL hosted on an ASPX webpage - c#

I'm developing a webpage using the ASP.net Framework 4.0, C# and I got a DLL from a class Library. The function of this DLL is to activate and read information from a hardware CARD-READER (Client side) then I want to send the information to the server.
How can I use this DLL from a ASPX webpage?

Copy the downloaded DLL file in a custom folder on your drive, hopefully at the root of your solution maybe in a libs folder, then add the reference to your project using the Browse button in the Add Reference dialog. Make sure that the new reference has Copy Local = True set within its properties once added to the solution, which is found when un-collapsing and right-clicking on the References item in your project within Solution Explorer.

You can host it creating a XBAP, silverlight or clickonce application. The created application will run clientside.
Hope this helps.
Regards.

Related

C# reference that requires additional files

I'm having a problem with a third party C# class library:
The given .net dll requires additional files to be in the same directory than the .dll (config files etc.).
When I load the library as reference into asp.net project everything works smoothly until first call to the library. I get exceptions from the library saying that the required files are missing.
Now the question is where should I put those required files into? I've tried obj/debug/, bin/ and including the files in the project and selecting "Always copy to output directory", but none helped.
I guess it's something to do with IIS and its way of handling the reference/additional files?
Edit: It's working fine in Windows Forms application, but not in ASP.NET web application.
You can view source code of external class library with iLSpy or Reflector to find how exactly additional files are referenced.
It's can be an application execute path (so it must be IIS shadow copy directory) or GAC.
For that you need to read the documentation. The method throwing the error should be expecting the file in some other folder other than bin, debug or obj.

Adding DLL as a reference to my SharpSSH C# project

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.

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

Dll of a single C# code behind page

I a using ASP.net website - 3.5 C#
I have a modification in a .cs page, I have to deliver only updates for this code behind file only to client. Is there any way to create dll for this page in the website ?
No, it is impossible to create an assembly from a single code behind page that is part of a website project.
The web project gets compiled into a single assembly - all code behind files become part of this assembly. An update to a single code behind file means that you need to recompile the project and deploy the updated assembly.
If you can change the project from a website project to a web application, this would be a different matter, as IIS would compile all code behind files on the fly, so updating a single code behind file is possible.
To create an assembly you will need to create a project class library project. In this project you will create your .cs class file. When you build this it will produce the DLL file.
Unfortuantely you cannot create web pages in this type of project.
Now to use this in your website you can either add a project reference to this class library project, or add a file reference to the DLL it produced
Select the highlighted part as mentioned in the screen shot and Publish it.

Error: Could not download silverlight application. Check web server settings

Developing a silverlight page in already existing web application for previewing video files. When I create a asp.net application locally and add silverlight application on the solution it works perfectly. But while I am trying to include into already existing project it throws this error. I have not deployed into the IIS. this happens while debugging.
Check the path to your xap file in your webpage. It should be something like:
/ClientBin/my.xap
Also ensure that your xap file is actually in the ClientBin folder. In the web application Properties, choose the Silverlight Applications tab and add the silverlight project to the list.
Although probably not applicable in your case, this can also occur if you are using iis and haven't registered the correct mime type for .xap files. It should be set to application/x-silverlight-app.
This is little same with another answer, but I give my detailed solution with image of setting.
In my case, one of my aspx page will load Zip and Xap files under ClientBin Folder, normally it'll load 20 Zip/Xap files under ClientBin\,
But I found that when building/publishing the project, the Zip/Xap files are NOT output to ClientBin\, that is ClientBin folder is nearly empty.
So my solution is to let the Zip/Xap files output to ClientBin\, to do this, the setting way can see this article:
https://social.msdn.microsoft.com/Forums/silverlight/en-US/d8e2c92a-4b31-4e4b-a440-4960a8d475b4/how-to-generate-xap-file?forum=silverlightstart
Besides here is the screenshot of my setting, that is Right click at your Silverlight project > Properties > Silverlight Application, and you can click the Add button to add content,

Categories

Resources