This is a migrated thread and some comments may be shown as answers.

3-Tier Sample App - Reference Persistent Classes

11 Answers 396 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Markus
Top achievements
Rank 1
Markus asked on 27 Jan 2009, 01:51 PM
Hi all,

I am currently exploring the world of OR-Mappers. Therefore I want to set up a 3 Tier sample Application with OpenAccess. So far I have performed the following steps:

Create a Solution with 3 projects: 2 class libraries (for the business and database layer) and 1 console application as a test gui layer. I defined my persistent classes in the business project and enabled it with the OpenAccess Wizard. (Project contains only persistent classes, so I only checked this checkbox in the wizard)
Then I enabled my database layer to work with OpenAccess (This time I only checked the Checkbox Data access code (DAL)).
The wizard created a App.config file in both libraries projects and an ObjectScopeProvider class in the database project. To mark the classes as persistent I used the OpenAccess Forwardmapping wizard and it generated the persistent attributes without any error. The last step was to add neccessary references (I added Projectreference from business to database project and another one from gui to business project and furthermore I added references to the Telerik namespace in the GUI project). In the App.config file of the database project I added a reference to the business project (<reference assemblyname="Business" configrequired="true"/> )
Finally I developed a class ScopeController in the business project to pass dataoperations to the database project.

Now, when I create some test object in the gui project and call some saveObject method (scope.Transaction.Begin, scope.Add(), scope.Transaction.Commit() ), an ConfigurationErrorsException error occur with following hint: "No enhanced assembly has been found for meta-data construction. This may be caused by a missing app.config file (use app.config as embedded resource then) or by an insufficient references section in the configuration file (add the referenced enhanced assemblies there too) or by a wrong enhancement setting; please check your configuration."

Right now I have no idea how to accomplish this test and I don't know if I made some basic error or if there is just a typo in a config file or something like this. Can anybody help me out?

Thanks in advance
Regards
Markus

11 Answers, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 27 Jan 2009, 02:20 PM
Hi Markus,

Can you run the 'Check Settings' feature (available under OpenAccess->Configuration->Check Settings)? This will perform some basic configuration checks on the solution. You can also try fixing any errors using the dialog.

Hope that solves your problem.

Sincerely yours,
Ady
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Markus
Top achievements
Rank 1
answered on 27 Jan 2009, 02:44 PM
Hi Ady,

thanks for your answer. I already performed the OpenAccess Check settings step, everything is green. No errors here.
I think the problem is due to the fact that I want to perform all datamanipulating operations in the database project, and keep the persistent classes in the business project. So OpenAccess is searching for persistent classes inside the database project, but I want it to search in the business project. Is this possible or is my first 3 tier application doomed? ;-)

Thanks in advance
Best Regards
Markus
0
Ady
Telerik team
answered on 27 Jan 2009, 03:02 PM
Hello Markus,

You can perform all database operation in your database (or DAL) project.
In a simple scenario you would add an assembly/project  reference from your DAL project to your Persistent class library and in your GUI project add a reference to the DAL and Persistent Class library project.
You can use the 'Check settings' feature to update the config reference entries in the app.config files.

I think what is missing in your setup is the reference from the DAL project to the persistent class library and not the other way round.

Regards,
Ady
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Markus
Top achievements
Rank 1
answered on 27 Jan 2009, 03:18 PM
Hi Ady,

thanks again for your answer. Regarding the project references: I thought in a 3 tier application every tier is supposed to interact with only one other tier and furthermore that they should only interact if they are "next to eacht other". In other words: The GUI should only interact with the business logic and the business logic should only interact with the database so one can change a tier without to care about the other application layers. This would not be the case if I add a reference from the GUI to the database tier. Perhaps I am just misadvised here?

Thanks again
Best Regards
Markus
0
Thomas
Telerik team
answered on 27 Jan 2009, 04:05 PM
Hello Markus,

the OpenAccess runtime constructs it's needed meta data completely during opening of the database.
At this point in time, all the classes and configurations are needed. The configuration comes from the application configuration file normally, but can also be stored in the resources of a class library. The only important point is that there needs to be a deterministic way to obtain it. The list of assemblies loaded in the current application domain (or something like this) is not enough, because the list might not be filled completely yet or otherwise unreliable. So much to the background.

What you should do is to have a <openaccess> section in the app.config (GUI), that just references the Business layer (<references><reference assemblyname="BL" configrequired="true"/></references>) .
Likewise, the BL should reference the DB-Layer. In this way, the application knows only the minimum,
but still is able to obtain all information by traversing the app.config files openaccess section.
Alternativly you could have a look at the Database.Get(string,XmlElement,Assembly) method 

Again, all is about reliably finding the configuration and classes.

Best wishes,
Thomas
0
Markus
Top achievements
Rank 1
answered on 27 Jan 2009, 04:11 PM
Hi Thomas,

thank you for your answer. I will try to use your hints tomorrow and post my progess (or failure.)

Thanks again
Best Regards
Markus
0
Markus
Top achievements
Rank 1
answered on 28 Jan 2009, 07:43 AM
Hi again,

I have now added your suggestions into my solution. (Added references into the App.config file in the GUI and the Business project).
Now I'm hitting the "No persistent class could be found" Error. The persistent classes are in the Businessproject and have the required persistent attributes. This should be ok. Is an entry for the persistent classes also in the App.conf file (businessproject) required? It looks like the forward mapping wizard did not gerenate an entry there.

Thanks in advance
Best Regards
Markus
0
Thomas
Telerik team
answered on 28 Jan 2009, 09:33 AM
Hi Markus,

this looks like you are not having set the 'Enhancing' flag for the project where the persistent classes are implemented. So the runtime does not find any enhanced persistent classes.

Sincerely yours,
Thomas
0
Markus
Top achievements
Rank 1
answered on 28 Jan 2009, 12:21 PM
Hi Thomas,

I checked the project settings and for every single project the EnhancementOutput Value is set to 1 and Enhancing is enabled (true). Can I send any Code samples to help you?

Best Regards
Markus
0
Thomas
Telerik team
answered on 28 Jan 2009, 05:55 PM
Hello Markus,

sure, please do so. Giving us code in nearly all cases speeds us up tremendously!

Kind regards,
Thomas
0
Markus
Top achievements
Rank 1
answered on 29 Jan 2009, 07:09 AM
Hi Thomas,

I finally managed to execute my Application and to save some testdata. The reason for the error was a typo in one of the references in an App.config file and furthermore the option "UpdateDatabase" in the Businessproject was not set to true, so whenever I wanted to save some data, there was no table to save it.

Thanks again for your fast help
Best Regards
Markus
Tags
Getting Started
Asked by
Markus
Top achievements
Rank 1
Answers by
Ady
Telerik team
Markus
Top achievements
Rank 1
Thomas
Telerik team
Share this question
or