Creating a .dll file in C#.Net - c#

I had created a project which is C# console application project for which I need to call this project dll in another windows application project. I had built the project in visual studio 2010 and checked for .dll file in bin\debug folder, but it is not created.
But a manifest file and .exe file havebeen created. Please help me out how to create the .dll in this case?

You need to make a class library and not a Console Application. The console application is translated into an .exe whereas the class library will then be compiled into a dll which you can reference in your windows project.
Right click on your Console Application -> Properties -> Change the Output type to Class Library

To create a DLL File, click on New project, then select Class Library.
Enter your code into the class file that was automatically created for you and then click Build Solution from the Debug menu.
Now, look in your directory: ../debug/release/YOURDLL.dll
There it is! :)
P.S. DLL files cannot be run just like normal applciation (exe) files. You'll need to create a separate project (probably a win forms app) and then add your dll file to that project as a "Reference", you can do this by going to the Solution explorer, right clicking your project Name and selecting Add Reference then browsing to whereever you saved your dll file.
For more detail please click HERE

You need to change project settings. Right click your project, go to properites. In Application tab change output type to class library instead of Windows application.

Console Application is an application (.exe), not a Library (.dll). To make a library, create a new project, select "Class Library" in type of project, then copy the logic of your first code into this new project.
Or you can edit the Project Properties and select Class Library instead of Console Application in Output type.
As some code can be "console" dependant, I think first solution is better if you check your logic when you copy it.

Creating DLL File
Open Visual Studio then select File -> New -> Project
Select Visual C# -> Class library
Compile Project Or Build the solution, to create Dll File
Go to the class library folder (Debug Folder)

Related

Click Once Deployment - How to publish an application which has multiple VS projects?

I'm building a complex WPF application. I'm having multiple visual studio solutions. Each solution has a project. Due to code protection reason, I had to place projects in separate solutions.
ComponentMain Solution (WPF Application)
ComponentA Solution (Class Library)
ComponentB Solution (Class Library)
Component A & B referenses assembly of Main Solution. The main solution loads the assemblies of Component A & B using reflection during the runtime.
When I build each solution, an Xcopy post build event will be triggered and all the dll's are copied into a folder called GlobalOutput, where I can run the application by simply running the MainSolution.exe.
Now I want to publish the application using ClickOnce. As I mentioned earlier, there are multiple projects and Dll's are loaded using reflection.
As per to my knowledge I cannot use the click once publish wizard due to above reason. May be i'm wrong.
How can I publish my application using click once.?
As I haveing all the dll's in GlobalOutput directory, Is there any way to create clickkonce deployment directly from there?
You can try to specify which files are published by Click Once.
For you, it will be something like:
Pick one of those solutions/projects as the publishing project to configure Click Once. You need to mark the dlls from the other projects/solutions as prerequisites.
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Publish tab.
Click the Application Files button to open the Application Files dialog box.
In the Application Files dialog box, select the application assembly (.dll file) that you wish to mark as a prerequisite. Note that your application must have a reference to the application assembly in order for it to appear in the list.
In the Publish Status field, select Prerequisite from the drop-down list.
To make the file from the other solutions/projects appear in the Application File Dialog box in step 3, you can either reference the output dlls, or add them as solution file and set the build action to content.
For more information: Specify Which Files Are Published by ClickOnce

How to copy .exe from C++ project to the output directory of a C# project?

Say you have a Visual Studio solution containing 2 projects:
Project A: C++ console application
Project B: C# console application
Project B depends upon the output .exe of Project A. Is there a way to set this .exe to be automatically copied to Project B's output folder during build?
You can use Buildevents in the properties for the project.
Here you can define Post and Prebuild Tasks with Wildcards.
like:
copy "$(TargetPath)" "$(SolutionDir)UploaderClient\bin\Debug\Plugins\$(TargetFileName)"
Yes, in VS go into the project properties for A. Look under "Configuration Properties" for a sub item of "Build Events", expand that and add a "Post-Build Event". These are simple dos commands, so you can just copy the .exe where-ever you want.

C# winforms converting a project to .dll

I working on a group task, I must input my work into the main project as a .dll project. in other words I should replace the old InfoCard project with my edited InfoCard.
I have done all the edit and changes in a Winform project how I can convert it into .dll and add it to the main project, Thank you in advance
In Solution Explorer
Right click your Project name
Click 'Build'
Go to your project location (for example: C:\Users\Documents\Visual Studio 2013\Projects\YourProjectName\bin\Debug); In Debug folder you can see the .dll format file
Copy the .dll file and paste it into your current project folder
In your main project, type:
using YourProjectName;

Compiling one .exe file from 2 projects

I have a c# solution that holds 2 projects (1 for the codes of data handling and 1 for the winform UI) the desktop project also holds an access file in its bin folder.
My question is, how do I create an .exe file of the solution that I can send out and it will work?
From your requirement, what I understand is you need to embed the dll in the exe. From VS Project(Your exe project) Properties -> Resources -> Add Resource -> Add Existing File
If UI project refers to "data project", on compilation of UI project in its Debug or Release (based on compilation configuration choice) folder you will find all binaries you need to run UI.
Will this work simply copy/paste on client machine noone can say other then you, as it strongly depends on how your program works.

Create setup File for windows application

I am three class libraries in my windows application project. And now i want to create setup file for my project. So what i did is, just create a new setup project and added my solution file. But it adds only Forms classes. so i manually added all remaining 3 class libraries by right on the setup's solution, clicked add existing project then browsed my class library. And builded the project got the exe file.
when i try to open the installed application it saying that missing dll in the project.
In your Setup project you need to include Content files as well as Primary output for the Windows project.
An example of adding files can be found HERE

Categories