VirtualBox, Android Devices and error “This device cannot start. (Code 10)”

Ok, if you get this error you are probably trying to install your Android device to windows and it fails. When checking the device manager you might see the following error code. There are numerous posts and instructions which might help you but none did to my LG G3. What eventually helped was an insight based on several different posts.

On my virtual machine the problem was related to the USB port type used in relation to the USB port actually used in your real world machine and USB cable used.

Basically as default the VirtualBox used USB 1.1 which for some reason does not work, probably something to do with my cable being USB 2.0. To fix my problem I installed the VirtualBox extension for USB: VM VirtualBox Extension Pack.

Then I changed the USB type to be used for the Virtual Machine to 2.0, booted my windows and it worked. So if you are getting the error above no matter where you are check that you have the proper USB cable which is compatible with your Android device and the port on your machine. For a virtual machine image check that you have the right USB configuration in relation to your real world devices.

In case the above does not work then try this KB article from Microsoft:

https://support.microsoft.com/en-us/kb/943104

SharePoint Excel Services Loading Excel files from code

If you ever wondered how you might load an Excel Sheet from an Excel file dynamically from a webpart then this is your lucky day :). Well below is the code how to do it.

The code below is rather simple. You have an excel file URL within SharePoint which is used to retrieve data to build a excel web services URL from where the actualy HTML based excel data is retrieved.

There are two points to be made:
1. During the development of this functionality I noticed that without the definition for the headers excel services would not always operate as expected. This was especially true when in anonymous mode, in other words a public site.
2. If you are going to ry to use excel services through code like in this example you also need to take into consideration access. Under a Windows Authentication model you have no problems but if you use anonymous access you are going to have problems. so if you encounter problem with public sites consider creating an AD account which is going to be used as the anonymous user in IIS for your SharePoint application. Then to allow access to the target excel file location simply add the minimum privileges of “Read” to the account. Add these rights either to the library where the file is located of the file itself.

private String excelWebServicesURL = "{0}/_vti_bin/ExcelRest.aspx/{1}/model/Ranges('''{2}''!{3}|{4}')?$format=html";

String composedExcelWebServicesURL = null;
            try
            {
                if (!String.IsNullOrEmpty(this.ExcelFileLocation) && !String.IsNullOrEmpty(this.ExcelSheetName) && !String.IsNullOrEmpty(this.ExcelSheetStartCell) && !String.IsNullOrEmpty(this.ExcelSheetEndCell))
                {
                    using (SPSite site = new SPSite(this.ExcelFileLocation))
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                            SPFile excelFile = web.GetFile(this.ExcelFileLocation);
                            if (excelFile != null)
                            {
                                String hostName = null;
                                if (!string.IsNullOrEmpty(Request.Url.Query))
                                {
                                    hostName = Request.Url.AbsoluteUri.Replace(Request.Url.Query, String.Empty);
                                    hostName = hostName.Replace(Request.Url.AbsolutePath, String.Empty);
                                }
                                else
                                {
                                    hostName = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, String.Empty);
                                }
                                Uri webURI = new Uri(web.Url);
                                String presentWebReformedURL = hostName + webURI.AbsolutePath;
                                composedExcelWebServicesURL = String.Format(this.excelWebServicesURL, presentWebReformedURL, excelFile.Url, this.ExcelSheetName, this.ExcelSheetStartCell, this.ExcelSheetEndCell);

                                if (this.DebugMode == true)
                                {
                                    this.lDebugInfo.Text += composedExcelWebServicesURL != null ? composedExcelWebServicesURL : "URL data is empty";
                                }
                                using (var client = new WebClient())
                                {
                                    var newUri = new Uri(composedExcelWebServicesURL);
                                    var myProxy = new WebProxy();
                                    myProxy.Credentials = CredentialCache.DefaultCredentials;
                                    myProxy.Address = newUri;
                                    client.Proxy = myProxy;

                                    client.Encoding = System.Text.Encoding.UTF8;
                                    client.Headers.Add("User-Agent", @"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
                                    client.Headers.Add("Accept", @"text/html, application/xhtml+xml, */*");
                                    if (this.DebugMode == true)
                                    {
                                        this.lDebugInfo.Text += "</br> Before download string";
                                    }
                                    this.lExcelWebServiceHTML.Text = client.DownloadString(composedExcelWebServicesURL);
                                    if (this.DebugMode == true)
                                    {
                                        this.lDebugInfo.Text += "</br> After download string";
                                    }
                                }
                            }
                        }
                    }
                }
				}
            catch (Exception ex)
            {

            }

SharePoint – Setting users or groups for a membership webpart through code

This is a rather simple thing… well once you have cracked it :).

 

There are two properties which need to be set:

And that is it. To find the “main” associated groups to your site you could use these properties:

https://msdn.microsoft.com/EN-US/library/microsoft.sharepoint.spweb.associatedownergroup.aspx

https://msdn.microsoft.com/EN-US/library/microsoft.sharepoint.spweb.associatedmembergroup.aspx

https://msdn.microsoft.com/EN-US/library/microsoft.sharepoint.spweb.associatedvisitorgroup.aspx

https://msdn.microsoft.com/EN-US/library/microsoft.sharepoint.spweb.associatedgroups.aspx


using (SPSite site = new SPSite(wsSite.ID))
{
using (SPWeb web2 = site.OpenWeb(wsSite.RootWeb.ID))
{
var pubWeb = PublishingWeb.GetPublishingWeb(web2);

using (var wpm = pubWeb.DefaultPage.GetLimitedWebPartManager(PersonalizationScope.Shared))
{
// Search for the right webpart(you could use LINQ instead of a foreach)
int memberShipWebPartsCount = 0;
for (int x = wpm.WebParts.Count - 1; x >= 0; x--)
{
var membersWebPart = wpm.WebParts[x] as Microsoft.SharePoint.WebPartPages.MembersWebPart;
if (membersWebPart != null)
{

// There are only two members webparts which are needed to be processed, at the moment
if (memberShipWebPartsCount < 2)
{
if (memberShipWebPartsCount == 0)
membersWebPart.MembershipGroupId = wsSite.RootWeb.AssociatedOwnerGroup.ID;
else if (memberShipWebPartsCount == 1)
membersWebPart.MembershipGroupId = wsSite.RootWeb.AssociatedMemberGroup.ID;

membersWebPart.DisplayType = Microsoft.SharePoint.WebPartPages.MembersWebPartDisplayType.GroupMembership;
wpm.SaveChanges(membersWebPart);

pubWeb.DefaultPage.Update();
if (pubWeb.DefaultPage.CheckOutType != SPFile.SPCheckOutType.None)
pubWeb.DefaultPage.CheckIn("");

if (pubWeb.DefaultPage.ParentFolder.DocumentLibrary.EnableVersioning && pubWeb.DefaultPage.ParentFolder.DocumentLibrary.EnableMinorVersions)
pubWeb.DefaultPage.Publish("");
}
memberShipWebPartsCount++;
}
}

}
}
}

SharePoint 2013 Search and Search Index Problems

If you find yourself in a situation where your search does not work you have some options:

  1. Do a full crawl
  2. Reset the search index and Do a full crawl
  3. Maybe along the way restart the SharePoint search service and/or the SharePoint timer service
  4. And if none of the above then you have to get creative

In the third option usually you get errors on your search webpart or search results. These errors do not go away and nothing seem to help, like the option one and two above.

One of the last things which you can do before going crazy :) would be to manually empty the configuration cache. You do this in the following way:

  1. Find the the folder named with a GUID which has cache.ini file under the C:\ProgramData\Microsoft\SharePoint\Config
  2. Stop SharePoint Server Search 15 and SharePoint Timer Services
  3. Backup the cache.ini file
  4. Delete all files except the cache.ini file
  5. Edit the cache.ini and make sure it has only 1
  6. Save and Close the file.
  7. Start SharePoint Server Search 15 and SharePoint Timer Services
  8. Start Index Reset from SharePoint Central Administration\Application Management\Manage Service Applications\SearchServiceApplication\Index Reset
  9. You will see your  C:\ProgramData\Microsoft\SharePoint\Config\YourGUID folder will be filled up new .xml files and your cache.ini file will be modified.
  10. Next I run a full search crawl to get some search results.

NOTICE: Do not do this if you are tight on time. Depending on the amount of data in your target environment running a full crawl will take a looon long time. All depends on the server resources and the amount of data in your target environment.

There is also a script from this at codeplex:

https://spcachecleaner.codeplex.com/

Hope this helps someone. I know I have spent enough time with this problem and it is anoying.

 

SharePoint 2013 display templates for content webparts do not work

This problem may occur when you have a custom display template which you are modifying at some stage and updating it into SharePoint. If for some reason your template stops working what you need to do is go to the display template and modify its properties.

There you will find several options where you want this template to be used, such as search, content webparts etc.

So go and check your display templates properties and make sure you have selected where the template is to be used.