Rockford Lhotka's Blog

Home | Lhotka.net | CSLA .NET

 Saturday, June 17, 2006

CSLA .NET version 2.0.2 is now available for download at www.lhotka.net/cslanet/download.aspx. This is a bug fix update to address various errata and issues that readers have found since version 2.0.1.

This version also introduces one change, which allows you to call DataPortal.Fetch with no criteria.

Saturday, June 17, 2006 9:53:34 AM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Friday, June 9, 2006

According to this blog post by Soma, WinFX is now going to be named .NET 3.0.

Now on one hand this makes sense. There's no doubt that WinFX introduces major functionality to .NET. Windows Presentation Foundation is the effective successor to Windows Forms after all - how much more major can you get??

On the other hand, the new .NET 3.0 doesn't break any .NET 2.0 code, and yet it "includes" .NET 2.0. All .NET 3.0 does is add new stuff. Typically, when I think of a major version number changing, I expect that I'll have to retest everything and that much of my stuff might break or be affected. None of that is happening here.

Even changing from .NET 1.0 to 1.1 brought tons of headaches (if you used Remoting or Enterprise Services at least). And that was a point release. Yet here we have a major version change that doesn't change any existing bits.

I guess it just goes to show that there are no hard-and-fast rules in the software industry ;)

In any case, there's no doubt that Microsoft will reduce confusion overall by keeping everything under the .NET moniker, so I think this is a wise move.

Friday, June 9, 2006 4:54:33 PM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Wednesday, May 31, 2006

CSLA .NET version 2.0.1 is now available for download at www.lhotka.net/cslanet/download.aspx. This is primarily a bug fix update to address various errata and issues that readers have found since the release of the original code. It does include a couple changes primarily geared toward simplification of code generation templates. You can see the change log here.

At a high level the changes (other than bug fixes) include:

  • A new Initialize() method for use by code generation templates
  • A new IEditableBusinessObject interface to allow polymorphic child objects in BusinessListBase-derived collections
  • Better support for lazy loading of child collections (EditLevel property now visible from BusinessListBase, and null child object references now restored in UndoChanges)

 

Wednesday, May 31, 2006 9:37:06 PM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Thursday, May 25, 2006

According to Bookscan (a service which tracks book sales for all sorts of books), Expert C# 2005 Business Objects is number 365 and Expert VB 2005 Business Objects is number 385 among all computer books out there. This includes consumer-oriented computer books too, so these numbers are incredibly good. Programming books have a hard time competing with consumer books for sales volume after all.

What I find most interesting is that the VB sales are comparable to the C# sales. Obviously there really is a market for higher end VB programming books, which I think validates a view I've held for a long time, that the VB community was waiting for .NET to mature before moving forward. Clearly VS 2005 is triggering a non-trivial movement of VB developers into .NET, and these are hard-core professional developers who are looking for something beyond the reference-style and tutorial style books out there.

Like I said a few months ago, in .NET 1.1 the C# book outsold the VB book rather substantially. These numbers appear to show that the dynamic is changing, and I find that quite exciting!

Thursday, May 25, 2006 2:09:19 PM (Central Standard Time, UTC-06:00)  #    Disclaimer

I have two updates for CSLA .NET for those who are interested.

CSLA .NET version 1.53 is now available from www.lhotka.net/cslanet/download10.aspx. This is a minor bug fix update to 1.52.

A beta of CSLA .NET version 2.0.1 is now available from www.lhotka.net/cslanet/download.aspx. This includes fixes for a number of bugs and errata (which you can find at www.lhotka.net/cslanet), as well as some minor enhancements due to unforseen limitations around areas like threading and polymorphic child objects. If you get a chance to try 2.0.1 I would appreciate it. Barring any negative feedback from the community I expect to finalize it in about a week.

Thursday, May 25, 2006 2:01:38 PM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Saturday, May 13, 2006

I’ve run into a spot where I’m stuck, and I’m hoping someone has an idea.

 

CSLA .NET 2.0 includes an ASP.NET data source control: CslaDataSource. This works well, except for one issue, which is that it doesn’t refresh the metadata for your business objects unless you close VS 2005 and reopen the IDE.

 

The reason for this problem is that your business assembly gets loaded into memory so the data source control can reflect against it to gather the metadata. That part works fine, but once an assembly is loaded into an AppDomain it can’t be unloaded. It is possible to unload an entire AppDomain however, and so that’s the obvious solution: load the business assembly into a temporary AppDomain.

 

So this is what I’m trying to do, and where I’m stuck. You see VS 2005 has a very complex way of loading assemblies into ASP.NET web projects. It actually appears to use the ASP.NET temporary file scheme to shadow the assemblies as it loads them. Each time you rebuild your solution (or a dependant assembly – like your business assembly), a new shadow directory is created.

 

The CslaDataSource control is loaded into the AppDomain from the first shadow directory – and from what I can tell that AppDomain never unloads, so the control is always running from that first shadow directory. And then – even if I use a temporary AppDomain – the business assembly is also loaded from that same shadow directory, even if newer ones exist.

 

And that’s where I’m stuck. I have no idea how to find out the current shadow directory, and even if I do odd things like hard-coding the directory, then I just get in trouble because the new AppDomain thinks it has a different Csla.dll than the AppDomain hosting the Web Forms designer.

 

Here’s the code that loads the Type object within the temporary AppDomain:

 

    public IDataSourceFieldSchema[] GetFields()

    {

      List<ObjectFieldInfo> result =

        new List<ObjectFieldInfo>();

 

      System.Security.NamedPermissionSet fulltrust =

        new System.Security.NamedPermissionSet("FullTrust");

      AppDomain tempDomain = AppDomain.CreateDomain(

        "__temp",

        AppDomain.CurrentDomain.Evidence,

        AppDomain.CurrentDomain.SetupInformation,

        fulltrust,

        new System.Security.Policy.StrongName[] { });

      try

      {

        // load the TypeLoader object in the temp AppDomain

        Assembly thisAssembly = Assembly.GetExecutingAssembly();

        int id = AppDomain.CurrentDomain.Id;

        TypeLoader loader =

          (TypeLoader)tempDomain.CreateInstanceFromAndUnwrap(

            thisAssembly.CodeBase, typeof(TypeLoader).FullName);

        // load the business type in the temp AppDomain

        Type t = loader.GetType(

          _typeAssemblyName, _typeName);

       

        // load the metadata from the Type object

        if (typeof(IEnumerable).IsAssignableFrom(t))

        {

          // this is a list so get the item type

          t = Utilities.GetChildItemType(t);

        }

        PropertyDescriptorCollection props =

          TypeDescriptor.GetProperties(t);

        foreach (PropertyDescriptor item in props)

          if (item.IsBrowsable)

            result.Add(new ObjectFieldInfo(item));

      }

      finally

      {

        AppDomain.Unload(tempDomain);

      }

      return result.ToArray();

    }

 

This replaces the method of the same name from ObjectViewSchema in the book.

 

Notice that it creates a new AppDomain and then invokes a TypeLoader class inside that AppDomain to create the Type object for the business class. The TypeLoader is a new class in Csla.dll that looks like this:

 

using System;

using System.Collections.Generic;

using System.Text;

 

namespace Csla.Web.Design

{

  /// <summary>

  /// Loads a Type object into the AppDomain.

  /// </summary>

  public class TypeLoader : MarshalByRefObject

  {

    /// <summary>

    /// Returns a <see cref="Type">Type</see> object based on the

    /// assembly and type information provided.

    /// </summary>

    /// <param name="assemblyName">(Optional) Assembly name containing the type.</param>

    /// <param name="typeName">Full type name of the class.</param>

    /// <remarks></remarks>

    public Type GetType(

      string assemblyName, string typeName)

    {

      int id = AppDomain.CurrentDomain.Id;

      return Csla.Web.CslaDataSource.GetType(

        assemblyName, typeName);

    }

  }

}

 

Since this object is created in the temporary AppDomain, the business assembly is loaded into that AppDomain. The Type object is [Serializable] and so is serialized back to the main AppDomain so the data source control can get the metadata as needed.

 

This actually all works – except that it doesn’t pick up new shadow directories as they are created.

 

Any ideas on how to figure out the proper shadow directory are appreciated.

 

Honestly, I can’t figure out how this works in general – because obviously some part of the VS designer picks up the new shadow directory and uses it – even though the designer apparently doesn’t. I am quite lost here.

 

To make matters worse, things operate entirely differently when a debugger is attached to VS than when not. When a debugger is attached to VS then nothing appears to pick up the new shadow directories – so I assume the debugger is interfering somehow. But it makes tracking down the issues really hard.

Saturday, May 13, 2006 12:53:49 PM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Friday, May 12, 2006

I just got back from Norway (so my body has no idea what time it actually is right now...), and one of the conversations I had while there was about data binding a TextBox to an object's property that is a Nullable<T> - like Nullable(Of Integer) or something.

Somehow I had expected that Windows Forms would have anticipated this (obvious) concept and would handle it. Not so...

Fortunately, as a result of this conversation, one of the people at the conference took some of the ideas we were tossing around and came up with an extender control to address the issue. Very nice!

Friday, May 12, 2006 7:57:52 AM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Friday, May 5, 2006

There's a new online CSLA .NET forum, hosted by Magenic Technologies, with the Community Server software provided by Telligent.

http://forums.lhotka.net

As always, the home site for CSLA .NET is www.lhotka.net/cslanet, where you can find news, answers to frequently asked questions and downloads of the framework and related resources.

This forum is a replacement for http://groups.msn.com/CSLANET - which has served the community for a number of years. Unfortunately groups.msn.com turns out to be rather unreliable and slow, so the forum had to be moved. If you are looking for older discussions you may want to check there. Associated with that forum is www.searchcsla.com, which allows you to search the archive of that older forum.

But now we've got this new forum, which will hopefully overcome some of the limitations and reliability issues of MSN - so please make good use of the forum and enjoy!

Friday, May 5, 2006 10:01:52 AM (Central Standard Time, UTC-06:00)  #    Disclaimer
 Wednesday, May 3, 2006

My author copies of Expert VB 2005 Business Objects arrived on my doorstep today, meaning that the book is in print and is being delivered to booksellers right now. This means it should be available on bookshelves and from online sellers very, very soon.

Wednesday, May 3, 2006 7:37:30 PM (Central Standard Time, UTC-06:00)  #    Disclaimer
On this page....
Search
Archives
Feed your aggregator (RSS 2.0)
April, 2019 (2)
January, 2019 (1)
December, 2018 (1)
November, 2018 (1)
October, 2018 (1)
September, 2018 (3)
August, 2018 (3)
June, 2018 (4)
May, 2018 (1)
April, 2018 (3)
March, 2018 (4)
December, 2017 (1)
November, 2017 (2)
October, 2017 (1)
September, 2017 (3)
August, 2017 (1)
July, 2017 (1)
June, 2017 (1)
May, 2017 (1)
April, 2017 (2)
March, 2017 (1)
February, 2017 (2)
January, 2017 (2)
December, 2016 (5)
November, 2016 (2)
August, 2016 (4)
July, 2016 (2)
June, 2016 (4)
May, 2016 (3)
April, 2016 (4)
March, 2016 (1)
February, 2016 (7)
January, 2016 (4)
December, 2015 (4)
November, 2015 (2)
October, 2015 (2)
September, 2015 (3)
August, 2015 (3)
July, 2015 (2)
June, 2015 (2)
May, 2015 (1)
February, 2015 (1)
January, 2015 (1)
October, 2014 (1)
August, 2014 (2)
July, 2014 (3)
June, 2014 (4)
May, 2014 (2)
April, 2014 (6)
March, 2014 (4)
February, 2014 (4)
January, 2014 (2)
December, 2013 (3)
October, 2013 (3)
August, 2013 (5)
July, 2013 (2)
May, 2013 (3)
April, 2013 (2)
March, 2013 (3)
February, 2013 (7)
January, 2013 (4)
December, 2012 (3)
November, 2012 (3)
October, 2012 (7)
September, 2012 (1)
August, 2012 (4)
July, 2012 (3)
June, 2012 (5)
May, 2012 (4)
April, 2012 (6)
March, 2012 (10)
February, 2012 (2)
January, 2012 (2)
December, 2011 (4)
November, 2011 (6)
October, 2011 (14)
September, 2011 (5)
August, 2011 (3)
June, 2011 (2)
May, 2011 (1)
April, 2011 (3)
March, 2011 (6)
February, 2011 (3)
January, 2011 (6)
December, 2010 (3)
November, 2010 (8)
October, 2010 (6)
September, 2010 (6)
August, 2010 (7)
July, 2010 (8)
June, 2010 (6)
May, 2010 (8)
April, 2010 (13)
March, 2010 (7)
February, 2010 (5)
January, 2010 (9)
December, 2009 (6)
November, 2009 (8)
October, 2009 (11)
September, 2009 (5)
August, 2009 (5)
July, 2009 (10)
June, 2009 (5)
May, 2009 (7)
April, 2009 (7)
March, 2009 (11)
February, 2009 (6)
January, 2009 (9)
December, 2008 (5)
November, 2008 (4)
October, 2008 (7)
September, 2008 (8)
August, 2008 (11)
July, 2008 (11)
June, 2008 (10)
May, 2008 (6)
April, 2008 (8)
March, 2008 (9)
February, 2008 (6)
January, 2008 (6)
December, 2007 (6)
November, 2007 (9)
October, 2007 (7)
September, 2007 (5)
August, 2007 (8)
July, 2007 (6)
June, 2007 (8)
May, 2007 (7)
April, 2007 (9)
March, 2007 (8)
February, 2007 (5)
January, 2007 (9)
December, 2006 (4)
November, 2006 (3)
October, 2006 (4)
September, 2006 (9)
August, 2006 (4)
July, 2006 (9)
June, 2006 (4)
May, 2006 (10)
April, 2006 (4)
March, 2006 (11)
February, 2006 (3)
January, 2006 (13)
December, 2005 (6)
November, 2005 (7)
October, 2005 (4)
September, 2005 (9)
August, 2005 (6)
July, 2005 (7)
June, 2005 (5)
May, 2005 (4)
April, 2005 (7)
March, 2005 (16)
February, 2005 (17)
January, 2005 (17)
December, 2004 (13)
November, 2004 (7)
October, 2004 (14)
September, 2004 (11)
August, 2004 (7)
July, 2004 (3)
June, 2004 (6)
May, 2004 (3)
April, 2004 (2)
March, 2004 (1)
February, 2004 (5)
Categories
About

Powered by: newtelligence dasBlog 2.0.7226.0

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2019, Marimer LLC

Send mail to the author(s) E-mail



Sign In