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

Mar 22, 2011

GetCustomListTemplates returns 0 values

One of my colleague encountered this issue where he was trying to create list on feature activation based on a custom list template uploaded to the list template gallery.
We tried different ways to check why the GetCustomListTemplates method of SPSite retunred empty values even if there are custom list templates uploaded to the gallery.

It is because we didn't set the Version property while uploading the templates via Feature. SharePoint 2010 expects version to be '4' for the list template.
So this did the trick for us:




<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="TestModule1" Url="_catalogs/lt" List="114">
<File Path="TestModule1\MyList1.stp" Url="MyList1.stp" Type="GhostableInLibrary" IgnoreIfAlreadyExists="FALSE" >
<Property Name="Product Version" Value="4" />
</File>
</Module>
</Elements>



Resolution: Setting the 'Product Version' property of File object in the elements xml file to value '4' allowed us to access that template via GetCustomListTemplates property of SPSite object in SharePoint 2010

Feb 20, 2011

The remote certificate is invalid according to the validation procedure

When you get this error while trying to send email using gmail's account id and your own custom code, just paste below line before you call .Send method of the smtp client like this:

ServicePointManager.ServerCertificateValidationCallback =
                    delegate(object s,
                                X509Certificate certificate,
                                X509Chain chain,
                                SslPolicyErrors sslPolicyErrors) { return true; };

// write smtp client's .send here

Once you do this,  you will see the error disappears!

How To Allow Anonymous Access on a SharePoint Application Page

If you want to allow anonymous access on a SharePoint application page, simply override this property and return true:

protected override bool AllowAnonymousAccess
        {
            get
            {               
                return true;
            }
        }

Next time onwards you will be allowed to browse the page anonymously. This will be useful in sharing anonymous information with users. The best example would be to use a custom Sign/In page or something which you want unauthenticated users to access.

Jun 17, 2010

Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 80040154

I got this error while trying to debug a console application accessing SharePoint Portal Server 2010 in Visual Studio 2010.

 Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 80040154


Resolution: It is because you are trying to build a x86 application. Go to project properties and set type to x64 everywhere. Then rebuild and debug. The Error Vanishes!