I have merged another project in my existing project by right-clicking on the project name and selecting Add->Existing project option. Now i wan't to access the files from my newly added project from the existing one in Visual Studio (Its a C# project) , how can i do this?
If I'm following your question, you had a solution with a project A. You then added an existing project B.
You now want to access a file from A in B. If that's the case, right click on the B -> References and add a reference to project A. Now you can use the files from that project.
Edit: From your comment, I'm not sure if you want to have a separate project / file. If you want them to be only 1, you shouldn't really add a new project, you should add to your project A the files you need from project B. If you want to keep it as a different module that is included, then the above holds, but you need to realize that usually you have one solution, with many projects inside of it.
I struggle with this until I found this the link is below:
If you want all windows application to run as one program rather then calling multiple .exe. Then change 'Out Put Type' of each project to 'Class Library'.
Step 1:
You can do that by right-clicking on each Project in solution -> Go to Properties -> Application -> Out Put Type... set it to Class Library
Once you have done that output of these will be generated as .DLL.
Step2:
Add a new Window Form application project, add reference of exiting projects in it so that they can be executed from here.. you can do that by.. right click on main project-> Add Reference->Projects select all existing projects from here.
Now on the main application, you can create 3 buttons to launch each project...
[Inventory]
[Accounts]
[Payroll]
Now in each button code will be something like that...
Inventory_click()
{
Inventory.MainForm frm=new Inventory.MainForm();
frm.show();
}
Credit goes to forum post
Related
I have two projects of Web API and Windows Forms App under one solution.
The names are:
Solution - CliendAddress
Web API - ClientAddress
WFA - ClientAddressWFA
In the ClientAddress project there is a class called ServiceResponse. How can I use this ServiceResponse class in my project ClientAddressWFA?
From my ClientAddressWFA, I've already added the reference to ClientAddress 👇
However, when I am trying to add using ClientAddress.Models; (<---- This is where the ServiceResponse class is) in my ClientAddress.WFA project, I'm getting an error👇
Recording: https://screenrec.com/share/XTp0dwbI42
If you need just this one source file then you can just add it to the other project "as link". Quick and dirty, but who cares. However, if you need more classes, then make a shared library project that would then be referenced by both projects. That's what shared libraries are for.
So, in project ClientAddressWFA try to add this one .cs file but instead of clicking "Add" click on small triangle next to "Add", and select "Add As Link".
Sometimes just restarting the visual studio and compiling again will work (Given that class you are referencing from another project is public and you have added project reference)
I have created an Error form that I like to use for multiple projects, rather than creating a new one. The Error form was created in, say, Project A. The error form is meant for catching exceptions, of course.
And now I am creating Project B. Like I mentioned, I would rather reuse the Error Form from Project A.
So here's what I did: I clicked Project -> Add Existing Item, then I browsed for Project A's Error Form's related files (ErrorForm.cs, ErrorForm.Designer.cs, and ErrorForm.resx). I am hoping to see the Error Form all in one shape in Project B. The Error Form has a PictureBox with a picture set btw.
Unfortunately, what actually happened: Then again, I was hoping to use Project A's Error Form in Project B. And then when I opened the designer, I get this error:
"The name or namespace name "ProjectA" could not be found in the global namespace". It's in this line in ErrorForm.Designer file:
this.pictureBox1.Image = global::ProjectA.Properties.Resources._2021_04_27_182907;
I commented out that offending line. As it wasn't a big deal, since I can always select the same image later from the designer window. However, the ErrorForm is totally blank, as if it was newly created!
Why is the ErrorForm blank, and how can I fix this problem?
Don't add the single form from A into B. That form uses resources from A that you aren't bringing in if you do. You should add the whole project as a project, into the solution. This is like what Ahmed mentioned in the comments,adding a dll and referencing it, except it's adding the project one step earlier, before it is compiled. This means you can tweak the code of the project within the solution rather than switching to another VS, updating the code, recompiling it, referencing the updated dll... VS does all that for you if you bring some dependent project into a solution ; it will compile the dll project A as a dependency of project B
Right click on the solution and choose add an existing project.
in the file picker choose the csproj from project A to bring the entire Project A into the solution.
Change the output type of Project A (in Project A properties) to be Class Library.
In project B, add a reference to project A, right click References, choose Add, in the panel that appears choose Projects and tick Project A
You can now, in any of your project B classes, do a using ProjectA (I'm assuming the error form is just in that namespace and not any deeper one; of it is, adjust accordingly - vs will help you if you point to the lightbulb in the margin/next to any red wiggly line) and you'll then be able to create a new ErrorForm
This is the first time I start with StackOverflow...
I think my question is a silly question!!
I need to call the forms and classes from two C# projects in a third project
I follow these steps:
From Solution Explorer in a third project, I have clicked the Add Reference
I click the Project Tab
I didn't find any add browsing to add these two projects. see the image
Create your multiple project in a single solution. then add project1 and project2 in your project3 reference using >> Add Reference >> Projects >> Solution.
here's how: https://msdn.microsoft.com/en-us/library/f3st0d45.aspx
Your Projects should be under same solution.
If in case you are building two projects differently not under same solution follow these steps
1.Create a winform project let say "Project1" go to project settings change the output type to class library and build it.
2.Create another winform project lets say "Project2" go to project setting change the output type to class library and build it
3.Create third project from where you want to call it. Go to Add reference. Browse for folders as below
debug folder of project1 select project1.dll and add reference.
debug folder of project2 select project2.dll and add reference.
4.Now create objects of Forms and call.
Alright. Visual Studio offers you the ability to add references you just created yourself. Those references could be (dynamic-link-)libraries DLL or executables EXE. So go ahead and create a project and add a new Form. This custom Form needs to be public so the other project is able to extract the code.
Now you are able to add and use a reference. Just be sure to include the namespace, if it doesn't match the one, in which you're going to use it.
The thing is called Project-to-project Reference
I'm wondering if its possible to set up and share an entire folder of source code between multiple projects in Visual Studio 2012 like how eclipse lets you use multiple source folders. I'm currently developing an entity framework model for a game I'm making with split server and client code, said framework currently sits in a class library referenced by both projects.
The reason I'd like to use a shared code folder instead is to add code to each entity component type by declaring the classes in the shared folder as partial and having another partial class in the client/server projects that adds sided functionality. I thought that achieving this would be more useful than extending each component on both sides, and it would also eliminate the need to have a DLL included with the product.
you can add a project to your solution (right click Solution -> Add -> Existing Project) and reference it (right click on your project -> Add Reference -> Solution -> Projects -> "Project you want to reference")
You can right click on a project and select - Add - Existing item.... Within the open file dialog select the desired file, click on the arrow next to the Add button and afterwards on Add As Link
(source: modbusdriver.com)
Please can someone could explain why I get this error and what to do to fix it (or what I'm doing wrong!). The steps I have taken are
Download Source code from http://www.codeproject.com/Articles/16859/AForge-NET-open-source-framework
Opening in VS2010 shows the references cannot be found
Re-Add all 3 references from PlayingCardRecognition\bin\Release so no further warnings
When I try and build or Run I get the following message
To fix this issue, do these steps:
Right click the Project name in Solution Explorer of Visual Studio
Select Set as StartUp Project from the menu
Re-run your project
It should work!
If it did not work, be sure that you have set your start page. If your project is C# Windows Application or C# Console Application, try this:
Right click the Project name in Solution Explorer of Visual Studio
Select Properties
Select the Application tab
In the Output Type drop box
Select the correct application type of your project
Re-run your project and let me know if it won’t work.
The project type set as the Start-up project in that solution is of type ClassLibrary. DUe to that, the output is a dll not an executable and so, you cannot start it.
If this is an error then you can do this:
A quick and dirty fix for this, if that is the only csproj in the solution is to open the .csproj file in a text editor and change the value of the node <ProjectGuid> to the Guid corresponding to a WinForms C# project. (That you may obtain from a google search or by creating a new project and opening the .csproj file generated by Visual Studio to find out what the GUID for that type is). (Enjoy - not many people know about this sneaky trick)
BUT: the project might be a class library rightfully and then you should reference it in another project and use it that way.
.Exe's and .dll's are both assemblies. The key difference is that executeables define an entry point Main which can be invoked by the runtime. The error
"Class library cannot be started directly"
is due to the fact that said .dll's do not have a Main. To fix this issue, change the project type to a Windows application/Console application and define an entry point. Or, add a new project that is of type Windows application/Console application and reference said .dll.
The project is a class library. It cannot be run or debugged without an executable project (F5 doesn't work!!!). You can only build the project (Ctrl+Shift+B).
If you want to debug the code add a console application project (set it as the start up project) to the solution and add the reference to the library.
The project you downloaded is a class library. Which can't be started.
Add a new project which can be started (console app, win forms, what ever you want) and add a reference to the class library project to be able to "play with it".
And set this new project as "Startup project"
The project you've downloaded is a class library, not an executable assembly. This means you need to import that library into your own project instead of trying to run it directly.
Your project type is a class library one would suspect, add a ConsoleApplication or WindowsApplication and use that as your startup object. Reference this project and then access the code.
If you convert the WPF application to Class library for get the projects .dll file.After that convert the same project to the WPF application you get the following error.
Error:".exe does not contain a static main method suitable for an entry point".
Steps to troubleshoot:
1.Include the App.xaml file in the respective project.
2.Right Click on App.xaml file change the build action to Application Definition
3.Now Build your project
Goto the Solution properties -> on Build right side you see the startup project type. here you need to select the console appication/windows appication.
If you got this issue (got it in Visual Studio 2017 RC), and you don't get any of the things listed by Mak post from step 3 onward "4 In the Output Type drop box....", it is because you made a Class Library app when you want to create a cross platform app, so here is the solution :
1 Start a new project
2 select Visual C# and cross-platform app.
3 select cross-platform app (Xamarin and native app)
4 select blank form.
From then , right click, select as startup project and build as mentioned by Mak, and it should work.
If you can afford to start from scratch, it could do the trick as it did for me.
This could do the trick for the main issue as well, but must be adapted to your current version of Visual Studio ("Xamarin.forms portable" for visual studio 2015 for example).
Bye!
VS -> Debug -> Attach unity debugger -> double click project
Set your api project to a startup project:
Right click the api Project than choose Set as startup Project.
Just right click on the Project Solution A window pops up. Expand the common Properties. Select Start Up Project
In there on right hand side Select radio button with Single Startup Project Select your Project in there and apply.
That's it. Now save and build your project. Run the project to see the output.
_Sarath#F1
To fix this issue, do these steps:
Right click the Project name in Solution Explorer of Visual Studio
Select Set as StartUp Project from the menu
Re-run your project It should work!