OK, this one took me a few minutes to figure out. First of all, if you actually deployed the project, it would work. So if you took exactly what you have and ran it through IIS or a test or production server (outside of the ASP.NET Development Server that runs out of VS in your system tray) it would work and will work.
The problem that you are running into is a .NET issue as to how it pre-compiles the application to run in a debug mode (good news is ahead so don't worry
), it dumps all assemblies into the Temporary ASP.NET folder (i.e. C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files) each time the app is run from within the VS environment. So when you create a reference to an assembly in code, it will shift the references and pull from this temporary ASP.NET files location. But StrataFrame (i.e. the ListView) uses a true resolution (ITypeResolver interface implemented in the ApplicationBasePage) to pull the assembly from the deployed Bin folder (or other sub folder within the compiled application).
So here is what happens when running through the designer:
//-- Pulls the assembly from C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
MyBO x = new MyBO();
where as our logic pulls it from the Bin folder (which is far safer in the long run):
//-- What is going on within the instance creation in SF which pulls from the actual deployed Bin folder
BusinessLayerBase x = (BusinessLayerBase)GetTypeFromReferencedAssemblies("BusinessObjectLibrary1.AccountAddresses" ((Tools.ITypeResolver)this.Page).GetCompilationSection(), this.Page);
Now long term we may make a change to determine if we are running through the designer...but there is a really simple workaround. Just sign the business object library and put it in the GAC on your development machine. You will NOT need to do this when you deploy (nor is it recommended), but this will resolve the casting exception that you are getting and always ensure that you are on the same reference.
You will also want to add a PostBuild Event that throws the BO library assembly in your GAC for you automatically so you don't have to worry about it every time you build. Just use the GACUTIL to automatically add (and overwrite) your assembly into the GAC on the post build event and from that point forward you should be good to go.
One final thought is to call the pre-compile tool on a post-build event and force the output to a totally different location, but this approach could be more cumbersome.