Beginner level - creating my Business Object libraryBeginner level - creating my Business Object library
Old forum URL: forums.lhotka.net/forums/t/2717.aspx
FCazabon posted on Tuesday, April 17, 2007
Hi,
I am trying to create my first business object library using CSLA.NET.
I have:
- created a new project and called it Membership.Library.
- added in a Reference to CSLA.dll,
System.Configuration and System.Transactions
- Added
a new Windows Class called Database.vb and added code in (based on
Database.vb)
- Added
a new Windows Class (Member) and added code in (based on Project.vb)
When I build the project I get quite a few errors:
1. Type 'BusinessBase' is not defined.
This occurs in my definition of the Public Class Member:
Inherits BusinessBase(Of Member)
Where is BusinessBase defined?
2. Likewise I am getting errors that CanReadProperty, CanWriteProperty, PropertyHasChanged have not been declared.
I'll start off with those, but be warned, I have 54 errors in all :(
Thanks for any help/insight on what is causing these errors.
Frank
FCazabon replied on Tuesday, April 17, 2007
Interesting...
I just tried building the ProjectTracker.Library and got loads of similar errors too!
Should this be happening? Or have I messed up something?
FCazabon replied on Tuesday, April 17, 2007
Well, I reinstalled the CSLA stuff from scratch and now the ProjectTracker.Library builds successfully.
But, my project doesn't :(
I'm feeling at quite a loss here. Any suggestions on how to approach learning how to use this framework successfully?
FCazabon replied on Tuesday, April 17, 2007
If I put an:
Imports Csla
at the start of my Member.vb then the problems I was having with the "BusinessBase not defined" is solved. But why do I have to do this when the Sample ProjectTracker Project.vb does not need it?
awsisme replied on Tuesday, April 17, 2007
Did you do a build on the CSLA stuff and generate the binaries? I don't think they are shipped with the framework. Sounds like VB isn't resolving the references properly.
Also, I think I remember having to point the Project Tracker references to a different place when I first installed. It's been a while.
Andy
FCazabon replied on Tuesday, April 17, 2007
Hi Andy,
I did build the csla project and then set the reference in my project.
Csla shows up in the object browser and if I type Csla. in the editor intellisense kicks in.
FWIW, I've got over all my errors! (at least the compile time ones). But I'd still ike to understand why the Imports is necessary in my project and not in the sample.
So my next step will be to try to build a windows interface to this BO.
Thanks for your help,
Frank
Q Johnson replied on Tuesday, April 17, 2007
>> But I'd still ike to understand why the Imports is necessary in my project and not in the sample. <<
Frank,
This is just a little opportunity for you to learn about setting references in VS. In the sample app, the references to CSLA are set in each PROJECT, so the code files in THOSE projects don't need to use Imports statements. You have evidently NOT set references at the project level, so your code modules require the Imports statements.
Look at the text in the "Setting up the project" section of chapter 8, ppg 408-409. Also note under "PTWin Project Setup" on pg 472 the very good advice offered about references: "...it is best to establish a file reference to the framework assembly, but use project referecnes between the UI and any business assemblies. This makes debugging easier overall, because it helps prevent accidental changes to the CSLA.NET framework project while enabling fluid changes to both the business objects and UI code." (emphasis is mine, of course) Please note that both of the kinds of references (file and project) he addresses in this text are references that are set at the project level. So you won't have to use Imports statements for them for the code files in those projects. I know this is a little confusing so please read it carefully. I'm talking about references set at the project level but to either a file or a project depending on the assembly you need. If it was too confusing, let me know and I'll step you through how to set references
One more tip on file references for CSLA in your projects - you probably want to be able to step through the framework code while debugging your own projects (even though you don't have the csla project in your solution). In version 1.x of the framwork you would just get the dll in the obj\debug folder. There appear to be two choices in the 2.x framework: bin\debug and obj\debug. Both have the csla.pdb file that I've heard holds that all-important functionality needed for the stepping through the code. I'm just making the transition to 2.x myself. I'm going with bin\debug for now (because I can see that this is what ProjectTracker.Library uses) and I'll be sure and let you know if that didn't work out as I expected.
One last thing. Your name looks rather familiar. Might you have been a FoxPro programmer back in the bad old ninties?
FCazabon replied on Wednesday, April 18, 2007
Hi Q,
yes, I am a VFP developer mainly, but have been digging more and more into .NET over the last year or so. I have a client who wants a VB app done soon, so have been looking into the frameworks available for .NET and CSLA is the first I've looked at. I remember your name as well. Have you moved on from VFP completely?
I believe I have set a file reference to the csla.dll, here's what I did:
In My Project | References (of my Membership.library project), I clicked on Add, then the Browse tab, then located the csla.dll in csla20vb\csla\bin\debug.
Did I do it wrong?
Thanks for your assistance.
Q Johnson replied on Wednesday, April 18, 2007
>> I remember your name as well. Have you moved on from VFP completely? <<
Oh yeah. I was only in FoxPro a relatively short time. I most on to VB3 in 1994 and never looked back. In fact, I never even used VFP; my last version was the 2.6 that had a DOS version and a Windows version.
>> In My Project | References (of my Membership.library project), I clicked on Add, then the Browse tab, then located the csla.dll in csla20vb\csla\bin\debug. <<
That's exactly right.
>>Thanks for your assistance. <<
Glad to help!
FCazabon replied on Wednesday, April 18, 2007
Hi Q,
well, if what I did to set the reference was exactly right, why do I need the "Imports" statement?
:(
Frank
JoeFallon1 replied on Wednesday, April 18, 2007
After you set a reference you can create a Project level Import statement in VS.
If you do this then you do not need one in each file.
If you don't do it, you need one in each file.
Joe
FCazabon replied on Thursday, April 19, 2007
Hi Joe,
thanks. I have searched the ProjectTracker solution and not found an "Imports Csla" statement anywhere. How do I create the project level Imports statement?
Frank
xal replied on Thursday, April 19, 2007
Go to the project's properties. Open the references tab. You'll see the list of references and then below that a list of imported namespaces. Check the box by Csla and there you go.
Andrés
FCazabon replied on Thursday, April 19, 2007
Thanks very much Andres!
I was never even aware that part of the screen existed. :(
Frank
JoeFallon1 replied on Thursday, April 19, 2007
See the attached image.
A picture is worth a thousand words.
Joe
FCazabon replied on Thursday, April 19, 2007
Thanks Joe, I got it now.
Frank
Copyright (c) Marimer LLC