By “because for both NH need an instance before anything else”, I guess your 
point is that the two system properties should always be defined in web.config, 
such that the ConfigurationManager.GetSection call from the Configuration 
constructor will pick them up before user code calls any of the 
Configuration.Configure() method overloads. Off course one could also use the 
setters on Environment before new’ing up the Configuration object.

 

Also by having the web.config you defined below, NH throws 
NullReferenceException in the static Environment ctor when calling 
LoadGlobalPropertiesFromAppConfig because on line 215 when foreach’ing over the 
Properties of the SessionFactory property, that property will be null. 

 

It should be

 

if (nhConfig.SessionFactory != null)

{

                      foreach (KeyValuePair<string, string> kvp in 
nhConfig.SessionFactory.Properties)

                      {

                                            GlobalProperties[kvp.Key] = 
kvp.Value;

                      }

}

 

/Maxild

 

  _____  

From: [email protected] [mailto:[email protected]] On Behalf Of 
Fabio Maulo
Sent: Friday, April 24, 2009 4:33 PM
To: [email protected]
Subject: [nhusers] Re: bytecode-provider and reflection-optimizer properties 
ignored from config file?

 

the answer to your question is above the question itself.

btw....

In web.config

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">

                    <bytecode-provider type="lcg"/>

                    <reflection-optimizer use="false"/>

</hibernate-configuration>

 

Then you can have the hibernate.cfg.xml in somewhere else.

 

 

2009/4/24 Morten Maxild <[email protected]>

 

You can read the log file is you set log for WARN.

 

Done that allready:-)

 

Btw the two properties are available only in web.config file (you can use both 
web.config and external file config).

Why ? because for both NH need an instance before anything else.

 

What I don’t understand is this: If I use web.config I can disable the 
reflection-optimizer, and everything works. If I use hibernate.cfg.xml file the 
two system properties are ignored, and entries are written to the log file for 
WARN. Why this difference depending on if I use a section handler in web.config 
or an external xml config?

 

Don't forget to take a look to ProxyGenerator project.

http://nhforge.org/wikis/proxygenerators10/default.aspx

I am all ready using NHPG.exe. I even got it working with fluent nhibernate 
PersistenceModel/ClassMap mappings, but that is a story for a patch to NHContrib

2009/4/22 Morten Maxild <[email protected]>

Hi,

 

I am trying to get NH to run in medium trust and would like disable the 
reflection-optimizer and bytecode-provider. But the two system properties are 
ignored when reading the config file, and warnings are written to log4net. I 
can see this was done back in R2923.

 

 What are the reasons for ignoring the system properties? And is it possible 
and correct to programmatically do something like this?

 

<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >

<!-- Important under Medium Trust, I guess??? -->

                      <bytecode-provider type="null"/> 

                      <reflection-optimizer use="false" /> 

…..

 

BTW I am running on the trunk R4174.

 

Kind regards

Maxild

 

 




-- 
Fabio Maulo

 

 

 




-- 
Fabio Maulo




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to