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

Tuesday, February 16, 2010

Indirect dependency on the framework assembly System.Web.DataVisualization

Scenario:
You are getting the following one or more such ERROR while compiling the solution

The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?

The type or namespace name 'Publishing' does not exist in the namespace 'Microsoft.SharePoint' (are you missing an assembly reference?)

The type or namespace name 'ServerContext' does not exist in the namespace 'Microsoft.Office.Server' (are you missing an assembly reference?)


You are getting the following WARNING while compiling the solution

The primary reference "Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v3.5". To resolve this problem, either remove the reference "Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".

Solution:
Actually as you have not added the binary reference for "System.Web.DataVisualization", visual studio is trying to pick the latest version from GAC. When it is not found you are getting this warning

So let's help visual studio finding this binary and that will take away this warning.

1. Right click the project and Add a reference
2. Navigate to "c:\Program Files (x86)\Microsoft Chart Controls\Assemblies\System.Web.DataVisualization.dll"

That's it

Wednesday, February 3, 2010

Code conversion from SharePoint 2007 to SharePoint 2010

Scenario:
SharePoint 2010 is extended platform and supports most of the framework of MOSS 2007. So converting the code from 2007 to 2010 is really not a big deal.

But still few important things to note/tips are listed here Preparing environment

Important things to note:
-- Ensure that you have Administrators rights on the machine , you want to use for Development.
-- Use standalone machine for Development , this will save you lot of time dealing with networking issues and also time for deploying/retracting solution cycles.
-- Run all the Windows update on the machine to make sure you have the latest build and hot fixes.

Solution setup Steps:
1. Launch the Visual Studio 2010

2. File > New Project > SharePoint > Empty SharePoint project > Specify a Name of the project Make sure you have Framework 3.5 selected from the drop down In case you get prompted for missing Administrator rights and need Restarting the Visual Studio as Administrator, please go ahead and do that.

3. File > New Project > SharePoint > Empty SharePoint project > Specify a Name of the project Make sure you have Framework 3.5 selected from the drop down You might be prompted that same Folder name already exist ( from your previous attempt ), so delete the existing folder or specify a new name.

4. You will be presented with SharePoint Customization Wizard as shown below. Specify the Url to the site collection you want to use for Debugging , make sure to Validate. Select Deploy as a farm solution.

a

This will get you a new SharePoint based project with Zero Features with No SharePoint items ( also known as SPI's ).

1. Click on the project Add > New Item > SharePoint

2. Select WebPart > Specify a name of the Web part

3. You will see new folder added with the name specified above for the Web part

4. Also you will see new folder name "Feature1" added under Features folder

5. Click on Feature1 > Check the properties window > Change the Folder name same as name of WebPart used in step2. This is update the files and folder name automatically.

6. Right click the project name > Deploy to test if deployment is smooth.

7. Once deployment succeed.

8. Navigate to the site collection you are using for debugging.

9. Edit the page and click on Add web part 10. Locate your custom webpart under Custom category > Select the Webpart > Add Webpart to the page to test.

Enhancement Steps:
Once full deployment cycle is tested , Navigate back to Visual Studio project.
At this stage we have the working 2010 solution project created and will start moving more functional components in the project.

1. Open the .cs file and start adding more functionality to the webpart to the methods like CreateChildControl , RenderContent etc.

2. Also Add other helper files ( resources / webcontrol files etc ) from 2007 project. At this point if you are using Layout based items , create a Mapping folder for Layouts/Images ( Right click project > Add > SharePoint mapping folder for Layouts/Images ).

3. Ensure you have the consistent Namespaces to avoid any build errors.

4. Do a code walkthrough to make sure you have write file path location for various dependent assets like css/js/image files.

4. Build often and if build is smooth , Deploy often to make sure , code builds fine and changes are as expected.

Sunday, May 31, 2009

Quickly getting the public token key

Scenario:
In Sharepoint every assembly we deploy , need to strongly names. Deploying the assembly to GAC and getting the public token key from them can be length process.

Solution:


Visual Studio External Tools is here for rescue.

1. Open Visual Studio
2. Go to Tools > External Tools > Add a new tool with below settings

Setting 1:

Title : GetPublicTokenKey

Command : C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\sn.exe

Arguments : -T $(TargetPath)

Use Output Window : Checked
OR
Setting 2 ( Need Reflector):
Title : GetPublicTokenKey

Command : C:\Reflector\reflector.exe <-- Change accordingly

Arguments : "$(BinDir)$(TargetName)$(TargetExt)" -debug

Use Output Window : Checked


Now anytime you need to read the public token key , no need to deploy the assembly to GAC .

Just go to Tools >> GetPublicTokenKey and you will get the public token key value in your output window.

Saturday, April 4, 2009

Visual Studio name too long error

Scenario:
When you create your solution/project inside Visual Studio it gives you error that name is too long and it cannot create that solution/project. So some of you might be thinking that looks like VS has some limitation on characters for a project/solution.

Solution:
Well that’s not the case. Problem is that if you create solution deep inside the path (default path of VS is document & settings -> visual studio projects etc.) then this error arises and if you change the path to some small path like c:\working or c:\VSProjects and keep your solution name as its, it will work.