Code Project

Link Unit

Friday, September 04, 2009

This solution contains two assemblies with the same name, or the SharePoint server already has an assembly with the specified name.

While trying to redeploy the same WebPart ,I was facing this rather silly error. I tried to do the “cleanup” by right clicking the Project and then redeployed same error appeared. Later figured it out by throwing a search in Google



#1 See if the feature that you're trying to add still exists in the "\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES" path. Delete it.


#2 Uninstall the particular Assembly from c:\windows\assembly folder too.


#3 Try to deploy it again.

Design decision to use ascx control in sharepoint webpart versus pure sharepoint webpart


1. Create asp.net webusercontrol (.ascx), and then load that user control in the newly created webpart.

2. Create a webpart from scratch, by putting the code to generate each and every control in code.

if you need to create a control with a really advanced user interface, for example many controls and stuff, then a user control could be much easier to create.

I have found that the execution lifecycle (control viewstate, event bubbling, etc.) is a pain when going with Option 2. I choose Option 1 because the viewstate is easily managed in the code. Additionally, I like Option 1 because I can visually design the page using the VS toolbox to drag and drop controls on the design surface as opposed to Option 2 where you have to handle each control manually in code.

The approach 2 may sound difficult because of not very great integration with Galleries , but if you have the luxury of invest the time, you'll be better off in the long run.

The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?)

This is a common but simple problem to solve , below is explanation and steps to solve.

using Directives at the top of code files just allows you to use types in a namespace without having to fully qualify them.
e.g. using System.Data directive allows you to declare a DataColumn as following:

DataColumn dc = new DataColumn();

instead of:

System.Data.DataColumn dc = new System.Data.DataColumn();

using statements define scope, but you still need a reference to the Library so that the project will build.

Do you see System.Data listed under it?
Open your solution explorer and Expand References:
More than likely not, hence the complaint from the Compiler.

What to do/ how to Solve??

Right click on References, and from the Context Menu, select "Add Reference"
The Add Reference view will default to the .NET tab, scroll down until you find the System.Data, select it and click the OK button.

Build your app.

Hope it Helps

Wednesday, September 02, 2009

The feature name WebPart1 already exists in SharePoint. You need to rename the feature before solution deployment can succeed

While working in Visual Studio 2008 , we were able to create new WebParts and deploy them easily . Off late we started facing the following problem.

“The feature name WebPart1 already exists in SharePoint. You need to rename the feature before solution deployment can succeed.”

The error may seem stupid , the solution to it is simple.

A simple method to avoid the above error is as follows
  1. Immediately after creating a new webpart project, remove the Webpart1 folder completely.

  2. Add new web part to the project by right clicking on the project and selecting new item from the context menu.

  3. In the Add new item dialog box select Sharepoint from categories and Select Web Part from templates.

  4. Give a name for your webpart and click Add button.

Friday, August 28, 2009

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 8000401a

If you add a reference to Microsoft Excel and then try to use it within your ASP.NET application you may receive the following errors.

Server Error in '/excel' Application. 

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 8000401a.

We referred this link for the DCOMCNFG settings required on Windows 2003 server http://blog.crowe.co.nz/archive/2006/03/02/589.aspx   . Even after the settings the problem was  not resolved and following error started to appear

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.

Make some changes also in ASP.Net Site’s web.config file.

Given below is the settings for web.config file.

<identity impersonate="true" userName="DomainName\administrator" password="password"/>

            <authentication mode="Windows">           </authentication>

 

Tuesday, August 25, 2009

Four Little Known, Helpful Methods, Properties, and Features for ASP.NET Developers

The .NET Framework is big. Really big. The System.Web assembly, which contains the guts of ASP.NET, is comprised of nearly 2,000 types, over 23,000 methods, and more than 12,500 properties. And that's not counting any of the functionality added to ASP.NET since version 2.0. ASP.NET AJAX, the ListView control, Dynamic Data, URL routing, and other features add hundreds of new types and thousands of new methods and properties.

Given the size and scope of the .NET Framework and ASP.NET even there are certain to be dark corners for even the most experienced developers. There are certain classes, methods, and properties in the .NET Framework that every ASP.NET developer is intimately familiar with: the Request.QueryString collection; the Session object; Pageobject properties like IsValid and IsPostBack. Yet even in these familiar classes there are very useful and very helpful properties, methods, and features that are less widely known. Heck, I've been building ASP.NET applications and writing about ASP.NET functionality and features full time since 2001, and once or twice a month I still stumble across an unknown feature or a helpful property or method buried in some dark corner of the framework.

This article lists four helpful methods, properties, and features in the .NET Framework that, in my experience, are not widely known to ASP.NET developers. Read here

Auto Refresh in Chrome

I work with all type of Browser including the new entrant Chrome. Other browsers have some plugin or addon which help to auto refresh the page. So I tried to figure out Does Chrome have an auto-reload option (per tab) ?? 
The answer was google search away.

Just create a bookmark with the following code as the URL:

javascript:
timeout=prompt("Set timeout [s]");
current=location.href;
if(timeout>0)
setTimeout('reload()',1000*timeout);
else
location.replace(current);
function reload(){
setTimeout('reload()',1000*timeout);
fr4me='';
with(document){write(fr4me);void(close())};
}


Click the bookmark with the tab you want to auto-reload active.
Set the time interval (in seconds) or set it to zero to cancel auto-reload.

Hope it Helps
Jatinder Singh