I'd like to add an item into the Visual Studio 2008 context menu exactly how ASP.NET MVC projects have "Add View" or "Add Controller" items in the context menu. How would I accomplish this? Do I have to write an add-in?
Thanks,
Nathan
you and I are probably trying to do the same kind of thing.
So I will share whatever I have found while doing my own research.
Oleg Sych was kind enough to point me to the ASP.NET MVC dll Microsoft.VisualStudio.Web.Extensions.dll file that contains the MvcTextTemplateHost class.
Take a look at this DLL using the .NET Reflector tool.
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Microsoft.VisualStudio.Web.Extensions.dll
As you will see, the DLL contains WinForm classes such as MvcAddControllerDialog, MvcAddViewDialog, and other classes.
So I am pretty sure you can dig around in there to figure out how they did it.
Another place to look is definitely the Visual Studio Extensibility Developer Center.
In the [Learning Center Resources] section, click on [Custom Wizards] link (msdn.microsoft.com/en-us/vsx/dd631327.aspx --- sorry I can include ONE Hyperlink per post at the moment).
Wizards can be implemented in Visual
Studio to let users select from a tree
view of available values when they
open the Add New Project dialog box or
the Add New Item dialog box, or when
they right-click an item in Solution
Explorer.
So start from those two places. I will post some updates myself as well if I found out more.
Related
I have created a C++ template with certain configurations in visual studio 2019, which is saved as a .zip file in the default ProjectTemplates folder.
However, when I open the New Project dialog, I couldn't find my new template, the dialog only shows me 3 options under the left Recent templates tag which is not what I want, and I can't find my own template in the right Scoll-down menu.
Please tell me how to create a new project from self-created template.
By updating my VS 2019 to professional edition, I managed to see my templates in the New project list. I am not extremely sure about the reason, just give a hint for this issue.
We are attempting to add MVC to an old, large, legacy webforms app. (The intent is to gradually re-implement portions of the app using MVC until the old app is gone).
Setting it up has gone smoothly. We have an MVC Area, and I created a controller which is accessible when running the app, by means on directly typing the url.
But whenever we "Add > Controller" or "Add > View"... Visual Studio hangs for around 10 minutes "Not Responding".
Clearly there is some bug in visual studio interacting with some quirk in our legacy project.
Googling, I have so far found only a few similar cases that are old & do not seem applicable.
Not sure where to begin resolving this.
UPDATE:
For what it is worth, we have converted the original VB webforms project to C#. I then added MVC Nuget package and and MVC area. Visual studio no longer seems to hang when adding controllers. So this might be a VB specific thing. Or maybe some windows update to visual studio fixed this in the interim since i posted this. Not sure.
The problem is still present in Visual Studio 2015 Update 1.
As a workaround, instead of selecting "Add View" you can select "New Item" and choose a page template from Web/MVC instead.
It is still in Visual Studio 2017; It takes time and you can restart making Controller/View or you can wait sometimes
this seems like bugs from visual studio,
you can copy other controller and paste it then rename namespace.
for temporary until visual studio is fixed.
I'm having the same issue. This should work. I'm selecting "Add Controller" from the context menu. It just spins saying Visual Studio not responding. This is with Visual Studio 2015.
In my case this situation arises when adding view to the controller and visual studio 2015 hangs indefinitely. However it creates the view file in the directory but not shown in solution explorer. I have manually copy pasted the file from directory to solution explorer and everything worked well.
Check if the below blog could help resolve your issue
http://digioz.blogspot.co.uk/2013/06/visual-studio-2012-freezes-or-crashes.html
I just downloaded the new nopCommerce 3.2 MVC 4 application.
When I open the solution in Visual Studio,
I can't add a Controller : there is no "Controller...." option from the "Add" menu.
There is also no "Add View" when I right click inside of a Controller.
It seems to be treating all the projects in the solution as "Web Forms".
I think is has something to do with the last Windows update. It changed something.
I have the latest updates on Visual Studio.
Anyone have any idea how I can fix this?
Thanks
UPDATE : Solved. Need to install this update :
[ASP.NET and Web Tools 2013.1 for Visual Studio 2012][1] : [1]: http://blogs.msdn.com/b/webdev/archive/2013/11/18/announcing-release-of-asp-net-and-web-tools-2013-1-for-visual-studio-2012.aspx
You need to add {E3E379DF-F4C6-4180-9B81-6769533ABE47} as 'the first GUID' to in your project .csproj. You may not need to update your Visual Studio.
Refer to Context menu to Add Controller/View missing
Just two steps
1)Update your Visual studio 2013
2) unload your project from solution explorer then Reload it again.
I want to create a replacement T4 template that can be called from Visual Studio's "add view". Where should I put the file? I'm not sure I should put it in
C:\Program Files\Microsoft Visual Studio 10.0\
Common7\IDE\ItemTemplates\VisualBasic\Web\
MVC 3\CodeTemplates\AddView\VBHTML
I suspect it will get wiped during repair etc if I put it there.
You can put your custom T4 template under your project like this:
{YourProjectFolder}\CodeTemplates\AddView
Of course this way it will only be enabled for this specific project, while putting them in the location you mention in your question will enable it for all your projects system wide.
Here you can find an interesting article going further into the details:
T4 Templates: A Quick-Start Guide for ASP.NET MVC Developers
There's even already a nuget package who does all the plumbing for you:
Add the ASP.NET MVC 3 Code Templates to your application with Nuget
create the following structure in the ROOT of your Project (Not solution):
CodeTemplates\AddView\VBHTML (in your case, or CSHTML for C# razor views) and copy the templates from that folder into the newly created VBHTML folder.
Also in set the Tool property in the files' Property to empty, otherwise it will ask to build the *.tt file every time you save. Also consider using Tangible T4 Editor extension for Visual Studio to edit the templates. It's available on http://visualstudiogallery.msdn.microsoft.com/
There are two possible locations. Either the one you showed which will be global for all projects on the system or in ~\CodeTemplates\AddView\VBHTML\MyTemplate.tt if you want this template to be available only for a given project. Here's a blog post about it.
I'm not sure if this question is appropriate for SO, but I'm sure a few people here have been through it:
I'm trying to follow the MVC tutorials on the ASP.NET website and there's a point at which it has you add an ADO.NET entity to the project, but for some reason, it doesn't appear on the dialog for adding a new item. I've got SP1 for .NET 3.5 installed, so I have no idea why it isn't showing up. Anyone know of something else I need to install or tick for it to show up?
Thanks
The Entity Data Source appears on the Toolbox, in the Data section.
Here's some helpful information from an MSDN blog for people who can't see the item in the Toolbox:
Can't find the Entity Data Source?
If you upgrade the RTM version of Visual Studio 2008 with SP1, the EntityDataSource control doesn't appear in the Data group of the Web project Toolbox by default. To add the control to the Toolbox:
·Open Visual Studio
·Open or create a Web Application
or Project.
·Make sure the Toolbox tool window is visible.
·Right click on the Toolbox, in the Data group and click on the "Choose Items…" option.
·Wait for the "Choose Toolbox
Items" window to appear.
·Scroll down in the list of components under the ".NET Framework
Components" tab until you find
"EntityDataSource"
·Ensure the checkbox is marked
next to the EntityDataSource
component and click on the OK
button.
If you cannot see “EntityDataSource” in the list, you may need to add the assembly manually. To do that, click on the “Browse” button on the “Choose Toolbox Items” window. Then browse for the System.Web.Entity.dll under “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5” or the equivalent folder in your configuration.
You need the Visual Studio Team System 2008 Database Edition GDR.
http://blogs.msdn.com/gertd/archive/2008/11/25/visual-studio-team-system-2008-database-edition-gdr-rtm.aspx