StrataFrame Forum

Problems with our own BO template. Can you help?

http://forum.strataframe.net/Topic8929.aspx

By Peter Jones - 5/21/2007

Hi,

This is not a StrataFrame issue as such but I would appreciate any comments you care to make. We have our own base BO that we have implemented as a template. It does a lot of standard stuff for our app and inherits from MicroFour.StrataFrame.Business.BusinessLayer of course.

In the environment we used to develop the template it works fine - a single project which contained all the BOs we created and various classes and forms.

We now have what we believe will be our 'proper' development environment - a single solution containing multiple projects, e.g. BO library for this, a BO library for that, a project for Forms etc. But now, when I create a BO using our template, I get the following errors and I just can't see where we have gone wrong. If I create a BO using the standard StrataFrame BO template everything is fine. I have checked the boXXX.designer.vb code for the BO produced by our own template and the standard StrataFrame template and its identical. I have checked the boXXX.vb code for for both approaches and, except for the expected custom code, both pieces of code are the same.

As I said, any comment would be appreciated.

Error 1 'Public Overrides Property RequiredFields() As MicroFour.StrataFrame.Business.RequiredFieldsCollection' cannot override 'Public Overridable Property RequiredFields() As MicroFour.StrataFrame.Business.RequiredFieldsCollection' because they differ by their return types. C:\TMSRedevelopment\TMS\BOTableMaint\boSPCNew.Designer.vb 46 31 BOTableMaint

Error 2 'Public Overrides Property ParentRelationship() As MicroFour.StrataFrame.Business.IBusinessParentRelationship' cannot override 'Public Overrides Property ParentRelationship() As MicroFour.StrataFrame.Business.IBusinessParentRelationship' because they differ by their return types. C:\TMSRedevelopment\TMS\BOTableMaint\boSPCNew.Designer.vb 60 31 BOTableMaint

Error 3 'Public Overrides ReadOnly Property FieldEnums() As
MicroFour.StrataFrame.Business.BusinessLayerFieldEnumDictionary' cannot override 'Public Overridable ReadOnly Property FieldEnums() As MicroFour.StrataFrame.Business.BusinessLayerFieldEnumDictionary' because they differ by their return types. C:\TMSRedevelopment\TMS\BOTableMaint\boSPCNew.Designer.vb 194 40 BOTableMaint

Error 4 function 'CreateNewFieldSecurityEventArgs' cannot be declared 'Overrides' because it does not override a function in a base class. C:\TMSRedevelopment\TMS\BOTableMaint\boSPCNew.Designer.vb 442 34 BOTableMaint

Error 5 sub 'OnCheckFieldSecurity' cannot be declared 'Overrides' because it does not override a sub in a base class. C:\TMSRedevelopment\TMS\BOTableMaint\boSPCNew.Designer.vb 462 29 BOTableMaint

Error 6 'Protected Overrides ReadOnly Property PropertyDescriptors() As MicroFour.StrataFrame.Business.PropertyDescriptorDictionary' cannot override 'Protected Overridable ReadOnly Property PropertyDescriptors() As MicroFour.StrataFrame.Business.PropertyDescriptorDictionary' because they differ by their return types. C:\TMSRedevelopment\TMS\BOTableMaint\boSPCNew.Designer.vb 572 43 BOTableMaint

Cheers, Peter

By StrataFrame Team - 5/22/2007

The "differ by return types" can be caused by one of a couple of things... either the versions of the SF DLLs are different (one project is referencing 1.5 and one is referencing 1.6), or you built a partial class for your base business layer class.  If you have a base class for your business objects that contains some extra code that is common to all of your business objects, you need to make sure you don't build a partial class for it (it should always have a red-x on it in the BOMapper, and when you do a "Build All" you'll get an error saying that it's not configured, which can be ignored...).

So, check the versions of your references and make sure they're all the same, and then if you have a base class for your business objects, make sure it's not configured.

By Peter Jones - 5/22/2007

Hi Ben,

I'm not sure what you mean by "If you have a base class for your business objects that contains some extra code that is common to all of your business objects, you need to make sure you don't build a partial class for it (it should always have a red-x on it in the BOMapper.." and "..if you have a base class for your business objects, make sure it's not configured."


Certainly our only partial class is the standard Designer code but we don't process anything through the BO Mapper that causes a red cross.

Our structure is as follows:

Our BO template generates the class, e.g.

  Imports System.Data
  Imports System.Data.SqlClient
  Imports System.Runtime.Serialization

  <Serializable()> _
  Public Class boSPCNew
      Inherits UtilBOBase.boBase

This class has the Constructors and handles "SetDefaultValues" that we extract directly from the database. It inherits boBase that is all our own code and is common to all BO's:


  Option Explicit On
  Option Strict On

  Imports System.Data
  Imports System.Data.SqlClient
  Imports System.Runtime.Serialization
  Imports System.Diagnostics
  Imports MicroFour.StrataFrame.Messaging
  Imports UtilRunTimeEnvironment
  Imports UtilEnums
  Imports UtilLogging
  Imports UtilLocalisation

  Public Class boBase

      Inherits MicroFour.StrataFrame.Business.BusinessLayer

Obviously MicroFour.StrataFrame.Business.BusinessLayer is unchanged.


So, we use our template to generate the BO and process that through the Business Object Mapper to generate the Designer code. The Designer code is standard StrataFrame:

  Option Strict On
  Option Explicit On

  Imports MicroFour.StrataFrame.Business
  Imports MicroFour.StrataFrame.Security
  Imports MicroFour.StrataFrame.UI.Windows.Forms
  Imports System.Collections.Generic
  Imports System.ComponentModel
  Imports System.Data
  Imports System.IO

  Partial Public Class boSPCNew


In terms of versions I think we a right there - everything is 1.6 in the GAC, \Program Files\Common Files\MicroFour\StrataFrame and \Program Files\MicroFour\StrataFrame\Assemblies although there are 1.5 DLL's in the sources directories.

In this case, the BO that works and the one that doesn't, are both in the same Project so I presume that rules out any potential versioning problem.

Ben, thanks for taking the time with this - I realise this isn't a really a StrataFrame issue.

Cheers, Peter


 

By Peter Jones - 5/22/2007

Hi Ben,

Now see what you mean re the base BO not being configured in the BO mapper. It isn't (has the red cross).

Cheers, Peter

By StrataFrame Team - 5/23/2007

Is your boBase business object in a different project than the other business objects?  And does the business object that is not having a problem inherit from boBase or directly from BusinessLayer?
By Peter Jones - 5/23/2007

Hi Ben,

Is your boBase business object in a different project than the other business objects?

Yes it does. The Project has references to MF.SF.Base and MF.SF.Business.


And does the business object that is not having a problem inherit from boBase or directly from BusinessLayer?

Directly from the BusinessLayer. The boXXX.vb code is:

Imports System.Data
Imports System.Data.SqlClient
Imports System.Runtime.Serialization

<Serializable()> _
Public Class boSPCOld

Inherits MicroFour.StrataFrame.Business.BusinessLayer


The boXXX.Designer.vb code is:

Option Strict On
Option Explicit On

Imports MicroFour.StrataFrame.Business
Imports MicroFour.StrataFrame.Security
Imports MicroFour.StrataFrame.UI.Windows.Forms
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.IO

Partial Public Class boSPCOld

Cheers, Peter

By StrataFrame Team - 5/24/2007

OK, looks like the version on your project that contains the boBase might be wrong.  Or something within a resource somewhere was not updated properly.  In both of your projects (the one with boBase and the one with your bo causing the problem), do a Ctrl+F for "1.5.0.0" (without the quotes Wink) and see if a reference pops up somewhere other than in the project referenses (like an .resx file or something).
By Peter Jones - 5/24/2007

Hi Ben,

Actually I had already done that search through the entire solution looking for "1.5." when you first mentioned we may have a reference to 1.5. somewhere but nothing is found (the search looked in all files including hidden text). I've just repeated the search but, again, nothing is found.

Cheers, Peter

By Peter Jones - 5/24/2007

Hi Ben,

All is ok now - thanks for your input. I guess it had to be resolved by something simple (but stupid).

I deleted the MicroFour references in the project and added them back! Just out of frustration and not thinking for moment that it would help but it did.

Prior to that I had put my boBase class into the project with the BO's that used it and that, as you would expect, also removed the error but that was never going to be a fix - I just did that to prove to myself that everything was fundamentally ok.

Cheers, Peter

By StrataFrame Team - 5/25/2007

Hehe, looks like VS was hanging on to something in the project file... Usually, when the references aren't marked with the silly little warning signs, you're OK; however, as you just figured out, sometimes, removing and re-adding the references helps as well.  I'm glad you got it working.