CslaDataSource TypeAssembyName & TypeName could not be set?

CslaDataSource TypeAssembyName & TypeName could not be set?

Old forum URL: forums.lhotka.net/forums/t/1707.aspx


cultofluna posted on Tuesday, November 07, 2006

Hello,

I'm having a strange problem with the CslaDataSource.

I have a MessageInfoList of class ReadOnlyListBase with child class MessageInfo. Both classes have basic fetch functionality and that's it.
The classes are placed in a separate Library dll.

For the webapp I use Windows authentication, I've added the namespace shortcut for Csla.Web. Furthur I have manually added the CslaDataSource and set the properties TypeAssemblyName and TypeName. However when setting the TypeAssemblyName property the Designer shows the following error:

Error Creating Control - MessageInfoListDataSource
'Project.Library' could not be set on property 'TypeAssemblyName'

What am I doing wrong?

cultofluna replied on Tuesday, November 07, 2006

They can be set programmatically I found...however I can't use the visual databinding features this way...or is this default behaviour?

cultofluna replied on Wednesday, November 08, 2006

After settings the properties and choosing the "Refresh Schema" of the CslaDataSource the properties were successfully set.

When binding the datasource to, for example, a datalist I would expect the TypeName to be that of the ReadOnlyBaseList, however this fails raising an error that the type could not be loaded.

So I tried the ReadOnlyBase class used by the ReadOnlyBaseList and that did the magic trick. I was suprised to see the datalist immediately showed the ReadOnlyBaseList items! How does the list or the datasource know to use the list, even when specifying the items class??

RockfordLhotka replied on Wednesday, November 08, 2006

cultofluna:

So I tried the ReadOnlyBase class used by the ReadOnlyBaseList and that did the magic trick. I was suprised to see the datalist immediately showed the ReadOnlyBaseList items! How does the list or the datasource know to use the list, even when specifying the items class??


All I can say is "read chapter 5" Big Smile [:D]

cultofluna replied on Friday, November 10, 2006

ok... I admit re-reading did help :D thanks!

SonOfPirate replied on Thursday, December 07, 2006

Sorry for the lateness of this post, but I just ran into the same problem and found this thread while searching for an answer.  However, I'm not finding one.  I did re-read chapters 5 and 10 and do not see anything that mentions the behavior that I am seeing and was reported earlier in this thread.

I created a web page yesterday with an Infragistics' UltraWebGrid.  I added the CslaDataSource to the page and setup the TypeAssemblyName and TypeName properties along with the OnSelectObject event handler.  Everything worked great, as promised and I was thrilled and showing off just how quickly and easily this was accomplished.  I was able to go right into the UltraWebGrid designer and setup the column order, etc. and within 5 minutes had the page up and running.  This was great!

Today I attempted to setup a second such page.  This time I quickly added the controls manually in the Source View following the same pattern as the previous page.  When I switched to the Design View so that I could use the UltraWebGrid designer, the CslaDataSource control failed, reporting that the TypeName property could not be set.

I tried deleting the control and adding it anew.  Same problem.

So, just for kicks - and comparison - I opened up the page that I had created yesterday (the one that worked great!) and it had the same error message!

To further troubleshoot the problem, I ran the app so that I could see if the pages would come up and they both came up fine.  This tells me we are dealing with strictly a design-time problem.  However, because I could not get the schema setup, the second UltraWebGrid had its default settings (column order, etc).

That brought me here.  I read this thread and discovered that I could eliminate the error by removing the TypeName and TypeAssemblyName values in Source View, switch back to the Design View, set the properties in the Properties Grid and click the Refresh Schema link as described above.  This worked, the error went away, the UltraGrid updated to reflect the schema and I was able to use the UltraWebGrid designer to setup the columns as desired.

Unfortunately, when I went back to the original page (the one I set up yesterday) and followed the same steps, the UltraWebGrid was restored to its default settings and I had to go through and re-order all the columns, etc. again.  I imagine this is by design as the grid probably doesn't know that the schema is just a refreshed version of the same - I'm sure it assumes nothing.  So, the fact that this happened isn't so much a problem other than the need to do so.

When I come in tomorrow will I have to go through all of my pages and redo all of these steps again?!?!?  In an application where I will have no less than 20 such views, this will get ridiculous fast.

So, can you tell me specifically why this error is occurring and what can be done to fix it short of following these steps for each and every instance in the application?

Thanks.

 

RockfordLhotka replied on Thursday, December 07, 2006

I don't know why this is happening, and I've been unable to replicate the issue, so debugging is challenging...

If you can reliably replicate the behavior you could help me out - though it is a bit complex.

What you need to do is

  1. Open your failing solution in VS.
  2. Then open a second instance of VS and load the CSLA .NET solution into it.
  3. Set break points in the CslaDataSource class in the TypeName property set block.
  4. Then, in that second instance, attach the debugger to the first instance of VS.
  5. Now return to the first instance of VS and make it fail. That should get you into the breakpoint in the second instance of VS and you can step through the code to find the actual exception/issue that occurs.

As you can see, without a failing project, this is impossible to debug - but if you can follow these steps it may give us a valuable clue as to why it occurs and then I can try and resolve it.

ajj3085 replied on Thursday, December 07, 2006

There's a slightly easier way, as long as you have the pdb files available for all your assemblies (including Csla).

Run the program in question.  Then goto the Debug menu, Windows, Modules.  Find yoru assemblies, and right clilck on them.  Choose the option to load symbols.  It will ask you where to find the pdb.  Locate it.  It will also ask you to locate the source code.. locate that as well.  You can then step through, all in one IDE session.

HTH
Andy

SonOfPirate replied on Thursday, December 07, 2006

Okay, now I'm stumped.

Worked on 5 different pages with 5 different grids and 5 different data sources and all of them were repeatable and consistent in their failure.  I couldn't even switch from Design view to Source view and back without them failing.

Shut everything down & came home.  Powered up just now and walked through the steps Rocky suggested and all of them are working perfectly fine!  No error messages.  Data sources and grid come up as expected!?!

So, now I'm stumped.  I'll have to wait and see if I can get it to fail then try this again.  If so, I'll post the results.

On the brighter side, was actually worth the time to walk through how the control is setup and see the objects interact.  Thanks for the insight on how to debug design-time behavior - that will come in handy in the future, I'm sure.

I'll let you know if I get it to fail again.

Confused [*-)]

 

RockfordLhotka replied on Thursday, December 07, 2006

This works to debug IDE hosted controls?
 
I don't think this will wrok - because you aren't actually running the first IDE in debug mode. The bug occurs when the IDE is still in design time, so that particular IDE's debugger isn't active.
 
Rocky


From: ajj3085 [mailto:cslanet@lhotka.net]
Sent: Thursday, December 07, 2006 3:59 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] SOLVED?? Re: CslaDataSource TypeAssembyName & TypeName could not be set?

There's a slightly easier way, as long as you have the pdb files available for all your assemblies (including Csla).

Run the program in question.  Then goto the Debug menu, Windows, Modules.  Find yoru assemblies, and right clilck on them.  Choose the option to load symbols.  It will ask you where to find the pdb.  Locate it.  It will also ask you to locate the source code.. locate that as well.  You can then step through, all in one IDE session.

HTH
Andy



ajj3085 replied on Friday, December 08, 2006

Sorry, missed that this was a design time error.

SonOfPirate replied on Tuesday, December 12, 2006

Got it to repeat!

Stepped through debugging as suggested and the code broke in the CslaDataSource class TypeName property setter on the statement:

((CslaDataSourceView)this.GetView("Default")).TypeName = value;

The error message was:

"Unable to cast object of type 'Csla.Web.CslaDataSourceView' to type 'Csla.Web.CslaDataSourceView'."

Stepping into the code, the view is returned from the GetView method and (obviously) failing on the cast.

I had to manually remove the TypeName and TypeAssemblyName attributes from the control in the web page, switch back to Design View and enter them into the Properties window to restore the control.

Any ideas?

I can tell you that this occurred after a rebuild of the complete solution - including the Csla assembly.

 

ajj3085 replied on Tuesday, December 12, 2006

SonOfPirate:
"Unable to cast object of type 'Csla.Web.CslaDataSourceView' to type 'Csla.Web.CslaDataSourceView'."


Hmm... the only thing I can think of that would cause an error message like that would be a version mismatch on the assembly.  So the version of the assembly the component in blue comes from is not the same as the version of the assembly the red is from.  That's just a guess though.. but its odd you couldn't cast a type to itself..

RockfordLhotka replied on Tuesday, December 12, 2006

SonOfPirate:

I can tell you that this occurred after a rebuild of the complete solution - including the Csla assembly.

So do you have the Csla project as part of your business solution?

That's not a supported scenario, and may not be something we can fix. The IDE loads a version of Csla.dll into the AppDomain owned by the IDE and you are stuck with that version. But since I do dynamic loading of assemblies into a temporary AppDomain to reflect against your business assembly, it could be loading a different version of Csla.dll at that point - which would cause no end of confusion...

It is not supported to have the Csla project and your business/UI projects in the same solution in VS.

SonOfPirate replied on Tuesday, December 12, 2006

The source was added to simply debug and testing and toying with changes/customization/tweaks.  but, this makes sense.  I believe that it occurred after I recompiled the source assembly the last time as well.  It is understandable that the versions are out-of-whack then, which would obviously lead to the casting error.

I will have the assembly removed from the solution.  I think our understanding is thorough enough at this point that there's no benefit versus a reference any longer.

Thanks for the help understanding what has happened.

 

ChristianPena replied on Tuesday, May 01, 2007

A little late in my response here, but I encountered the same issue just now. This was caused by having a web app running in 1.5 and then attempting to run another one (the one that failed) in 2.0.

I shut down the 1.5 application and the issue was resolved.

Copyright (c) Marimer LLC