Sunday, February 13, 2011

The joy of BCS

I have spent many hours over the past week trying to work out why my BDC Model that I created in Visual Studio would not render in an External list.

I received the lovely:

Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.
Correlation ID:…..

message in the web part. The only problem was that SharePoint was not actually logging the error to the ULS log which posed an interesting challenge.

I tried a default “Hello world”  BDC Model, and that worked fine.

So I thought there must be something wrong with my model, but wasn’t sure what.

Then I came across this very handy tool from Phill Duffy, of Lightning Tools on codeplex.

It allowed me to test the finder and specific finder methods of my BDC model and turned up the first issue. I found out that the ID can’t be of int64 type. (Thanks to the following article)

I changed the identifier to int32 and the model worked in the bcstesterman, and I thought that was going to be it.

But, to my disappointment, the web part error persisted. I then tore out what little hair I had left. Trying to work out how I was going to find the problem, I finally decided it was time to lay out some hard earned cash to buy .Net Reflector professional. I disassembled Microsoft.SharePoint and told VS.Net to break on exceptions. After a few minutes, I identified the cause of the problem:

{"There is an error in the TypeDescriptors of Parameters on Method with Name 'ReadList' on Entity (External Content Type) with Name xxxxx in Namespace … The TypeDescriptors incompletely define where the Identifiers of Entity 'xxxxx' are to be read. That Entity expects exactly '1' Identifiers, but only '0' TypeDescriptors were found from which to read them."}

So there was one error in my BDC model where I had not selected the identifier option in the ReadList (finder) method.

So it is now working and I can move on (and get some sleep). Once again .Net Reflector professional has saved the day.

1 comment:

Anonymous said...

Hi Jeremy,

I just came across your blog post, I am very pleased that you have found BCS Tester Man useful.

All the best