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

Sunday, November 2, 2014

the name SPSecurity does not exist in the current context

In SharePoint when using SPSecurity you might come across this error "the name SPSecurity does not exist in the current context"


Probably you are using a sandbox solution. You cannot use SPSecurity in sandbox solutions. Instead, go with a Farm solution in order to run this code.







Saturday, February 15, 2014

This version of Visual Studio does not have the following project types installed or does not support them

You might come across instances where you get the below message when opening SharePoint solutions in Visual Studio 2012.

"This version of Visual Studio does not have the following project types installed or does not support them"



1) The immediate remedy that pops into mind is to update the Visual Studio 2012 version.

The latest update for Visual Studio 2012, as of now is Update 4 (Released: November 13, 2013). Could get it from the link:  Visual Studio 2012 Update


2) Once that's done, you might get the following message on project load.

"An error occurred while trying to load some required components. Please ensure that prerequisite components are installed"
  • Microsoft Web Developer Tools
  • Microsoft Exchange Web Services

Possibilities are that either
  You don't have the "Microsoft Office Developer Tools for Visual Studio 2012" OR
  The installed tool is not complete.

Solution:
  • If the tool is already installed, uninstall through Control panel,
  • Download  Web Platform Installer   
  • Use the Web Platform Installer to install the tool.



Monday, March 11, 2013

Creating a Simple WCF in Visual Studio 2012

In this post I would like to explain on how to create a simple WCF using Visual Studio 2012 and deploy to the IIS server.

Step 01
Create a WCF Project. ( File > New > Project > WCF >WCF Service Application ). Select WCF Service Application and give a name.



                                                               
                                                                                                                                                   
Step 02
The Solution will include a WCF Service created by default. Let's delete this and create a new from scratch. You need to delete the files Service1.svc and IService1.cs.

Step 03
Create a new WCF service. Right click on the project, select "Add", then select New Item. In the Add New Item Window select "WCF Service" and provide a name for the service.


                                                                                                                                                                                                                                                                           
Step 04
Define the operation contract in the interface as the below example:
















                                                                                                                                                    
Step 05
Add the method and the logic in the service class and build the solution. (in SimpleService.svc.cs)
























                                                                    
Please note that I have used simple exception handling instead of the fault contract for simplicity.

Step 06 - Creating a site
Open the IIS Manager (In start menu select "Run" and type "inetmgr")
                                                     
Create an application pool















                                                                                                             
Create a site. You can specify the application pool to use.  

























                                                                                                                 
                                                                                   
Step 07 - Deploy Solution

In the solution explorer, right click on the project and select "Publish".



















                                                                                                                    

Click on the "Preview" button to check on the publishing actions to the files:




















                                                                                                         
Once the solution is published, you can check the service availability












  
                                                                                                        
Now the Service is ready for use.

Testing the Service

You can test the service functionality using the Visual Studio 2012 Developer command prompt. In the command prompt, type "wcftestclient".


                                                                                                                                                                                                   
In the WCF test client, right click on the "My Service Projects" and select "Add Service"
















                                                                                                                                                            
Insert the path for the service URL and select "OK".









                                                                                                             
The client opens up the service methods, double click on GetAverage(). Insert the values to the parameters and click "Invoke". You will get the resulting value.