Archive | September, 2012

Jpgs in Sharepoint 2010 dont show in final page for IE8 and lower

11 Sep
  1. Ok, so here is the situation, I have a site owner. They have full permissions on the site, and can see all the other images in the same library. In fact they can see other JPGs in the same library. When you go to the library they can see the images in the link, when they mouse over they see the pop up with the image. BUT when they go to a page that has the image in it they see a red X. And if they open the image directly, red X. But it is limited in our data to only one JPG. What gives?
  2. We ran the normal permissions checks, ran a fiddler trace, tried it from different users, and machines. And it appeared to be machine, not user specific. since the user could see the image on other machines. And it was not machine specific since other browsers on this persons machine could resolve the image. It wasn’t a caching issue since we cleared that out.
    Turns out it was IE8 specific. And here is what it appears to have been.
  3. IE 8 could not render the JPG since apparently the graphic artist saved it as CMYK and not RGB. And since the newer versions of IE and therefore the newer versions of SharePoint graphics routines could handle it, it was able to generate the thumbnails that the user was seeing in the administrative interfaces. So the user could see it in the library list, mouse over and see the correct image, assign it to a page, see it in other browsers, and on other machines (which had IE9) and just not on the final page in IE8 (or 6 or 7).
  4. Solution was straight forward, open it up in Microsoft Expression Design 4, and save the image as a PNG or JPG with RGB color palettes.
    Problem solved.

SharePoint 2010 Taxonomy store and Ampersand issue

10 Sep
  1. I ran into a weird issue while I was working with the SharePoint taxonomy term store to upload some managed metadata. I had modified the code to check for existing terms, and if they were not there to insert them. turns out there were no errors when I had tested it, but when I ran it against the production file I would get errors, that I was trying to insert a duplicate key.
    I did some tracing, and for some reason Ampersands in the term name were causing failures. further investigation showed that even though the term was in the comparison list, the compare criteria was failing.
    After a little more time, and some unsuccessful approaches, I notices that the ampersand in the watch window looked a little different from the comparison string vs the input string.
  2. && << look similar don’t they?
    SharePoint doesn’t think so
  3. So I thought it was a different font, or bolded, or something. I tried pasting into excel and getting the unicode for the mystery character, and it did indeed come back as not an ampersand.. but what was it.. A little more searching and I cam e across this:
  4. that was the smoking gun. The system was transforming the input text as I was putting it in. so when I pulled it back out to compare to the new list, it was just subtly different enough to fail the comparison, and then once I tried to insert the text, it would transform it on the way in and throw an ugly error about key violations.
    Solution in my case was straight forward, I did not need to transform the text back into it original form. I just needed to know if what I was looking at was already in there. So I Used the TaxonomyItem.NormalizeName method to pre transform my input text and then compared that to what was already in the terms collection.
    worked out much better.

Creating a Copy of a Custom Sitemap in SharePoint 2010

10 Sep
  1. I wanted it cached and I was planning to use the HTTPruntime to handle the caching in my code. The issue I ran into was that since the root object was a complex reference type with deep nested elements, the changes and trimmings I made to the data ended up propagating all the way back into the HTTP Run time cached object. I came across this link which seemed to cover the issue.
  2. However that method required that and iclonable interface be implemented. So that did not work since the object was just a bare data class/structure.
  3. This method looked promising, but also did not work. So I accepted that I was going to have to create my own copy logic and attach it to the base object as a method. So I did some searching and found this very helpful article.
  4. the only change I needed to make was swapping out one argument type here.
  5. the original article called for a fieldinfo array to be grabbed from the type, but the way I had it set up, I needed to grab the propertyInfo array from getproperties. And since this was a List<string> type in my example, I then had to iterate over it to copy the object.

    Once I made these changes, I was able to new up a copy of the original object, avoid all the calls back to the taxonomy store, and make whatever trims and modifications I wanted without corrupting the base object.
    pretty handy, and not to hard to pull off.