Showing posts with label Visual studio 2012. Show all posts
Showing posts with label Visual studio 2012. Show all posts

Friday, March 21, 2014

Visual Studio 2012 error + An exception has encountered .This may be caused by an extension



This  error came up in our server ,by which I was not able to open the ascx or aspx files in visual studio 2012.This error caused the intellisense to not work in design pages, also the Tools box was not showing up with any controls only the HTML controls was available.

Analysing the Log I found that there was the below exception


System.NullReferenceException:Object referencenot set to instance of an object.at Microsoft.VisualStudio.Web.Exports.HTMLClassifierProvider.Microsoft.VisualStudio.Text.Classification.
IClassificationProvider.GetClassifier(ITextBuffer textBuffer) at Microsoft.VisualStudio.Text.Classification.Implemention.ClassifierTaggerProvider

Logs can be found at  "C:\User\UserName\AppData\Roaming\Microsoft\VisualStudio\11.0\ActivityLog.xml"

You can try below steps to resolve this issue

  1. Open visual studio click Tools  then Import and Export setting  reset all.This will reset all your custom changes
  2. Choose Tool -->Tools Box item run it once
  3. Tools-->Extension and updates-->If you have installed any vulnarebale packages uninstall them
  4. Run the Visual Studio Repair
  5. Uninstall and Install the VS 2012 again
  6. In my case none of the above worked
So what I did was to give a try to reinstall the .netFrameWork 4.5 .This did the magic for me.
I guess some of the system update corrupted the framework hence the issue was caused.VS2012 installer also installs the framework but since it was already installed, it dint try to install again I believe. Downloading a new package of .net FrameWork 4.5 and installing it solved my issue with Visual Studio 2012

 

Wednesday, January 22, 2014

MSOCAF error- Remove inline code present in the aspx pages


Remove inline code present in the aspx pages. Inline code is not recommended within a site definition due to the issues involved with the code no longer rendering as soon as the page is customized. Inline code is supportable if included on a page in the _layouts directory. Inline code should not be allowed through the PageParserPath exclusion, except in extremely rare circumstances, because it can be modified without going through any review process. As a result, it represents a danger to the environment’s performance and security. Adding PageParserPath element to the web.config files is not allowed. Modifying these files may ‘break’ SharePoint in some way if you change the wrong part of the file
 
 
Found this error while running the MSOCAF on my project having aspx file been deployed to Layouts folder.
 
This error is mainly due to using the <script> tag in your ascx file as below to refere your "js" files in different location like site assests,layouts or any other location
 
 
<script src="myscripts.js"></script>
 
This tag throws the above error
 
This can be resolved by using the tags as mentioned below
 
<SharePoint:ScriptLink ID="ScriptLink1" Name="~sitecollection/siteassests/myscripts.js" runat="server" />
 
 

Tuesday, August 27, 2013

SharePoint Event receiver triggering for all list .Need to trigger for only one list or one type of list

Hi one of the most common requirement in SharePoint is to have event receiver attached to a list .But when you add a event receiver item in Visual Studio and deploy .It will be attached to all the list .

Below are the few things you need to follow to attach a Event Receiver to particular list in SharePoint

1)In the Element.xml of Event Receiver change the tag property as below

         <Receivers ListUrl="Lists/List1">

This will attach the Event Reciever to only List1


2)Changing the tag as below

        <Receivers ListTemplateId="10001" >

will attach the Event Receiver to all the list in site which as listTemplateID =10001

These id are found when you create a list definition by yourself through Visual Studio.
Follow  this link Default list template Id to know about default list id of share point list.


Even after doing this few people see that Event Receiver is been attached to all the list .

The main reason for this is the Feature which is trying to activate the Event Receiver is at Site scope it has to be always at Web scoped . If it at Site scoped the ListUrl and ListTemplateId will be overridden and it will be attached to all the list in the site.

Wednesday, August 7, 2013

SharePoint 2013 Workflow

The concept of Workflow in SharePoint 2013 is changed a whole lot.

The three thing which you need to take care while configuring the workflow to run on SharePoint 2013 is that

  1. Workflow Manager 1.0
  2. Workflow client 1.0
  3. Workflow Manager Tool for Visual 2012
  4. Developer Tools for Visual studio.

As the Workflow does not run inside the share point  you can install Workflow Manager 1.0  on different server or on same server where share point is hosted ..You can follow the MSDN link below to install and configure the Workflow Manager 1.0.

http://technet.microsoft.com/en-us/library/jj658588.aspx

Workflow client 1.0 - This has to be installed on all the sharepoint server (Web fornt end,App).This has API which communicates with the Workflow Manager.

Workflow Manager Tool for Visual 2012 - This has to be installed on the server where you create Visual studio 2013 SharePoint Workflow.Assuming that VS2012 is already installed .
2013 Sharepoint WF template is named as "Workflow"  in VS the "sequential and state machine" template is legacy now and it is not used in SharePoint 2013.

Developer Tools for Visual studio- Is to be installed on server where the Visual studio 2012 is installed.This provide new activities in Tool Box of VS12.


Along with this when you try to install the WorkflowManager through webPlatform installer .
Service Bus and cummunlative updates will be installed automatically.If you are installing it manually you need to install all the updates and Service bus.


Even after having all this there will be few problem with sending mails from VS12 WF.To overcome the issue You need to Install the MARCH-PU sharepoint 2013 updated and configure the same.


Plese follow the below link to install and configure it

http://www.deliveron.com/blog/post/Installing-March-2013-Public-Update-on-SharePoint-Server-2013.aspx


After all these are done you also need
  • App Management Service to be running
  • User Profile Service to be running
  • User Profile Sync Service to be running
Only then your WF runs without any problem :)

Friday, July 5, 2013

Add data to People picker field programatically -Sharepoint 2013

I had a requirement where in the visual webpart had a people picker control .I used the client people picker which is a new and betta control in Sharepoint 2013.This control had to be binded with the data coming from a people picker field of some list.Here is the code to achieve it




SPFieldUserValueCollection reviewers = (SPFieldUserValueCollection)Item["PeoplePickerFieldColumnDisplayName"];
List<PickerEntity> reviewersEntity = new List<PickerEntity>();
foreach (SPFieldUserValue spuserval in reviewers){

SPUser userToassign = spuserval.User;
PickerEntity entity = new PickerEntity();
PeopleEditor pe = new PeopleEditor();
entity.EntityData["AccountName"] = spuserval.User.LoginName;
entity.EntityData["SPUserID"] = spuserval.User.ID;
entity.EntityData["Email"] = spuserval.User.Email;
entity.Key = spuserval.User.LoginName;
entity.Description = spuserval.User.LoginName;
entity.DisplayText = spuserval.User.Name;
entity = pe.ValidateEntity(entity);
entity.IsResolved =true;
 reviewersEntity.Add(entity);
}
PeoplePickerControlName.AddEntities(reviewersEntity);



*"item " is a SPListItem type


in ascx file client people picker looks like

<SharePoint:ClientPeoplePicker runat="server" ID="PeoplePickerControlName" Required="true" ValidationEnabled="true"
                        InitialHelpText="text"
                        VisibleSuggestions="3"
                        Rows="1"
                        AllowMultipleEntities="true"
                        CssClass="ms-long ms-spellcheck-true" /> 

Have a look at other post about  people picker of Sharepoint 2010
People Picker -Sharepoint 2010 

Thursday, May 30, 2013

Error in content type deployment while visual studio deployment .Content type Id already exists for this feature ID

I encountered a starnge error.I just created a content type through Visual studio 2012 using some site columns deployed it ,it worked fine.But now I made some changes and try to redeploy it.It poped up with a errror stating "Content type with the ID ______ in the feature ID ________ already exists"


I tried retract and deploy again and again it dint work

The trick was .

1) Retract the solution
2)Close the Visual studio
3)Restart and redploy
4)It will work fine .