Enterprise Library 3.1 - machine.config, problem with attribute 'requirePermission'

Topics: Data Access Application Block
May 29, 2007 at 9:28 AM
Hello all,
I have installed the Enterprise Library 3.1 version and I am trying to play around with it in order to use it in my projects. I have added the “app.config” file, which I modified by using the Enterprise Library configuration application, to connect to Northwind DB using SQL Server 2000.
I have a line of code that I instantiate a Database object as follows

Dim dbTemp As Database
. . .
dbTemp = DatabaseFactory.CreateDatabase()

As soon as the above line is executed, I get an error message regarding the attribute 'requirePermission' in the machine.config file, stating that it is unrecognized.
No matter what I have tried for the past week, I could not get it to work.
I would appreciate it greatly if anyone can assist me with this problem.
Thank you for your cooperation.
May 29, 2007 at 3:58 PM
If you are using an older version of the DAAB ( 2.0 or earlier ), you need to make sure you are using the DAAB in EntLib 3.0. The RequirePermission Attribute is new to Enterprise Library 3.0 and a configuration error may occur when using older versions of the DAAB.

Regards,

Dave

_______________________________

David Hayden
Microsoft MVP C#
May 29, 2007 at 4:01 PM
If you are definitely using EntLib 3.x, what is the exception you are getting at runtime?

You may get schema related warnings in the IDE at design time if the configuration file is open, but just close the configuration file.

Regards,

Dave

_______________________________

David Hayden
Microsoft MVP C#
May 30, 2007 at 7:29 AM
Actually requirePermission is a .NET attribute, it isn't defined by EntLib. Also the EntLib installer doesn't make any modifications to machine.config. So I can't explain what could be causing this problem - maybe the app is trying to run under an older version of the CLR?

The path of least resistance may be just to remove the offending attribute from machine.config, although it would be more satisfying if we could figure out the root cause of the problem.

Tom
May 30, 2007 at 12:24 PM
Hello David Hayden,

Thank you for your fast reply and also for the solution. You are correct 100%.
Somehow, I was referencing the wrong dll's regarding the Enterprise Library 3.0 and 3.1.
As soon as I re-reference them in my project, everything worked fine!
Now I can get deeper into the EntLib's functionality because we should not re-invent the wheel.

I want to thank you again for your great help and also "codeplex" site that does a remarkable work
by helping us biginners with our first steps.

Sincerely,
Nikos Zacharakis