C# winforms converting a project to .dll - c#

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;

Related

Taking sln file from other app

I worked on some C# app (wpf), I uploaded it as zip file to google drive for now that's the only copy of the project That I have.
The problem is that I forgot to upload the .sln file.
When I downloaded the app from google drive to my pc I took some other .sln from other app and it worked fine for now.
Is it ok? I mean it can cause any problems in the feature?
A solution is sort of like a container that holds all your projects together. So as long as you have a valid project file (.csproj) you can simply create your own solution file and add the project to it.
If you go to:
File > New > Project
you can open up New Project dialog box.
There, under:
Installed > Other Project Types > Visual Studio Solutions
you can create a blank solution.
Once you do that, then you can add your existing project to this new empty solution.
For that, go to your Solution Explorer, right click the solution and select Add > Existing Project and select your project.
I took some other .sln from another app and it worked fine for now:
Most of the time: If you have a single csproj file, all you have to do is double click on the csproj file to build it. Visual Studio will automatically create a solution for your single csproj.
Is it ok? I mean it can cause any problems in the feature?
I think the big issues will only come when you have more than one project in your solution.
For example, lets say you have a solution with Project A and Project B, and project B has a reference to A.
You will need to add both projects to your new solution so that .NET knows to build A first, then build B using the output from building A.

Visual Studio Project rearrange project into folder with same name

Project name is testProject. I want to create a new folder named "TestProject" and move the project into it, because I want to add testProject.uTest and testProject.iTest for unit and integration tests. So everything related is located in the same folder.
The solution is in VSTS. Already one folder exists with the same name because of the project. Namespaces will all change.
How do I go about this the best way?
I got everything to work.
First I opened the solution and deleted the project in there. Then I created the new folder in the solution explorer. I then copied all the project related files into the new folder in windows explorer. I opened up the solution and added this existing project and add all files to source contrl. Next I had to re-add nuget packages and fix some references in other projects. Next I pushed the changes and then I deleted the old project files in source control explorer.
Took 10mins and everything works fine!
A few simple steps that worked for me:
Create a folder and add some text/number at the end:
Example: Infrastructure1
Create/Add the Project to your solution without the text/number at the end.
Example: Infrastructure
Rename the folder (Infrastructure1) to match your Project name(Infrastructure).
That's it, and you will get rid of the message that Project can't be named with the same name as the folder.

Refactor on multi project in Visual Studio with lots of "Linked Files"

I have several C# project in different solution of Visual Studio.
There are many .cs file that are referenced from different project (NOT copy of same .cs file, but only 1 file and several reference in several project).
Now I have created a general solution (.sln) where are imported ALL my project (.csproject)
What I need is refactor some variable name in ALL my project.
I try to open in visual studio the .cs file and do a refactor but it change all name of that variable only inside THAT project and NOT of all project! And if I mouve inside other project i found the error because that variable is not find and I can't do refactor in the same way...
So, what I can do?
I give some other info:
All project compile separatly in each separate solution.
In general solution I import all *.csproj and if i build all project simultaneously or separately they correctly build.
all .cs files that are referenced in many project were added by link and NOT copied
If I open one common .cs file in one project (.csproj) and try to open the same .cs inside another project (.csproj) visual studio give me the error "the file is already opened in another project of solution"
maybe the most important thing: If I open one common .cs file in one project I can navigate inside his functions... In visual studio upper the function there is a small menu that tell ALL reference of that function inside the project.
OK, in this menu I see only the reference inside the project where i open the file and NOT the reference of the other project of my solution.
example: in file "utility.cs" I have function named "TryConvertMatrix(..)". I have one project named "river" that use this function and onother project named "telephone" that use this function. In both project the file "utility.cs" was added as link. If I open file "utility.cs" from project "river" I see all reference of the function "TryConvertMatrix(..)" inside the .cs files of project "river" but NOT where was called inside .cs file of "telephone" project
In the example explaned before, if I try to refactor the name of function "TryConvertMatrix(..)" in "ConvertPerfectMatrix(..)" Visual Studio, correctly, change all reference ONLY inside "river" project!
So when I navigate inside the project "telephone" I find all calling to "TryConvertMatrix(..)" instead the new name so it can't build! And, in this case, I can't do a refactor in this project because... No build ---> No refactor
What I need is only change a name of a variable and ALL reference in ALL project that I have opened in my solution.
I try do delete all project's bin folder, restart visual studio and rebulild
In this way no improvement...
Many thanks,
Massimiliano

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.

Creating a .dll file in C#.Net

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)

Categories