install new theme

Topics: Administration, Announcements, Core, Customizing Orchard, General, Installing Orchard, Localization
Jan 12, 2015 at 7:13 AM
Hi, I I am using orchard 1.8.1 and try to install the theme Teched - 1.0.0 and it gives me the following error. Can any one help me please?
ValueFactory attempted to access the Value property of this instance.

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.

Source Error: 


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:             }

Source File: c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Logging\OrchardLog4netLogger.cs    Line: 63 

Stack Trace: 


[InvalidOperationException: ValueFactory attempted to access the Value property of this instance.]
   System.Lazy`1.CreateValue() +416
   System.Lazy`1.LazyInitValue() +152
   System.Lazy`1.get_Value() +75
   Orchard.Logging.OrchardLog4netLogger.AddExtendedThreadInfo() in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Logging\OrchardLog4netLogger.cs:63
   Orchard.Logging.OrchardLog4netLogger.Error(String message, Exception exception) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Logging\OrchardLog4netLogger.cs:175
   Orchard.Logging.CastleLogger.Log(LogLevel level, Exception exception, String format, Object[] args) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Logging\CastleLogger.cs:45
   Orchard.Logging.LoggingExtensions.FilteredLog(ILogger logger, LogLevel level, Exception exception, String format, Object[] objects) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Logging\LoggingExtensions.cs:71
   Orchard.Logging.LoggingExtensions.Error(ILogger logger, Exception exception, String message) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Logging\LoggingExtensions.cs:31
   Orchard.Environment.DefaultOrchardHost.<CreateAndActivateShells>b__7(ShellSettings settings) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Environment\DefaultOrchardHost.cs:139
   System.Threading.Tasks.<>c__DisplayClass21`2.<ForEachWorker>b__17(Int32 i) +22
   System.Threading.Tasks.<>c__DisplayClassf`1.<ForWorker>b__c() +910
   System.Threading.Tasks.Task.InnerInvoke() +72
   System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask) +17
   System.Threading.Tasks.<>c__DisplayClass10.<ExecuteSelfReplicating>b__f(Object param0) +208

[AggregateException: One or more errors occurred.]
   System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) +3548265
   System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) +10487717
   System.Threading.Tasks.Task.Wait() +10
   System.Threading.Tasks.Parallel.ForWorker(Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally) +925
   System.Threading.Tasks.Parallel.ForEachWorker(TSource[] array, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally) +216
   System.Threading.Tasks.Parallel.ForEachWorker(IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally) +146
   System.Threading.Tasks.Parallel.ForEach(IEnumerable`1 source, Action`1 body) +110
   Orchard.Environment.DefaultOrchardHost.CreateAndActivateShells() in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Environment\DefaultOrchardHost.cs:133
   Orchard.Environment.DefaultOrchardHost.BuildCurrent() in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Environment\DefaultOrchardHost.cs:106
   Orchard.Environment.DefaultOrchardHost.GetShellContext(ShellSettings shellSettings) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Environment\DefaultOrchardHost.cs:65
   Orchard.Logging.OrchardLog4netLogger.LoadSettings() in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Logging\OrchardLog4netLogger.cs:53
   System.Lazy`1.CreateValue() +180
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +22
   System.Lazy`1.get_Value() +10749357
   Orchard.Logging.OrchardLog4netLogger.AddExtendedThreadInfo() in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Logging\OrchardLog4netLogger.cs:63
   Orchard.Logging.OrchardLog4netLogger.Error(String message, Exception exception) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Logging\OrchardLog4netLogger.cs:175
   Orchard.Logging.CastleLogger.Log(LogLevel level, Exception exception, String format, Object[] args) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Logging\CastleLogger.cs:45
   Orchard.Logging.LoggingExtensions.FilteredLog(ILogger logger, LogLevel level, Exception exception, String format, Object[] objects) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Logging\LoggingExtensions.cs:71
   Orchard.Logging.LoggingExtensions.Error(ILogger logger, Exception exception, String message) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Logging\LoggingExtensions.cs:31
   Orchard.Environment.DefaultOrchardHost.<CreateAndActivateShells>b__7(ShellSettings settings) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Environment\DefaultOrchardHost.cs:139
   System.Threading.Tasks.<>c__DisplayClass21`2.<ForEachWorker>b__17(Int32 i) +22
   System.Threading.Tasks.<>c__DisplayClassf`1.<ForWorker>b__c() +910
   System.Threading.Tasks.Task.InnerInvoke() +72
   System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask) +17
   System.Threading.Tasks.<>c__DisplayClass10.<ExecuteSelfReplicating>b__f(Object param0) +208

[AggregateException: One or more errors occurred.]
   System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) +3548265
   System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) +10487717
   System.Threading.Tasks.Task.Wait() +10
   System.Threading.Tasks.Parallel.ForWorker(Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally) +925
   System.Threading.Tasks.Parallel.ForEachWorker(TSource[] array, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally) +216
   System.Threading.Tasks.Parallel.ForEachWorker(IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally) +146
   System.Threading.Tasks.Parallel.ForEach(IEnumerable`1 source, Action`1 body) +110
   Orchard.Environment.DefaultOrchardHost.CreateAndActivateShells() in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Environment\DefaultOrchardHost.cs:133
   Orchard.Environment.DefaultOrchardHost.BuildCurrent() in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Environment\DefaultOrchardHost.cs:106
   Orchard.Environment.DefaultOrchardHost.BeginRequest() in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Environment\DefaultOrchardHost.cs:229
   Orchard.Environment.DefaultOrchardHost.Orchard.Environment.IOrchardHost.BeginRequest() in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard\Environment\DefaultOrchardHost.cs:80
   Orchard.Web.MvcApplication.HostBeginRequest(HttpApplication application, IOrchardHost host) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard.Web\Global.asax.cs:38
   Orchard.WarmupStarter.Starter`1.OnBeginRequest(HttpApplication application) in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard.WarmupStarter\Starter.cs:68
   Orchard.Web.MvcApplication.Application_BeginRequest() in c:\inetpub\wwwroot\MyOrchard.Source.1.8.1\src\Orchard.Web\Global.asax.cs:29

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +192
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +108
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19
   System.Web.Util.ArglessEventHandlerProxy.Callback(Object sender, EventArgs e) +56
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
Jan 13, 2015 at 7:24 AM
Edited Jan 14, 2015 at 4:00 AM
I could repro your issue with different themes installations

Note: Here, I talk about themes that contain some code (e.g if they have a *.csproj file) and aren't precompiled (no bin folder), so, they need to be dynamically compiled on startup

Your issue happens when you have some themes installed that fail on startup. You can see that in your App_Data/logs/*.log file, if you have something like that: No suitable loader found for extension "TheThemeName". The workaround is to disable these themes. If you don't need them, you can also uninstall them, but remember to disable them before

Note that when you select a theme, you don't disable the previous one. So, even it's not the current one, it can fail again on startup. Be aware also that if it suceeds to load, even it's not the current one, some code can run (Migrations, Filtering...). It's not always desired. When a theme is installed, it's not enabled. When you select a theme, it's enabled and set as current. When you select another theme, if you don't need the previous one, my advice is to disable it

If you have the full source code, it' better to download a theme and integrate it in your solution. Then, you can compile and see if all is ok. Maybe, you will have to update the .net version, some dll or project references... Otherwise, check your log files

So, I think it's a multi threading issue if the logger is used when the app restarts itself. So, if you have a theme that fail on startup (I think it's the same with a module or any other starting failure), then you will have your issue when you install a new theme (because the app restart itself). The workaround is to disable the failing theme (or module...)

Regards
Jan 13, 2015 at 8:41 AM
Edited Jan 13, 2015 at 8:46 AM
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<T> instance... (see msdn doc)

Needs to be validated...

Regards