Copy and paste form into project is not working - vb.net

I accidentally deleted my form file, so I restored through Recycle Bin. However, I found that it's not in my project so I selected [Projectname].vb, [Projectname].designer.vb, and [Projectname].resx in 'Add Existing Item' dialog in Solution Explorer. It was successfully added, but I found that there's thousands of errors that show me things are already declared. And all thing in designer.vb not applied to designer. So I tried delete form files and add again, add .vb file only, etc. But not working at all, and it came even worth, so designer even not open now! Error while showing Designer Photo
Error in designer.vb
Thank you.

If you are trying to copy files from windows explorer. you should copy the three vb file.
In Visual Studio, just add the base .vb file
Just press Ctrl+D or right click your project -> Add -> Existing Item

Related

Visual Studio Error Cant open source code of my form

enter image description here
I was working on my project about 4 hours and after I am done with it I saved it and try to rename the form name bu mouse right click ! after that it gave me like that error even I cant open my source code :( is there any why that can I save my codes at least.
in addition : when I press build it builds with no problem and I can use it.
I guess there was an visualstudio error, It changed the form name but didn't update successfully to the .csproj file. You can fix this issue by opening the .csproj file and edit it (by notepad or any text editor) or unload project and edit it, find the name of Form and mame sure the path to the form and form name is correct
Hope this helps!

How to Add Reference Automatically to a Project when it is in runtime in vb.net?

I am new to vb.net. I am creating a program with vb.net. The program has a database. It should have the ability to add an exe file to its database and as reference. When the exe file is added to database it can be run by clicking on an Icon.
I solve the database problem. I can add the exe file to my database and run it. However, the main problem is to add the file to my project references automatically. I mean I want to add the exe file by selecting the file with openfiledialog or something like that. This way, I will be able read some data from the exe file and add them to a database.
For example, My project name is "MY Project". When I run its exe("My Project.exe"), in its menu, I have a button named("Import exe.file"), when I click that button, a window is opened for selecting the exe file.when the file is selected, the program automatically add the exe file to its database and add the file to "My Project" references.
I didn't find any code to add a file to references.
Any help is greatly appreciated,cause I spent more than 2 weeks on this problem, without any progress.
Thanks,
Sepehr

How do I add a linked file to the My Project folder in a VB.NET project?

How do I add a linked file to the My Project folder in VB.NET in VS.NET 2010? A 'linked' file is when you right-click a project in VS.NET, select 'Add -> Existing item...' and in the file dialog, click the arrow to say 'Add as link'.
I am trying to add a shared 'SolutionInfo.vb' file to my project, but I want it next to the 'AssemblyInfo.vb' file which resides in the 'My Project' folder. Simply dragging it into the locating in Solution Explorer is not allowed. The file is added successfully but it is in the root of my project. I want it inside the 'My Project' folder.
Anyone know how to do this?
P.S. C# folks, I know this same thing can be done and you can drag the file into the 'Properties' folder which is where the AssemblyInfo.cs file resides in C# projects. So in C# not a problem; just VB.NET.
You didn't originally say which version you're referring to, but I had VS2010 open when I answered the question.
Instead of Drag'n'Drop, with the mouse, Cut'n'Paste, with the keyboard, works!
That is, create the linked file in the top level, then select it and type Ctrl+X to Cut, then select a file within the My Project folder (with Show All Files on) and type Ctrl+V to Paste.

View Designer Code in Visual Studio 2010

What is a standard way to open the Designer (automatically generated) code for a VB file?
As a workaround, I can get to it by searching the entire solution for some keyword that is usually only found in those files: Global, Partial, etc.
Open the Solution Explorer. Along the toolbar at the top there is a tool Show All Files (it is the 2nd from the left on my version of visual studio). Click on that tool. All of your Form files will now have an arrow beside them. click on that arrow to expand. Look for the code file named FormName.designer.vb. Double-click on it to open.
You have to click the "show all files"-Button. Then you can also see the Designer.vb-files.
Note: For C# and VS 2008, but the same applies to VB in VS 2010.
http://peterkellner.net/2007/12/31/visualstudioshowallfiles/
http://blog.brianhartsock.com/2009/09/14/visual-studio-tip-show-all-file/
Keyboard shortcut for Show All Files
Show All Files is a useful little button in the Visual Studio solution explorer to give us a full view of the directory structure our project files are sitting in. When it is off, we only see the files that are explicitly included in the project, but when it is on, we see everything. This makes it very easy to explicitly opt a file into the project without doing an add -> existing item -> find existing item in directory structure and add to project.
The default when creating a new Visual Basic application in Visual Studio is to not show all files, and unfortunatly there is no setting you can adjust to change that.
Open the code file, and in the top-right corner of the code window is a drop-down containing all methods. Open this and select "InitializeComponent".
A screenshot from a newer version. Visual Studio 2015 and 2017 will look like this.

"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.