I am doing an MVC project... am very new to MVC... something very strange is happening...
When I drop a control from the toolbox to the design page visual studio closes.. I have no clue why this happens.. am totally perplexed...I tried searching for possible solution in the net...nothing showed up...:(
Unless I've totally missed the boat, you shouldn't be able to drag-and-drop any control from the toolbox to an MVC view. At least in MVC 1.0, views and user controls do not implement code-behind by default, but, more importantly, the designer code file that gets modified in WinForms .ASPXs and .ASCXs is not created when the view is created. In MVC, controls are added to views using code-based HTML helpers or the actual HTML code. The fact that the default Visual Studio behavior when executing a drag-and-drop with a toolbox control is to modify the form's designer file could be causing the immediate exit, since the file doesn't exist.
P.S. Don't bother trying to create it...the framework isn't built to implement or support it and it would probably just slow you down, anyway.
Try to start Visual Studio in safemode via
cd C:\Program files\Microsoft Visual Studio 9.0\Common7\IDE
devenv.exe /safemode /log
If this works then one of the installed add ons is responsible for the crash. It often helps in my environment.
Also you may try cleaning up the project.
Run
c:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe yoursolution.sln /t:Clean
Might help if something got screwed in your project.
Related
I'm working on a few Umbraco projects that use MVC4. The MVC intellisense doesn't work within visual studio and I get lots of errors underlined. But when I run build the project, I don't get any errors, and when I run the site everything works fine.
I'm using Visual Studio 2013 and I created a new MVC4 site and compared the web.configs within the Views folder and they're identical.
I'm pretty sure it's not a code problem as my colleague is using the same code and he doesn't have this problem.
I've just done a fresh install of Visual Studio 2013.
Any ideas?
This could be a clue:
When I hover over #Htmlit tells me that my HtmlHelper is a System.Web.WebPages.Html.HtmlHelper instead of a System.Web.Mvc.HtmlHelper
The common one is to ensure that it is switched on (Visual Studio menu: Tools > Options > Text Editor > All Languages (or C# if you want it just for that language) > Tick "Auto list members", Untick "Hid advanced members", tick "Parameter information")
Once you've checked this, sometimes if you're using one HDD on Windows, because the disk has its bandwidth used up (particularly if using ReSharper then you need two or more drives ideally with the pagefile going to the non-OS drive I find). This is the case if the red lines do disappear after up to two minutes of not touching the IDE.
Finally check you project's references folder to make sure where the paths for your includes are coming from and that Visual Studio has permission to read from there. Permission issues cause all manner of problems I find, so when you launch VS, right click and choose "run as Administrator".
Hopefully one of these solves your problems. If not, then please update your question to explain how you create your project. Do you create an empty site or an MVC site? Do you then use Nuget to install Umbraco through the Package Manager Console like this?
Install-Package UmbracoCms
I recently applied Update 5 to Visual Studio 2013 (Ultimate Edition) running on Windows 8.1. After the update, any time I try to create a Razor View (*.cshtml) file in my MVC application using scaffolding, I get the following error:
There was an error running the selected code generator:
The Templates\PackageVersion5.1.3.xml file is missing from the
installed template folder
From the error, it is clear that some file (PackageVersion5.1.3.xml) is missing but I'm not sure how to fix it. I even repaired Visual Studio but to no avail.
As yoo probably know during scaffolding your view is generated base on this missing xml file. I don't know why your file is not there but you can copy it from one of your colleagues computer or reinstall visual studio.
Maybe you have change something i VS options?
I avoid the scaffolding options in Visual Studio.
Why? In my experience, the standard MVC pattern where everything separated by type will always led to a difficult to manage and test solution.
Instead, I now prefer to organise MVC projects by feature (http://timgthomas.com/2013/10/feature-folders-in-asp-net-mvc/).
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
Any time I try to paste anything in a CSHTML file that contains Razor markup or targets a line inside a code block - the entire Visual Studio freezes for almost a minute.
I've applied SP1 for Visual Studio. I'm using ASP.NET MVC 3.
I also only have this problem on a single computer so I'm guessing there's some sort of application or version mismatch I'm simply not seeing. I'm running ReSharper and upgraded it to 6.0 to no avail (though the Razor code inspection works and is really nice).
It's only if I paste a line containing Razor markup that the issue occur. I get no errors on the copy operation, and if I'm pasting regular HTML without Razor markup or outside code blocks in the very same file there're no issues whatsoever. No problems pasting in any other kinds of files like .cs or .aspx. Freshly created MVC 3 projects suffer as well as existing old projects.
I resolved this a while ago but I don't recall exactly which component was the issue - but it was either SP1 for Visual Studio that was in fact not RTM (though it wasn't obvious when looking at the about dialog hence the difficulty in figuring out) or, more likely according to my memory, a pre-RTM version of MVC 3 installed, also not obvious at all when looking through the installed components list.
It took some manual work to get all the related components uninstalled, including some registry hacks, before reinstalling the RTM version and then the problem disappeared. I did not have to reinstall Visual Studio or any of my addons.
Hope this helps someone with similar problems, carefully investigate the exact build numbers of the suspected components. They may in fact be pre-RTM :9
Have you tried to reset the Visual Studio settings? I can't promise this will help but I think it would be worth a try (devenv.exe /ResetSettings). If that doesn't help, I think you will have to re-install Visual Studio.
I am introducing ASP.NET MVC to a new team and one of the questions that comes up often is "Is there a designer view"
Even if it's not for layout is there an IN visual studio design view for ASP.NET MVC3 using the razor view engine.
No, there is no designer. It would likely be difficult for a designer to even know what is meant by Razor code in many cases.
It's really not so difficult to just use your web browser as a viewer. You can make changes to the HTML without having to recompile, just make the change, save, and refresh your browser.
EDIT (8/2/2013)
Since this answer was originally written, Microsoft has released Visual Studio 2012 which includes a feature called Page Inspector, which while not a true "designer" in the way that the question was written, it does give a much nicer semi-live preview mode. This has been improved in Visual Studio 2013 (which was RTM'd today, 10/17/13).
I use a web browser window and set the url my localhost in place of the designer.
view > "other windows" > "web browser". I then split the windows vertically or horizontaly.
I was able to work using the following trick:
change the razor file's extension to .html
Open the document
with the document open, change file extension back to .cshtml
Congratulations, you now have a designer's view of the razor file. If you need razor intellisense, close and re-open it.
No, in general you should try and steer clear from visual designers. The combination of HTML/CSS/Javascript is something that just cannot be done well with visual designers and the short term pain of learning these manually will be well worth it. Once you know these well you will be coding in a cleaner and quicker way. I often use Expression Web to do initial layouts before copying it to Visual Studio.
I know I am late to the party, but..
You can trick the IDE as mentioned above, but if you are building applications in MVC, you should be comfortable in code view. It is more productive and most of the responsive design and css implementation can give you false results in design view. Designer is useful in WebForms. But with the Browser Link feature in Visual Studio 2013, there is no longer any reason to trick your IDE, you can have one-to-many browsers open and get live updates back and forth from browser to visual studio. Can't beat that! The browser is where it's at!
Browser Link!
Install the following and you will be golden!
Microsoft Visual Studio 2013 Update 3
Web Essentials (Dependent on VS Update 3)
I think they are working on that as a feature for Expression Blend 5 Developer Preview .
They clearly recognise the issue of designing JS in the designer so I suspect they realise the same applies to some designers working on MVC applications.
I was told by someone from Microsoft "I think in Blend for HTML, using interactive mode, you would probably be just fine with designing MVC or MVVM patterns"
Also check out Visual Studio Page Inspector it looks like it will do what is needed
In Visual Studio 2013 added browser link this allows two way communication between browser and Visual Studio. It means you can refresh browser when you change code and instantly see how it looks. Also you can change Css in the browser and have it saved in Visual Studio
There is workaround it is mentioned here http://www.codeproject.com/KB/aspnet/EnablingDesignerSupport.aspx