BCS Error "The server was unable to process the request due to an internal error."

Posted by | Filed under

When trying to access the Business Data Services Application Proxy, I got the error "The server was unable to process the request...". I also noticed that the Secure Store service was giving a WCF-related error.

 At any rate, what I did to fix my particular error is start the "Claims to Window Token Service" which stopped for some reason. BCS started working again after doing so.

 This post is what pointed me in the right direction and gives more information:
http://www.intheknow.it/Default.aspx?Page=ssserror&NS=&AspxAutoDetectCookieSupport=1

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Making DelayActivity Work In SharePoint 2010

Posted by | Filed under , , , ,

In the previous MOSS 2007 version of SharePoint, there was an issue of delay activities in workflows not waking up because of how the SharePoint workflow runtime works.

 Sadly, Microsoft didn't reslove the issue by default with SharePoint 2010. You still have to jump through some hoops to get it running (usually after scratching your head as to why it doesn't work and scouring the internet for solutions).

 It turns out that the way to get things running is to dust off stsadm.exe and run the following commands:

stsadm -o setproperty -pn job-workflow -pv "Every 5 minutes between 0 and 59" -url http://webappurl
stsadm -o setproperty -pn workflow-eventdelivery-throttle -pv "45"

Thanks to StackOverflow for pointing me in the right direction.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Rename the "Title" Field in a SharePoint List Definition

Posted by | Filed under , , , ,

Sometimes you'll want to override the name of the default (required) "Title" field on a SharePoint list definition. At first, it's a bit confusing how to do so, because to make your "Title" rename comprehensive, you have to change not only the "Title" field's display name, but also "LinkTitle" and "LinkTitleNoMenu".

Luckily, doing so isn't difficult. Either find the fields below in your list definition, or add them in the <Fields/> element. From there, simply change the "DisplayName" attribute (not the "Name" or "StaticName", which should remain unchanged).

<Field DisplayName="Custom Title" ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="Title" Required="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" FromBaseType="TRUE" />
<
Field DisplayName="Custom Title" ID="{bc91a437-52e7-49e1-8c4e-4698904b2b6d}" ReadOnly="TRUE" Type="Computed" Name="LinkTitleNoMenu" DisplayNameSrcField="Title" AuthoringInfo="(linked to item)" EnableLookup="TRUE" ListItemMenuAllowed="Prohibited" LinkToItemAllowed="Prohibited" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitleNoMenu" FromBaseType="TRUE">
   <
FieldRefs>
      <
FieldRef Name="Title" />
      <
FieldRef Name="LinkFilenameNoMenu" />
   </
FieldRefs>
   <
DisplayPattern>
         <IfEqual>
            <Expr1>
                <LookupColumn Name="FSObjType"/>
       </
Expr1>
            <Expr2>1</Expr2>
                 <Then>
            <
Field Name="LinkFilenameNoMenu"/>
                </Then>
         <
Else>
            <
HTML><![CDATA[<a onfocus="OnLink(this)" href="]]></HTML>
            <
URL/>
            <HTML><![CDATA[" onclick="EditLink2(this,]]></HTML>
            <
Counter Type="View" />
            <
HTML><![CDATA[);return false;" target="_self">]]></HTML>
            <
Column HTMLEncode="TRUE" Name="Title" Default="(no title)" />
            <
IfEqual>
               <Expr1>
                 <
GetVar Name="ShowAccessibleIcon" />
               </
Expr1>
               <
Expr2>1</Expr2>
               <Then>
                  <HTML><![CDATA[<img src="/_layouts/images/blank.gif" class="ms-hidden" border="0" width="1" height="1" alt="Use SHIFT+ENTER to open the menu (new window)."/>]]></HTML>
               </Then>
            </
IfEqual>
            <HTML><![CDATA[</a>]]></HTML>
            <
IfNew>
               <HTML><![CDATA[<img src="/_layouts/1033/images/new.gif" alt="]]></HTML>
               <
HTML>New</HTML>
               <
HTML><![CDATA[" class="ms-newgif" />]]></HTML>
            </
IfNew>
         </
Else>
      </IfEqual>
   </DisplayPattern>
</Field>
<Field DisplayName="Custom Title" ID="{82642ec8-ef9b-478f-acf9-31f7d45fbc31}" ReadOnly="TRUE" Type="Computed" Name="LinkTitle" DisplayNameSrcField="Title" ClassInfo="Menu" AuthoringInfo="(linked to item with edit menu)" ListItemMenuAllowed="Required" LinkToItemAllowed="Prohibited" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitle" FromBaseType="TRUE">
   <FieldRefs>
      <FieldRef Name="Title" />
      <
FieldRef Name="LinkTitleNoMenu" />
      <
FieldRef Name="_EditMenuTableStart2" />
      <
FieldRef Name="_EditMenuTableEnd" />
   </
FieldRefs>
   <DisplayPattern>
   <FieldSwitch>
      <Expr>
         <GetVar Name="FreeForm" />
      </Expr>
      <Case Value="TRUE">
         <Field Name="LinkTitleNoMenu" />
      </Case>
      <Default>
        <Switch>
          <Expr>
             <GetVar Name="MasterVersion" />
          </
Expr>
          <Case Value="4">
             <
HTML><![CDATA[<div class="ms-vb itx" onmouseover="OnItem(this)" CTXName="ctx]]></HTML>
             <
Field Name="_EditMenuTableStart2" />
             <
HTML><![CDATA[">]]></HTML>
             <Field Name="LinkTitleNoMenu" />
             <HTML><![CDATA[</div>]]></HTML>
             <
HTML><![CDATA[<div class="s4-ctx" onmouseover="OnChildItem(this.parentNode); return false;">]]></HTML>
             <HTML><![CDATA[<span>&nbsp;</span>]]></HTML>
             <HTML><![CDATA[<a onfocus="OnChildItem(this.parentNode.parentNode); return false;" onclick="PopMenuFromChevron(event); return false;" href="javascript:;" title="Open Menu"></a>]]></HTML>
             <
HTML><![CDATA[<span>&nbsp;</span>]]></HTML>
             <HTML><![CDATA[</div>]]></HTML>
          </Case>
          <Default>
             <
HTML><![CDATA[<table height="100%" cellspacing="0" class="ms-unselectedtitle itx" onmouseover="OnItem(this)" CTXName="ctx]]></HTML>
             <Field Name="_EditMenuTableStart2" />
             <HTML><![CDATA["><tr><td width="100%" class="ms-vb">]]></HTML>
             <
SetVar Name="ShowAccessibleIcon" Value="1" />
             <Field Name="LinkTitleNoMenu" />
             <
SetVar Name="ShowAccessibleIcon" Value="0" />
             <HTML><![CDATA[</td><td><img src="/_layouts/images/blank.gif" width="13" style="visibility:hidden" alt=""/></td></tr></table>]]></HTML>
          </Default>
       </Switch>
      </Default>
    </FieldSwitch>
   </DisplayPattern>
</Field>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Serialize or Deserialize Any .NET Object To and From an XML String

Posted by | Filed under , , , , , , ,

A new and handy feature of C# 3.0 is "extension methods". Extension methods essentially allow you to write methods for classes that you may or may not have written yourself.

Additionally, a great feature of .NET 2.0 is "generics", which allow you to create templates of methods (and classes) for multiple types at once.

Combine extension methods and generics, and you can really cook up some trouble! In terms of XML serialization, you can code a few simple lines to handle all your XML string serialization needs.

Observe:

public static class Extensions
{
   public static string ToXml<T>(this T toSerialize)
   {
 
     var serializer = new XmlSerializer(typeof(T));
      var sb = new StringBuilder();
      using (var writer = new StringWriter(sb))
         serializer.Serialize(writer, toSerialize);
      return sb.ToString();
   }


   public static T DeserializeXmlString<T>(this string xml)
   {
     
var serializer = new XmlSerializer(typeof(T));
      using (var reader = new StringReader(xml))
         return (T)serializer.Deserialize(reader);
   }
}

Observe. After creating the class above and referencing its namespace in your code, the extension method becomes available for use so that you can perform serialization/deserialization trickery like so:

public class MyClass
{

   public
int IntProperty { get; set; }
   public string StringProperty { get; set; }
}

var mc = new MyClass(){ IntProperty = 1, StringProperty = "Test" };
var xml = mc.ToXml();
//output:
//<MyClass>
// <IntProperty>1</IntProperty>
// <StringProperty>Test</StringProperty>
//</MyClass>
var deserializedMc = xml.DeserializeXmlString<MyClass>();

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Getting the Strong Name of an Assembly (Now That Reflector 6.8 Doesn't Seem To)

Posted by | Filed under , , , ,

Red Gate software recently updated their Reflector product to the last free version (6.8). Unfortunately, they also seemed to take away the feature I used the most, namely the ability to get the strong name of an assembly (which is often needed for SharePoint development).

 Luckily, the tool's capability is easy to replace. I simply created a Windows Forms app with a Button, an OpenFileDialog and a TextBox for displaying the strong name. The code to extract the full name of the assembly is as follows, which I added here in the Button.Click event handler. Naturally, button1 is the Button, openFileDialog1 is the OpenFileDialog and textBox1 is the TextBox. You can rename or change the controls however you wish.

private void button1_Click(object sender, EventArgs e)
{

    // Show the open file dialog and get user input.
    DialogResult result = openFileDialog1.ShowDialog();
    if (result == DialogResult.OK)
    {
        // Assuming you pick a .dll, this code will load it and then display
        //the strong name in the TextBox control of the form.

         var
assembly = Assembly.LoadFile(openFileDialog1.FileName);
         textBox1.Text = assembly.FullName;
    }
}

 UPDATE: RedGate fixed the problem and the strong name section is there again if you download the latest version.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Three Car Seats in a Prius (or Other Mid-Sized Car). Easily!

Posted by | Filed under , , ,

I love my three kids! As a parent of three, however, I'm faced with new dilemmas like the question of how to transport them comfortably and safely. I could drop up to $40,000 on a new minivan, $5,000 for a used one, but frankly I'd like to save my money and the MPGs by making due with my 2007 Prius. After all, having kids is expensive already, and most family sedans say they hold up to five passengers, right?

Well, if you're like me, you came across a lot of confusing information elsewhere on the internet. There aren't a lot of definitive answers, and those who managed to fit three car seats in the back of their car make their solutions sound a bit sketchy (e.g. awkwardly "puzzle fitting" different car seat combinations or eschewing the latch anchors altogether in favor of seat belts because the fit is too tight).

 Well, my fellow fertile parent, I have some good news! It's actually quite easy to fit three car seats in the back seat of your car, and I have a how-to guide!

 The first thing you need to know is you may have to buy some new car seats. That may come as a bummer for some, but at least it beats dropping $1000s on a different vehicle, right?

 Anyway, the key to making things work is getting a couple Sunshine Kids Radian Car Seats. There are three models to choose from, all of which are specifically designed to fit three across in most vehicles' back seats. The Radian65 holds kids up to 65 lbs., the Radian80 holds kids up to 80 lbs. while being just as narrow as the 65, and the Radian XT, which is basically a Radian 80 with memory foam cushioning and head support.

 All will work for a three-car seat setup, and conveniently lack bulky armrests, but I personally recommend the Radian XT both because you can use it longer than the Radian65 (up to 80 lbs. vs. 65) and it gives your kids a headrest that provides better side-impact protection and head support for when they fall asleep.

 Next, while Sunshine Kids, the Radian's manufacturer, claims that you can use the Radian car seats as rear-facing car seats for babies, I recommend using a car seat specifically designed as a rear-facing car seat. The Radians are especially awkward as rear-facers as they keep their shape, but simply have a plastic shim that tilts them. Beyond looking a little sketchy, this configuration also takes up so much space that you may not be able to slide the front seats far enough forward to accommodate the size.

 Naturally, you'll want the narrowest rear-facing car seat possible also, and for that I recommend the Chicco KeyFit travel system seat, which beyond having higher-quality latch mechanisms, release systems and sunshades than competing Graco travel system seats, is also about 2 inches narrower. 

When put together, it looks a little something like this:

As you can see, the kids are comfortable, with plenty of space. What you can't see is that I'm using the latch system for the two outer seats no problem.

 Note that I put the rear-facing Chicco in the middle and secured it with a seat belt since, like many cars, the Prius lacks LATCH anchors for the middle seat, and sharing anchors with the outer seats isn't recommended. A rear-facing Chicco in the middle lets both front seats slide all the way back, and the travel system seat, though slightly tight, releases and locks without much fuss (you just need to make extra sure you click both sides into place and double check it by wiggling it around).

 Voila! What could have been a $40,000 investment in a low MPG mini van purchase turned into just a few hundred dollars worth of car seats that fit into my car!

 Now if I could just get the big girls to stop reaching into the middle car seat and stealing the baby's binkie!

Currently rated 3.6 by 38 people

  • Currently 3.631578/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Solved! - The service 'System.Workflow.ComponentModel. Compiler.ITypeProvider' must be installed for this operation to succeed.

Posted by | Filed under , , ,

I'm working on a SharePoint project where several componenets (Workflow, List Definitions, Content Types, etc.) are tightly related to the same functionality. To reduce the risk of components breaking because of an out-of-sequence or missing dependency, and just to make things easier, I wanted to throw everything together in the same project. I discovered something interesting about Workflows in the process, however.

Namely, if you try to add a Workflow to a typical project, you'll get an error in the Workflow designer saying:

     "The service 'System.Workflow.ComponentModel.Compiler.ITypeProvider' must be installed for this operation to succeed."

This happens if you added references to the proper assemblies (System.Workflow.Activities, System.Workflow.ComponentModel, System.Workflow.Runtime and microsoft.sharepoint.WorkflowActions)!

Odd, but luckily there are solutions. One is to write a bunch of code to build the support that the Workflow Designer needs, but I was looking for something even simpler. What I discovered, is that you can add support for Workflows to your project (the .csproj or .vbproj file) by cracking it open in notepad and adding some "ProductTypeGuids" to the project XML. Just add both of the GUIDs featured in the ProjectTypeGuids element below (or add the element if it's not there), and you should be good to go!

<PropertyGroup>
    ...
    <AssemblyName>MyCompany.Technnology</AssemblyName>
    <ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    ...
  </PropertyGroup>

 I'm curious to see if you can add these GUIDs to many types of projects to enable Workflow support (and further curious about if there are any consequences apart from designer support),

Currently rated 5.0 by 4 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

The Very Basics of a Custom ConfigurationSection

Posted by | Filed under , , ,

In my view, the custom configuration API in .NET is one of the most underappreciated tools at a .NET developer's disposal.

 The .NET Framework team made it dirt simple to create configuration extensions that harness the capabilities you're used to. With one simple class, you have all you need to add entries to web.config/app.config and machine.config files, you have rich API's supporting features like XML encryption, and you do it all without any XML parsing logic or file IO!

 At the core, a custom configuration section consists of three pieces:

  1. A class that inherits from System.Configuration.ConfigurationSection (be sure you add a reference to System.Configuration).
  2. A registration of your custom configuration section in configSections element your .NET configuration file.
  3. The XML configuration itself, which you add later in the file.

We'll examine each f these parts seperately, and briefly cover what you need to know about each.

 First, the ConfigurationSection class! In my case, I created an overly simplified section that includes the email address of someone you want to send notifications to.

 In it, you'll want to pay attention to four things. First, data access is handled by ConfigurationManager though of note is that WebConfigurationManager, a web-centric class with extra capabilities, may also be used for web apps. The second thing to note is the path we use to access our configuraiton section, "cSharpConsultant/notifications" in our case. This corresponds to our configuration XML and the configSections entry we make for it.

 Third, notice how we implemented our property via a ConfigurationPropertyAttribute. The "emailAddress" value we use in the attribute works in conjuction with the property getter and setter to access the internally parsed and managed configuraiton value. You'll see later on that "emailAddress" directly relates to an XML attribute in our custom configuration.

 Lastly, see how we can apply validation rules to our property via a RegexStringValidatorAttribute. RegexStringValidator is just one of the many available rules we can apply to our configuration property. The biggest gotcha to note, however, is that the validation rules will run on the default value of a property before they validate the actual value in the configuration file. This means that without a "DefaultValue" set in ConfigurationProperty, our RegexStringValidator would actually run against a blank default value and throw an exception saying "The value does not conform to the validation regex string"!

public class NotificationsConfigurationSection : ConfigurationSection
{
  private const string configPath = "cSharpConsultant/notifications"
  public static NotificationsConfigurationSection GetSection()
  { 
    return (NotificationsConfigurationSection) 
      ConfigurationManager.GetSection(configPath);
  }

  /*This regular expression only accepts a valid email address. */ 
  [RegexStringValidator(@"[\w._%+-]+@[\w.-]+\.\w{2,4}")] 
  /*Here, we register our configuration property with an attribute. 
  Note that the default value is required if we use 
  the property validation attributes, which will unfortunately 
  attempt to validate the initial blank value if a default isn't found*/
  [ConfigurationProperty("emailAddress", DefaultValue=Address@Domain.com)]
  public string EmailAddress
  { 
    get{ return (string)this["emailAddress"]; }
    set{ this["emailAddress"] = value; }
  }
}

 The second part of our setup is to register our configuration class in the file where we want to use the configuration. At the top of all .NET configuration files is a "configSections" element, where we'll register the schema and type of custom ConfigurationSection. Notice how our setup relates to "cSharpConsultant/notifications", the path we used to access our section in the above code.

<configSections> 
  <sectionGroup name="cSharpConsultant">
    <section name="notifications"
        type="ConfigurationSample.NotificationsConfigurationSection,
        ConfigurationSample, Version=1.0.0.0, 
        Culture=neutral, PublicKeyToken=null"/>
</sectionGroup>

Finally, to complete our setup, we need the actual configuration! Notice how the attribute "emailAddress" relates to the ConfigurationProperty value we registered in our custom configuration section's "EmailAddress" property.

<cSharpConsultant>
    <notifications emailAddress="NotifiedPerson@Domain.com"/>
</cSharpConsultant>

 That's it! Now to access our custom configuration, it's as simple as this!

NotificationsConfigurationSection section 
  = NotificationsConfigurationSection.GetSection();
string emailAddress = section.EmailAddress;

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Creating an SPWeb From Its Absolute URI

Posted by | Filed under ,

A collegue of mine recently asked a fairly common question for SharePoint developers getting familiar with the SharePoint API; "If I have the absolute URI of my web, how do I use it to instantiate a corresponding SPWeb object?"

You'd assume that the SPWeb would have a constructor that accepts an absolute URI, but that isn't the case. What you have to do is first create an SPSite using your URI, then call the parameterless OpenWeb() method on it.

string uri = "http://server/site/subsite/web";

//remember your "using" statements so the SPSite and SPWeb are properly disposed
using(SPSite site = new SPSite(uri))
//here, OpenWeb() opens the web corresponding to the URI passed to the SPSite constructor
using (SPWeb web = site.OpenWeb())
{
    //use your web here
}

Currently rated 4.7 by 3 people

  • Currently 4.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Worked for Me! iPhone 3G Car Bluetooth Echo and Break Up Solution

Posted by | Filed under , ,

I love my iPhone 3G, but the one major (and I do mean major) issue for me was that there was that when it connected to my 2007 Prius' OEM Bluetooth system, there was an annoying echo and complaints of my voice frequently breaking up (though callers sounded fine to me).

Luckily, the solution was pretty simple in my case:

  1. Initiate a call via your Bluetooth system.
  2. Press the "Volume Up" button on the iPhone 3G until its "Bluetooth Volume" is cranked all the way up.

Voila, virtually no echo and the calls didn't break up any more! The difference was instant and noticeable.

If you have a Toyota, Lexus, BMW, Nissan, Infiniti, Volvo and other make of car and have the same issue, I recommend trying the solution. I used it to fix my echo/break up problem twice (once originally and once after a firmware update reset my Bluetooth volume).

Unfortunately, I discovered that it isn't working for everyone as you can see in the comments below.

 UPDATE: Of note, is that I adjusted my Prius' Bluetooth microphone sensativity before taking the above steps, and John says in his comments below that it helps doing so.

Here's a link that explains how it's done for the Prius: http://priuschat.com/forums/audio-electronics/33443-low-bluetooth-microphone-volume.html. Note that certain settings in diagnostic mode can ruin your car if you're not careful, so just stick to adjusting the Bluetooth mic.

 

Currently rated 2.8 by 6 people

  • Currently 2.833333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5