Convert a completed project to a DLL - c#

How can I convert a completed C# project to a DLL, in order to use it in other projects?
I have Googled but lots of results say to open the Class Library, write your code there, then Build Solution and everything will be ok.
But my question is: how can I convert a completed project to a DLL? The project can include lots of Forms etc.

if your code is complete, you need to create a Class project out of it, if you already have a project then only transfer the useful code to the class project for reuse in other projects
or change the Output Type to class library, you can find that in your project properties under the tab application

If you are using VS2010, go to your solution in Visual Studio,
Click the 'Project' tab
Select 'Project Properties' down at the bottom of the menu
Now in the 'Properties' window click 'Application'. This should show you a menu
On this menu, select the 'Output type' as 'Class Library'
Now when you compile the project you will get your output as a DLL (.dll) in the relevant bin folder.
I hope this helps.

Related

Register c# Lib as Assembly in USQL solution project

I created USQL project in visual studio. I created job and it executed successfully. While following demos, I have added one separate c# lib in solution. But when I tried to register lib as assembly, I could not able to find it on right click in context menu.
My environment:
windows 10 Visual Studio-2015
When creating a .NET library project if you choose the project type "Class Library (For U-SQL Application)" from the New Project dialog, then you will get a project that knows about ADL. You can do this for a brand new solution, or when you add a project to an existing solution. In that case you will get the context menu where the project is listed in the Solution Explorer for registering the library.
For registering any library, you can kick off the process by going to the Server/Cloud Explorer and navigating to the Data Lake Analytics account you want to use. There you can expand the "U-SQL databases" node, and then the particular database you want (e.g. master). You will see an Assemblies listing. You can right-click on this part of the tree and you'll get the register assembly option which will walk you thru the steps needed.

How do I install a C# class library in Visual Studio?

I am trying to use a class library which I found on a different question here.
I am quite new to C#, Visual Studio, and OOP in general, so please excuse me if this is not the right question.
I followed the link and downloaded the zip. The help file does not seem to contain any directions on how to get Visual Studio to utilize the library. I figure that I have to tell it to use the library somehow, but I really don't know what to do. Or maybe I need to copy the .dll to a specific folder. I also assume I need using ... in the top of the .cs files that use it.
How can I use this library in a Visual Studio C# project?
You should add a reference.
In the project you are working on, you can add a reference to the dll (or a library) by doing navigating to:
(Project)->References->Add Reference
[You will find Properties, References and [class]files below your project]
According to your question, you should add "UltraID3Lib.dll" to your project references and use it through adding a using on top of your project files like this:
using HundredMilesSoftware.UltraID3Lib;
After you have successfully added the resource you should build the project and it will copy all the necessary files to your output directory (bin/Release or bin/Debug).
Step 1:
Open Debug Folder (you can find it In your project Folder => Bin => Debug). Copy .dll >files there.
Step2:
In Solution Explorer Right Click on References => Add References
Go to Project Tab.
Under the Project Tab you can find Added References (References added In Debug Folder). >Simply select needed references & hit OK. You're done
Happy Coding....! :D

Runtime Error in C#

I have installed Async-CTP-v3 for using new feature of C# 5 but when I tried to run a console application using async keyword/await expression this error appeared:
"A Project with an output type of Class Library cannot be started directly.
In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project."
Is there anyone can help me?
Thanks.
Your project's output type is almost certainly set to "Class Library".
You can change the Project's Output type by right-clicking on your project in Solution Explorer and selecting properties in the context menu.
Here you can choose the Output type from a drop-down menu. Change your project's output type from "Class Library" to "Console Application"
If that does not work, double check your startup project and make sure it's the project you think it is (and should be).

Copy C++ library to a C# project automatically on build? (Visual Studio 2010)

I have a library written in C++, and a wrapper for this library written in C#.
Both projects are under development, and the way it is now I have to manually copy the .dll from the C++ project to the C# project after each build.
So I was wondering if there was any way to make Visual Studio copy the .dll from the C++ project automatically when re-building?
You can use Build events in visual studio and place a dos command to copy the dll to the current project
Right click on the project in Solution explorer in Visual studio, select properties. There in Build events you can type:
copy c:\Cplusproject\yourproject.dll $(TargetDir)
You can use Post Build or Pre Build events based on your requirements
See this article: http://geekswithblogs.net/dchestnutt/archive/2006/05/30/80113.aspx
Use post build event for that. Just something like xcopy <yourDllFilePath> <destinationPath> and it will copy your dll file to wherever your want
if yr using that c++ dll as reference, then u might be able to add the c++ project as a project reference, and everything will be copied automaticly, and it also helps while debugging.
Click on references in yr c# project, then a dialog window opens and choose Projects and select yr c++ project
There are several approach to achieve what you request.
Here I suppose you are using Microsoft Visual C++, but on other platforms there will be analogous functionalities.
Right click on the icon representing the vc++ project on the Solution explorer
Click Properties
Select the Configuration Properties/Build Events/Post Build Event node
Write the Command Line required to copy the dll around
Remember you must do it for every Configuration and for every Platform supported from your project.
Alternatively you may ask the Linker to output directly on the location referenced by your C# project:
Right click on the icon representing the vc++ project on the Solution explorer
Click Properties
Select the Configuration Properties/Linker/General Event node
Set the Output File property to the location referenced by your C# project
That said, you may also get the dll from the c# project.

Rebuild Visual Studio Library Project Reference

I have a Visual Studio 2010 solution that contains multiple projects. One of these projects is a library, which I have added a method to. Within visual studio I can navigate from the method call in my main project to the method in the library, but when I attempt to build/run the solution it gives me a "does not contain a definition for 'My_Method'". What am I doing wrong?
Seems you are not rebuilding the library project and/or you are referencing the output binary (dll) directly. To solve this you can do one of the following
Make sure you rebuild the library project, and reference the updated binary/dll
Reference the project directly if it's part of your solution, this way, every time you rebuild the dependent project, it will rebuild the library project. The drawback to this is, if you have too many projects, it will slow you (re)builds
It looks as if the library project isnt being rebuilt on each run, assuming that the project reference is correctly added (right click on references -> add reference -> select your library project)
You should make sure that your library is being rebuilt when you run.
To do so :
Right click on your Solution
Click on Configuration manager (approximative translation)
Make sure that the build is checked, if not, check if for the library project

Categories