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

Thursday, 24 July 2014

Visual Studio Deployment Configuration

It happens to be the case when you want to make some changes to a feature and redeploy it using VS but sometimes it doesn't work the way it should or worked first time around. I tried to deploy a WSP solution containing 3 list definitions & instances, but VS 2012 kept trying to activate features when I don't need it, well at least at the time of solution deployment.

Packaging Explorer Deployment Configuration

Visual Studio 2012 lets you use Packaging Explorer to configure WSP solution deployment. So to change them within the properties tab I set "Activate on Default" to False, but VS 2012 just ignored it and still tried to activate the feature and threw an error - which is another story,


Did some research and figured out these properties within Packing Explorer are set to be used when we deploy the solution by command line or using Power Shell only e.g. VS ignores them. Ummm so does this means we can't change solution deployment configuration when deploying using VS 2012 then.... Answer is Yes, you can but at VS project level !!

Visual Studio Deployment Configuration

While deploying a WSP solution VS follows steps provided within project specific deployment configuration setup for SharePoint as shown below,



Just select the deployment steps you want VS to follow when deploying a WSP solution for a project and it should all work fine...


Saturday, 15 February 2014

Error occurred in deployment step 'Uninstall app for SharePoint': The local SharePoint server is not available.

Hmmm, was excited enough to deploy my first SharePoint hosted app but this error ruined the joys,

Error occurred in deployment step 'Uninstall app for SharePoint': The local SharePoint server is not available. Check that the server is running and connected to the SharePoint farm.

Now what ? error doesn't help much at all, so lets look at logs, the way I debug any issue regarding SharePoint is,

 - Check event logs in Event Viewer.

 - If don't find anything in Event Viewer then ULS Viewer, check this post if you don't know how to debug       using ULS Viewer.


Other than that you can also use SVC_Trace exe or fiddler for debugging web services or client side code, anyway coming back to topic, in this case I find the real error in event viewer,

SQL database login for 'TestServer01_Config' on instance 'SQLTEST01' failed. Additional error information from SQL Server is included below.
Login failed for user 'DEV\mr'.

So when we deploy a solution to SharePoint site using Visual Studio, it uses the account we are running Visual Studio as to deploy the solution, which in return makes changes to SharePoint config database, so if account doesn't have access to SP config, it will fail to deploy solution. As you would had figured out the solution, just give development account permission to SharePoint config database.

Edit

I have given my development account SP_DATA_ACCESS permissions on all relevant databases as shown in picture below,



Edit-2

Unfortunately above steps didn't solved the problem and lead to another error,
SQL Database 'WSS_Content_Dev' on SQL Server instance 'TESTSERVER01' not found. Additional error information from SQL Server is included below.
Cannot open database "WSS_Content_Dev" requested by the login. The login failed.
Login failed for user 'DEV\mr'.

Giving development user "dev\mr" in this case "SP_Data_Access" permissions on WSS_Content_Dev solved the problem :-).

This solved the problem of deploying my first app to SharePoint server.



Note:
I am giving development account permissions to SharePoint configuration database because it's a test environment, however if on production environment, your SharePoint administrator account should be deploying the solution and should have right permissions already.

Wednesday, 19 June 2013

Convert WSDL file to a C# class and then DLL


Today I was trying to update a web reference of custom web services in my project but because of some reason visual studio 2010 wasn't getting the latest methods I added even though I could see them using browser. Hence to get around problem I converted WSDL file into C# class and then into a dll.

You can target dll to any framework you would like. In order to get DLL in .Net 4.0 framework try following steps;

For getting you library dll in.Net 4.0 framework you will require Visual Studio 2010 tools installed on your machine, however for it in .Net 3.5 framework you will need Visual Studio 2008.


  1. Open Visual Studio Command prompt as a administrator by going to Start menu > All Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio Command Prompt (2010).
  2. Put your WSDL file in somewhere accessible e.g. in this case I will put it in my C drive and getting output CS class in C drive too but you can change it. Type this command and press okay,

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>wsdl /l:C# /out:C:\OutPutClassName.cs C:\myWebService.wsdl
  3. Above command will generate a CS class in your C drive, now if you want to convert this class into dll in .Net 4.0, type this command;

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>csc /target:library /r:System.Data.dll /r:System.Data.Services.Client.dll /out:C:\OutPutClassName.dll C:\OutPutClassName.cs

    Above command will get you class library dll in .Net 4.0 framework.
  4. In order to get ..Net 3.5 use this command,

    C:\Program Files\Microsoft Visual Studio 9.0\VC>csc /target:library /r:System.Data.dll  /out:C:\OutPutClassName.dll C:\OutPutClassName.cs
MSDN Reference: http://msdn.microsoft.com/en-us/library/bb332338.aspx#msdnwcfhc_topic6

Wednesday, 5 June 2013

Right way of installing assembly into GAC in Windows Server 2012


In previous version's of Windows Server we were able to simply drag and drop assemblies into GAC folder which wasn't recommended at all, however being in a development environment (Windows Server 2012) when I tried to drag and drop a DLL into GAC, I received this error,




Now if you want to install assembly to GAC following steps,

  1. Assuming you are new to Windows Server 2012, Move your mouse pointer to right bottom of your screen just next to Date & Time.
  2. Click on "Search" tile.
  3. Now enter "cmd" in search text box.
  4. Most likely you will see two apps named as "Command Prompt" and "Visual Studio Command Promp...".
  5. If you will right click on "Visual Studio Command Promp.." it will give you few options at bottom of screen as show in picture below,






  6. Click on "Run as administrator" and press "Yes" for typical dialogue appears each time you try to start       a processes as administrator as security confirmation.
  7. Now type down this command,

    cd C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
  8. Copy your assembly to folder directory,

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
  9. Once assembly is copied you can use following syntax to install assembly to GAC,

    gacutil /i mySolution.myProject.dll
    an IIS reset will be produced as a result of above command so be careful as if you might break any on going process

That's it. Your assembly is installed, you can follow the procedure as many times as you want.

For more information please check this MSDN link out: http://msdn.microsoft.com/en-us/library/ex0ss12c(v=vs.80).aspx