Orchard CMS Error “ValueFactory attempted to acces

2019-04-02 03:48发布

问题:

I I am using orchard 1.8.1 and try to install the theme Bootstrap and it gives me the following errors. Can anyone help me out? Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: ValueFactory attempted to access the Value property of this instance.

Line 61:         // Load the log4net thread with additional properties if they are available
Line 62:         protected internal void AddExtendedThreadInfo() {
Line 63:             if (_shellSettings.Value != null) {
Line 64:                 ThreadContext.Properties["Tenant"] = _shellSettings.Value.Name;
Line 65:             }

回答1:

Just found that it seems to work if, in OrchardLog4netLogger.cs, we replace

_shellSettings = new Lazy<ShellSettings>(LoadSettings);

With

_shellSettings = new Lazy<ShellSettings>(LoadSettings,
     System.Threading.LazyThreadSafetyMode.PublicationOnly);

Then, all threads are allowed to run the initialization method. The first thread to complete initialization sets the value of the Lazy instance