CslaDataSource refresh issue

CslaDataSource refresh issue

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


RockfordLhotka posted on Saturday, May 13, 2006

As you may have discovered, CslaDataSource (the ASP.NET data source control) doesn't refresh the metadata for business classes when you change your business assembly. At least not without closing and reopening VS 2005.

I've been trying to solve this issue, but I'm stuck. Anyone looking for a seriously geeky challenge? Smile [:)]

http://www.lhotka.net/WeBlog/DynamicallyLoadingAssembliesFromShadowDirectories.aspx

vivus replied on Tuesday, May 16, 2006

this may or may not help you, i know that i was having issues trying to load types from the App_Code folder and i found a bunch of people saying Assembly.Load("App_Code").GetType()... etc.... this didn't work either. 

what i found was a very new but undocumented class  BuildManager in the System.Web.Compilation namespace.  This guy is supposed to know what is loaded and manages that.  

    return BuildManager.GetType(typeName, false, true); 

rather than

Assembly asm = Assembly.Load(assemblyName);
                    return asm.GetType(typeName, true, true);

i'm haven't tested it on other libraries, but i know it helps with using types from the App_Code directory, so it might be smart enough to load the other libraries you need as well.  At the the very least, it might get rid of the need to having to name  AssemblyName, leaving you to just supplying the full type name.  '

i also added a method to your CslaDataSourceDesigner and tweak some other methods to pass around the base.component which holds the service provider. 

    internal static Type GetType(IServiceProvider serviceProvider, string typeName) {
            ITypeResolutionService service1 = null;
            Type type1 = null;
            if (serviceProvider != null)
                service1 = (ITypeResolutionService)serviceProvider.GetService(typeof(ITypeResolutionService));
            if (service1 == null)
                return null;
            try {
                type1 = service1.GetType(typeName, true, true);
            } catch (Exception exception1) {
                throw new Exception("Can not find type", exception1);
                type1 = null;
            }
            return type1;
        }

RockfordLhotka replied on Thursday, May 18, 2006

Unfortunately the BuildManager doesn't appear to return Type objects for referenced assemblies - only those built from App_Code I guess.
 
Rocky
 

Jav replied on Friday, May 19, 2006

I predict that this problem with CslaDataSource will go away by itself when Microsoft issues the VS2005 SP1. 

Rocky, I don't know if you have had to work with Windows Forms Designer much in VS2005, but I am finding it pure hell. To me the etiology of both appears to be the same and both need fixing - soon.

I converted my working app to Csla 2.0 and I can run it and open most of its forms and do useful work in them.  But in the Windows Forms Designer, it is a miracle if I can open an existing UserControl without a full screen message with about the same unhelpful language telling me that the designer cannot open the control.  Yesterday, the message in every case told me it was looking for one of my assemblies with a version number that I could find nowhere in my Solution. (The version it was seeking was actually higher than any that I have in my solution)  It felt like some reference was sticking somewhere like a wad of bubblegum to the shoe.

I removed every one of my project references and everytime the Build proceeded without error and the program ran fine, but there was no way I could get the designer to work.  The only way I could make it work was to delete every bin and obj folder from the Solution.  And then it worked for about an hour and I was back in the same hell with some different Control.

I am wondering if MS recently hired some programmer from Sun Microsystems - surely somebody's trying to sabotage'm from the inside.

Jav

RockfordLhotka replied on Friday, May 19, 2006

Jav, I've spent a lot of time working with the Windows Forms designer and it is far from perfect...
 
However, I have found that upgraded forms (from 2003) are very unreliable, while new forms created in 2005 work far better. Just this past week, while at VS Live, I had to rebuild one of my demos. It had been working fine for weeks and then failed for no apparent reason. But it was a 2003->2005 upgrade and I think ultimately that was the cause of the problem.
 
I agree - hopefully SP1 will fix most of these issues!
 
Rocky
 

Jav replied on Friday, May 19, 2006

I posted about my troubles with Windows Forms on MS NewsGroups.  Here is a response that I got.  I think it is interesting since it also talks about having to restart VS.

>>> ..... Also, if you are using
the new object binding, it may be that you re-built your object store after
the last build of the user control. The winform object binding hard-codes
the version number for the objects. If you rebuild the business layer, the
version number is not updated until you close and re-open VS. (royal pain
at times)
.
Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
<<<

That makes a lot of sense because my problems with WinForms designer also improve a whole lot if I close the VS and then re-open it.  Waiting for SP1.

Jav

dnorth replied on Tuesday, May 23, 2006

Jav,

I don't know if this will help you or not - we were experiencing similar problems in the Form Designer in VS.NET 2005:

http://support.microsoft.com/kb/912019/en-us

4
 

Jav replied on Tuesday, May 23, 2006

Thank you - I would certainly try it.  I do hope MS will issue the SP1 soon.

Jav

vivus replied on Sunday, May 21, 2006

any referenced assembly in the web.config which is whatever reference you add to your web project through VS 2005.

though i think the 2nd method is what you are really looking for, its a static GetType method used for designer classes.  You'll need to pass  around an IComponent that comes from the base.component of your CslaDataSourceDesigner to the object schema.  that way you can pass IComponent.Site to the method. 

I'll play around with it more once i have some time to breathe, to verify if this is really what you need

Copyright (c) Marimer LLC