CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

The original Visual Web Part template is missing in Visual Studio 2012

Today I encountered a weird issue, the classic Visual Web Part template was gone in Visual Studio 2012. When I created a Visual WebPart, a webpart was created with a generated .g.cs file, like the sandboxed visual webparts. I am not exactly sure why it happened. According to the MSDN guide Creating Web Parts for SharePoint, the structure of Visual Webparts should be the same as in Visual Studio 2010. It could have happened after I installed the power tools.

However, if someone runs into the same issue, here is the solution:

Copy this zip file from a computer with VS2010 installed:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\SharePoint\SharePoint14\1033\SharePoint14VisualWebPart.zip

Unpack it.

Edit SharePointVisualWebPart.vstemplate. Change the assembly line so it references to the Version 11:

<Assembly>Microsoft.VisualStudio.SharePoint.ProjectExtensions.Wizards, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>

After that copy the directory SharePoint14VisualWebPart to these two locations on your computer with Visual Studio 2012 installed.

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates\CSharp\SharePoint\SharePoint14\1033\
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplatesCache\CSharp\SharePoint\SharePoint14\1033\

Just to be safe, save the SharePoint14VisualWebPart (which have the same name) by appending “.bak” to the name.

If you don’t have an access to a VS2010 computer, I have saved the template for you on github.

Advertisements

24 responses to “The original Visual Web Part template is missing in Visual Studio 2012

  1. Kiran 2012-09-24 at 19:49

    Thanks a bunch. I had the same problem with Visual Studio 2012 RC.

    • Anatoly Mironov 2012-09-25 at 06:37

      I am glad it helped. I could not find anything on google, so I shared this when I found a solution. First I thought i could be powertools. A collleague of mine ran into the same issue without powertools installed.

  2. Chris 2012-10-12 at 10:37

    Thank you!!! Helped a lot, was adding my webparts with vs2010, saving, and re-opening in vs2012.

    • Anatoly Mironov 2012-10-16 at 00:38

      🙂 Glad it helped! I wonder why the original template is gone. Does Microsoft want us to abandon the usercontrol-inside-a-webpart-way, or is it just a miss?

      • Iouri Simernitski (MSFT) 2012-12-05 at 00:51

        Anatoly, I will phrase this a little differently, but yes, we thought you would want to abandon the usercontrol-inside-a-webpart-way. Are there any benefits to it over the VS 2012 way?

  3. Gabriel 2012-11-05 at 15:00

    Unpack it.

    Change the assembly line so it references to the Version 11:

    Where is this?? I`ve opened all files inside the zip and none has an similar text…

  4. Iouri Simernitski (MSFT) 2012-12-05 at 01:05

    Anatoly is spot-on – the new web part is pretty much the same as the Sandboxed Visual Web Part from Power Tools. The big advantage is that the new web part can be added to Sandboxed solutions in addition to the Farm solutions (and even published to Office365).
    Moreover, the end user experience of having two controls (web part and user control) is more complex and error-prone than having just one. I also know first hand that we only had that experience in the first place because of technical constraints that have been since overcome. That being said, maybe that approach had some unique strengths that the Visual Studio team has overlooked?
    If you want the original Visual Web Part back, please post a suggestion at http://connect.microsoft.com/ and articulate the reasons what are the features that are currently missing. We review all customer reports and suggestions on Connect and take it into account when making decisions for the next Visual Studio version.

    Iouri

    • Anatoly Mironov 2012-12-05 at 09:59

      Thank you for your input, Iouri! Now I use the new visual webparts.

    • jasear 2013-01-30 at 18:37

      Hi Iouri,

      As mentioned by Alex below this new change increases development time. Whereas before we just needed to copy the .ascx file to the hive to see our changes take affect now for every little UI change we need to build the assembly, deploy it to GAC and then recycle app pool and then wait for 10-30 seconds (depending on how powerful your development environment is) for the page to load up so that you can see your changes.

      Imagine repeating them 100’s of times every day and it turns into a really slow and painful process.

  5. discoveringsharepoint 2012-12-05 at 13:13

    Great discussion guys! =)

  6. Alex DaSwagga Dresko 2012-12-28 at 18:59

    Webpart development seemed easier with the old template because I could open up the .ascx file in the 14 hive to make small changes before committing those changes back to VisualStudio via copy/paste. That was easier than waiting for VisualStudio to retract, build, and redeploy the WSP just to test the effects of a simple HTML or javascript change.

  7. Dhanashri 2013-03-19 at 07:18

    That’s awesome post. you could solve my problem a big time. Thanks.
    only the correction is in file path location in SP 2013 environment:
    C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates\CSharp\Office SharePoint\1033
    C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplatesCache\CSharp\Office SharePoint\1033

    • Anatoly Mironov 2013-03-19 at 07:38

      Thanks Dhanashri for the correction about SP 2013. I’ll adjust my blog post. But honestly, I abandoned this approach when I began developing for SP2013. As Iouri (in the comments above) said, with the new template you’ll get a more secure, faster and office 365-ready webpart.

      • Dhanashri 2013-03-19 at 09:43

        I agree that the new templates are less clumsy than earlier ones. however I’m not sure how the new templates are useful to implement the connectable web parts feature. as the new template doesn’t install the .ascx file in controltemplates gallery, but instead wrap all filed in the dll; we’ve no way to access the ascx file path control.

        do you have any thoughts on this?

    • Anatoly Mironov 2013-03-19 at 10:03

      Well. Dhanashri. I actually haven’t worked with connected webparts as much. As far as I know, the ascx isn’t so important in connected webparts.

  8. cmatosr 2013-07-24 at 08:37

    Great Post !

    Cheers

  9. sjohn 2013-07-25 at 09:10

    it worked, thank you.

  10. Aditya 2014-07-16 at 21:31

    hello Anatoly Mironov. I need your help in one issue that i am facing with visual webpart in vst 2012 for SharePoint 2013.

    i have one solution file with two projects that i developed for SP 2010 in VST 2010. When i open thi in VST 2012 in SP 2013 server, it converts and shows some final messages and opens the solution.

    when i deploy and add the visual webpart, it says user control under control templates not found. even after manually copied to the required location (i.e., copied to 14/control templates/) i am getting the same error messagge.

    could u plz suggest what to do here.

    thank u.

    • Anatoly Mironov 2014-07-21 at 15:59

      This approach worked a while, but it doesn’t seem to work anymore. As it is not supported, I have stopped using it. I hope you can find a solution. Please share then. Otherwise, we all should stop using this approach.

  11. Saifal Maluk 2014-07-19 at 21:26

    i have follow the same approach and it works but control.ascx.designer.cs file is missing. Please help how to fix it. thanks in advance.

    • Anatoly Mironov 2014-07-21 at 15:57

      I cannot answer this, because I have abandonned this approach. This template is not supported, as stated above by a MSFT employee (see comments). Sorry.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager talking Office 365, SharePoint and Azure

My view and thoughts on Productivity and more.

My programming life

and everything in between

SharePoint Development Lab by @avishnyakov

It is a good place to share some SharePoint stories and development practices.

SharePoint Dragons

Nikander & Margriet on SharePoint

Paul J. Swider - RealActivity

RealActivity is a specialized healthcare services and solution advisory firm.

Mai Omar Desouki - Avid SharePointer

Egyptian & Vodafoner - Senior SharePoint Consultant

Cameron Dwyer | Office 365, SharePoint, Outlook, OnePlace Solutions

Office 365, SharePoint, OnePlace Solutions & Life's Other Little Wonders

paul.tavares

Me and My doings!

Share SharePoint Points!!

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

SPJoel

SharePoint for everyone

SharePointRyan

Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode, ya mama

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

%d bloggers like this: