Use the same file in more than one solution - vb.net

Just wondering whether it is possible to used a single form into more than 1 solutions?
I have frmbookstock.vb in solution A and i need to use frmbookstock.vb in solution B as well. So every time i change the content of the frmbookstock.vb, both of the solution will received the update as well.
I have tried to import it to another solutions, but it will create a new file under the new solution.

Yes you can.
In Visual Studio go to the folder that you want to add the existing item to.
Right click and Go to "Add".
Select "Existing Item".
Select your file.
IMPORTANT STEP: Select the little dropdown arrow next to the "Add" button.
Select "Add as Link" instead.
This will place a link to the original file in the source folder.
So now you have two Visual Studio items in different projects that point to the same, real, file on your hard drive.

Related

Save Aptana Studio 3 project explorer state on close

I'm sure there is a simple option for this but I have as yet been unable to find it. Every time I close and reopen Aptana Studio 3 it collapses all the folders in the project explorer and I have to reopen them all, is there a way to get it to leave them open and save the project explorer's state when I close the program?
Thanks.
I cannot find any way to keep the state of the Project Explorer. However, using the App Explorer, the state of your open folder will be preserved. You can also try the "Navigator" which looks just like the Project Explorer, but appears to keep state. I will add the proviso to that: It kept state when I restarted aptana, but it also developed a GUI glitch where it appears to be scrolled to the right so I only see the right half of all of my file names and I cannot fix it, so this may not be a good option if you get the same glitch.
There is also a method which does not do quite what you ask, but may be a good fix for you anyway. If you click "Link with Editor" picture (two yellow arrows) in the Project Editor, it will automatically expand your project hierarchy to match whichever open file you have active. Since your files stay open when you close Aptana, this would keep the Project Explorer expanded to whatever you are looking at even on restart. See this question
You can also set up working sets for various parts of your code that are buried in the hierarchy and use the Project Explorer to show those working sets instead of you projects. This does not save state, but it does give you easy access to common parts of your code that may be deeply buried.
Hope one of these helps you.

Merging two VB.Net Projects

we are new to Visual Basic Programing, We are working on a project, which has modules. My team worked on these modules and prepared 3 separate Visual Studio Projects. Now, I want to combine then into one Visual Studio Project for Integration purposes.
We are using Visual Studio 2010.
In the solution explorer window (Default is top right) you will need to:
Right click on your Solution
go down to Add
select Existing Project
This will pop up a windows browser window, you will need to navigate to the place that you have the files saved, then click Open
Repeat steps 1-4 for all subsequent items.
Based on what you are saying, it sounds like youll need to add references to the modules in the main project:
Ensure that you are viewing all files in your solution by selecting Show All Files in the Solution Explorer
go down to References
click Add Reference - a window will pop up
in the top left, select Projects
in the popup window Right click on the Name of the project and select Add Reference
You should be good from here.
Your question is not clear wether or not you want to add the code from the individual projects to one project or add your projects to one solution.
In the first instance use the project that you want to be the main project and right-click on the project and select add existing item to select the .vb module file that you want to add.
In the second instance create a blank solution File -> New Project -> Other Project Types -> Visual Studio Solutions -> Blank Solution, then right-click on the new solution and select Add -> Existing project to add your projects

Why would a .sln file open as empty in VB2010Express when it should open referring to projects etc. as it did before?

Why would a .sln solution file open and appear empty in Microsoft Visual Basic 2010 Express - i.e. no windows showing projects and code files etc.
When I inspect the file in a text editor, it contains references to vbproj files (which are present) which indicate that it should not appear as empty.
No error messages are reported when the file is opened.
Update:
(To illustrate my problem)
It attempts to load the projects that belong to the solution:
And then results in a bare solution screen
Express Edition is limited to on project per solution. If you have more than that, you will not be able to use the solution file with the express edition of visual studio. You will need to open the projects separately.
The answer is that the projects did load for the solution but the Window to display them was not open or visible. To make it visible, go to the View menu and select Other Windows:
This displays the 4 projects referenced by the solution
Forgive me for blurring the project names but this might be commercially sensitive and therefore not for public awareness. But you get the picture.
In summary it was my lack of knowledge about the tool, though I had looked under the Window option first thinking along these lines, but the View menu is actually where one would go to display things about the project.
Thanks to everyone for your contributions.

How do I add an existing folder to Visual Studio 2010 Express project?

I'm trying to add a folder and some files within it to a Visual Studio 2010 Express VB.NET project. I have read the answers to questions on this subject here and here. They both say "select folder, right click, and then select Add To Project".
But when I right-click in this way, no "Add to Project" option appears. Does anyone know why this is so, and what I can do about it, or alternatively another way of adding a folder to a project?
Yes, this works fine. Click on the "Show All Files". You'll see ghost images of all the files that are not included in your Solution. Right-click on the folder that you want, then click the "Include in Project" It comes right in with no problem and shows up in your Solution Explorer menu.
I found this:
Visual Studio - Add Existing Folder
Instead what you can do is hit the "Show All Files" tool strip button at the top of the solution explorer, then right click on the folder you want to add and hit "Include In Project". Pretty trivial. Its amazing how long you can use a product and not know about all of its features.
Click on File.
There you can add a new or an existing project.
Once you've added a new or existing project, you can rightclick and add projects on the solution explorer.
So there is absolutely no need to show hidden fiels etc.
I understand your problem because I also use VB.Net 10 Express, and have also used the pukka versions. You do NOT, as you are aware, have the right click add to project facility however there is a way to add an existing form/class/folder etc to a project, but you have to be prepared to dive into the .vbproj file.
Here is an example of one I added to one of my projects. First of all EXIT VB.NET
Now copy the .sln, .suo, .vbproj, .vbproj.user files somewhere else or just zip them up as a backup in case you manage to screw it all up!
Next open the .vbproj file with an editor. You could use notepad or textpad but I use and recommend scite. Anyway whatever you use it must be a plain text editor. Forgive me for stating the obvious but do NOT used Word, WordPad etc.
In the file find the section that starts
<itemgroup>
You can tell if you have the right one by the fact that the entries say
<Compile Include=
Other groups say reference include or import include and you don't want those. Within that section add the code needed to get your folder and files into the project. Here is a sample:
<Compile Include="SuperPro Extras\FGeophysicalReport.designer.vb">
<DependentUpon>FGeophysicalReport.vb</DependentUpon>
</Compile>
<Compile Include="SuperPro Extras\FGeophysicalReport.vb">
<SubType>Form</SubType>
</Compile>
Note that your FOLDER is added at the front of the file names. For each of the vb files you should add the name of the designer file and the name of the code file (as above).
Finally you need to include the resx file. You will find another ItemGroup that comtaines the embedded resource files. The resx file is added into this group in exactly the same way.
<EmbeddedResource Include="SuperPro Extras\FGeophysicalReport.resx">
<DependentUpon>FGeophysicalReport.vb</DependentUpon>
</EmbeddedResource>
Note the folder\filename on the first line and then the dependency WITHOUT and folder name.
I know this is a LONG time after the question was asked so possibly not usefull to you but I hope it helps someone else. I think I will develop a utility to do this. I have one for assembly/file numbers so this would be a useful addition.
I wanted to add a little more comprehension to this as some of the directions were not explicitly clear considering one's level of Visual Studio knowledge. Here's a quickie on how I accomplished this task (using VS2013).
Drag/drop folder you want to include in the Resources folder
(i.e. %path%\"Project Name"\"Project Name"\Resources\)
For this example, I wanted to add a folder structure named AppData.
In Solution Explorer, on Top Panel, click Show All Files then click Refresh.
Locate your folder (mine: AppData) under Resources then right-click > Include In Project.
Images for guidance:

"There is no editor available for ../Form1.vb" error?

I was happily using VB.NET, saved, and, well, there was a blackout.
Probably lucky? Well, now I open my project just fine, double click the Form1.vb and.... "There is no editor available for ../Form1.vb, make sure the application for the file type (.vb) is installed."
.......... Did something go wrong with my project? Is it dead?
Windows 7, Visual Basic 2010 Express.
What should I do?
The same thing just occurred to me but I couldn't get it fixed trying the previous answers. For some reason, one of my references Microsoft.Office.Core had a yellow exclamation point on it.
Simple Solution
Solution Explorer
Expand References
Right click on the item with "Yellow Triangle w/ "!" point"
Select "Remove"
Open the "Build" Menu at the top
Select Rebuild "filename"
Once this was done, I could open my forms correctly.
It's difficult to imagine what you're seeing. I've seen plenty of cases where the design view won't open for whatever reason, but I've never been unable to view the code for the form.
First thing to try is navigating to your project folder in Windows Explorer, right-clicking on the Form1.vb file, and trying to open it in Notepad. This is pretty much the ultimate test. If you can open it in Notepad, your work is salvageable. If not, the file is corrupted and your best bet is to start over. I suppose if you really feel that you have a lot invested, you could try various file recovery techniques, but considering it's a single form file, I seriously doubt it's worth the time or expense.
If that succeeds, and you can open the file in Notepad, select all the code and copy it to the clipboard. Now go back into Visual Studio, and add a new Form to your project. Delete everything in the new form's code file and paste the salvaged code from your original form back in. You still won't be able to open the form in the designer though, and you'll likely be missing references to all of your controls. Ignore all those squiggly underlines for now.
To fix that, you need to go back to Windows Explorer, and find a file named Form1.Designer.vb. This is the partial class that the designer saves information into; it contains declarations for all of your controls and the properties you set for those controls at design time. Just as before, right-click on this file and open it in Notepad. Select everything and copy it to the clipboard. Now go back to Visual Studio, and click on the "Show All Files" button at the top of the Solution Explorer (hover over them to read the ToolTips). You'll see a bunch of extra junk show up, but what you're primarily interested in are the drop-down arrows that just appeared to the side of every Form class. Expand the new form you added in the previous step, and find it's .Designer file. Delete everything that's in there now, and paste in the code from your salvaged form's .Designer file.
You now have an exact copy of your old form in your project. You can delete that old, corrupted form file, because you're no longer using it. You'll also probably want to change the name of the new file itself by right-clicking on it in the Solution Explorer—right now, it's named Form1 just like your old form, because it's an exact copy of that form. The code says it's name is Form1 and couldn't care less about your file name. Clean and rebuild your project, and if things go your way, everything should be back to normal.
Windows 7/ Vista:
Try right clicking the .vb file and selecting the "Previous versions" tab. When the list has loaded (if it has) select the most recent file from the list and select "Restore". Now reload your project, try doing this with all of the form files, e.g. "Form1.resx" and "Form1.designer.vb" and "Form1.vb" and then reload the project.
It implies that the file is corrupted.Replace an uncorrupted copy of that file in the corresponding directory and then try.
I had the same problem and it was from a bad reference to Excel caused by copying the project from a Win7 machine to a Win8 machine probably.
Open the solution explorer and expand the references You will see two references with the yellow exclamation mark icon beside them indicating a problem - Microsoft.Office.Core - Microsoft.Office.Interop.Excel Right click on both these icons and click remove Your form should load now, if not, save the project, close it then reopen it.
i have this problem too . when i restart Visual Studio the form create successfully and show it's designer.
I've created the Form with a different version of VS, other than 2012 (eg VS 2010, VS 2013, VS 2015; I've used VS 2015). Save the Form in the solution, open the solution with VS 2012 and include the form in the solution. It worked for me.
To fix the problem you need :
1) NotePad++
And you should follow this simple steps :
1) Close Visual Studio .
2) Go to the Backup Folder of your VS version usually in : "C:\Users(your user name)\Documents\Visual Studio (year)\Backup Files\your project or application name" .
3) Open the last Backup file of your corrupted file , usually the name format is : "Recovered-month.-day-year-time.(Your File Name).cs" with NotePad++ , and copy the source code .
4) Go to your corrupted file in the project folder and open it with NotePad++ , Edit => Select All => Past the source code and Save .
5) Go to windows start list and search for : "Visual Studio Tools" folder , open it and double click on : "Developer Command Prompt for VS(year)" .
6) Write this two codes in the Developer Command Prompt : "devenv.exe /setup" and then "devenv /resetskippkgs" .
7) Open your project .
Note : if this didn't work for you try to do the steps before in this arrangement :
1) => 2) => 3) => 4) => 7) => 1) => 5) => 6) => 7)
and your problem will be fixed .
It works 100% for me , i hope this will helps you
Try changing the security permissions on the form affected. Right click the file, go to properties then security and change the access ability to everyone.