Orchard.Azure will not launch to localhost Compute Emulator

Topics: Installing Orchard, Troubleshooting
Sep 26, 2013 at 6:34 AM
I have cloned the source code for version 1.7.1 and I am trying to run the Orchard.Azure.Sln in localhost using the Azure Compute Emulator (v 2.1.0.0). Everything compiles however when it launches I get the following exception...

Does anyone know what is happening here?

-Tim
Server Error in '/' Application.

None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Orchard.Environment.DefaultOrchardShell' can be invoked with the available services and parameters:
Cannot resolve parameter 'Orchard.Mvc.Routes.IRoutePublisher routePublisher' of constructor 'Void .ctor(System.Func`1[Autofac.Features.OwnedInstances.Owned`1[Orchard.Environment.IOrchardShellEvents]], System.Collections.Generic.IEnumerable`1[Orchard.Mvc.Routes.IRouteProvider], System.Collections.Generic.IEnumerable`1[Orchard.WebApi.Routes.IHttpRouteProvider], Orchard.Mvc.Routes.IRoutePublisher, System.Collections.Generic.IEnumerable`1[Orchard.Mvc.ModelBinders.IModelBinderProvider], Orchard.Mvc.ModelBinders.IModelBinderPublisher, Orchard.Tasks.ISweepGenerator)'.

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: Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Orchard.Environment.DefaultOrchardShell' can be invoked with the available services and parameters:
Cannot resolve parameter 'Orchard.Mvc.Routes.IRoutePublisher routePublisher' of constructor 'Void .ctor(System.Func`1[Autofac.Features.OwnedInstances.Owned`1[Orchard.Environment.IOrchardShellEvents]], System.Collections.Generic.IEnumerable`1[Orchard.Mvc.Routes.IRouteProvider], System.Collections.Generic.IEnumerable`1[Orchard.WebApi.Routes.IHttpRouteProvider], Orchard.Mvc.Routes.IRoutePublisher, System.Collections.Generic.IEnumerable`1[Orchard.Mvc.ModelBinders.IModelBinderProvider], Orchard.Mvc.ModelBinders.IModelBinderPublisher, Orchard.Tasks.ISweepGenerator)'.

Source Error: 


Line 111:            var shellScope = _shellContainerFactory.CreateContainer(settings, blueprint);
Line 112:
Line 113:            return new ShellContext {
Line 114:                Settings = settings,
Line 115:                Descriptor = descriptor,

Source File: c:\orchardazure\src\Orchard\Environment\ShellBuilders\ShellContextFactory.cs    Line: 113 

Stack Trace: 


[DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Orchard.Environment.DefaultOrchardShell' can be invoked with the available services and parameters:
Cannot resolve parameter 'Orchard.Mvc.Routes.IRoutePublisher routePublisher' of constructor 'Void .ctor(System.Func`1[Autofac.Features.OwnedInstances.Owned`1[Orchard.Environment.IOrchardShellEvents]], System.Collections.Generic.IEnumerable`1[Orchard.Mvc.Routes.IRouteProvider], System.Collections.Generic.IEnumerable`1[Orchard.WebApi.Routes.IHttpRouteProvider], Orchard.Mvc.Routes.IRoutePublisher, System.Collections.Generic.IEnumerable`1[Orchard.Mvc.ModelBinders.IModelBinderProvider], Orchard.Mvc.ModelBinders.IModelBinderPublisher, Orchard.Tasks.ISweepGenerator)'.]
   Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Reflection\ReflectionActivator.cs:106
   Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:79
   Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Lifetime\LifetimeScope.cs:270
   Autofac.Core.Resolving.InstanceLookup.Execute() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:64
   Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:123
   Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Delegate\DelegateActivator.cs:69
   Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:79
   Autofac.Core.Resolving.InstanceLookup.Execute() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:62
   Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:123
   Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:94
   Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Lifetime\LifetimeScope.cs:232
   Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\ResolutionExtensions.cs:346
   Autofac.ResolutionExtensions.Resolve(IComponentContext context, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\ResolutionExtensions.cs:197
   Orchard.Environment.ShellBuilders.ShellContextFactory.CreateSetupContext(ShellSettings settings) in c:\orchardazure\src\Orchard\Environment\ShellBuilders\ShellContextFactory.cs:113
   Orchard.Environment.DefaultOrchardHost.CreateSetupContext() in c:\orchardazure\src\Orchard\Environment\DefaultOrchardHost.cs:167
   Orchard.Environment.DefaultOrchardHost.CreateAndActivateShells() in c:\orchardazure\src\Orchard\Environment\DefaultOrchardHost.cs:143
   Orchard.Environment.DefaultOrchardHost.BuildCurrent() in c:\orchardazure\src\Orchard\Environment\DefaultOrchardHost.cs:103
   Orchard.Environment.DefaultOrchardHost.Orchard.Environment.IOrchardHost.Initialize() in c:\orchardazure\src\Orchard\Environment\DefaultOrchardHost.cs:67
   Orchard.Azure.Web.MvcApplication.Application_Start() in c:\orchardazure\src\Orchard.Azure\Orchard.Azure.Web\Global.asax.cs:36

[HttpException (0x80004005): None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Orchard.Environment.DefaultOrchardShell' can be invoked with the available services and parameters:
Cannot resolve parameter 'Orchard.Mvc.Routes.IRoutePublisher routePublisher' of constructor 'Void .ctor(System.Func`1[Autofac.Features.OwnedInstances.Owned`1[Orchard.Environment.IOrchardShellEvents]], System.Collections.Generic.IEnumerable`1[Orchard.Mvc.Routes.IRouteProvider], System.Collections.Generic.IEnumerable`1[Orchard.WebApi.Routes.IHttpRouteProvider], Orchard.Mvc.Routes.IRoutePublisher, System.Collections.Generic.IEnumerable`1[Orchard.Mvc.ModelBinders.IModelBinderProvider], Orchard.Mvc.ModelBinders.IModelBinderPublisher, Orchard.Tasks.ISweepGenerator)'.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12938589
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

[HttpException (0x80004005): None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Orchard.Environment.DefaultOrchardShell' can be invoked with the available services and parameters:
Cannot resolve parameter 'Orchard.Mvc.Routes.IRoutePublisher routePublisher' of constructor 'Void .ctor(System.Func`1[Autofac.Features.OwnedInstances.Owned`1[Orchard.Environment.IOrchardShellEvents]], System.Collections.Generic.IEnumerable`1[Orchard.Mvc.Routes.IRouteProvider], System.Collections.Generic.IEnumerable`1[Orchard.WebApi.Routes.IHttpRouteProvider], Orchard.Mvc.Routes.IRoutePublisher, System.Collections.Generic.IEnumerable`1[Orchard.Mvc.ModelBinders.IModelBinderProvider], Orchard.Mvc.ModelBinders.IModelBinderPublisher, Orchard.Tasks.ISweepGenerator)'.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12955596
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12794333

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18213
Coordinator
Sep 27, 2013 at 5:50 PM
/you can't run the solution on the azure emulator right now
Sep 27, 2013 at 8:26 PM
Got it.

Too bad. This would really help the efficiency of writing add on modules targeting Azure.

Just curious if there is a priority to get this working or if its lower on the list?

Its an odd error. Not sure why the Azure Compute Emulator would effect Autofac Dependency Resolution.

-Tim
Coordinator
Sep 28, 2013 at 12:21 AM
Try to locate the folder where the emulator is running from them check which files are missing, This could help us understand what needs to be handled during the build for this matter.

What kind of Azure feature are you trying to implement ? Curious and also would like to share effort or not duplicate it actually.
Oct 16, 2013 at 4:30 PM
Edited Oct 16, 2013 at 4:32 PM
It seems the following files are missing from the bin folder, although I'm not sure all of them are required for the Azure emulator:

Orchard.WarmupStarter.dll
Orchard.Web.dll
MySql.Data.dll
amd64*
x86*
Oct 17, 2013 at 7:12 PM
The problem is that the emulator doesn't run of the cspack file (the package file deployed to azure)

The emulator just mounts the Orchard.Azure.Web project.

This project is mostly an empty project, no Modules or Themes are below this project.
In the cspack script, the modules and themes are copied to the package, so the same has te be done for debugging?

Maybe this worked in older Orchard versions, because the .proj files have changed?
Oct 28, 2013 at 2:29 PM
Hi,

I have cloned a copy of the master branch (commit 58c2181522b1).
I have found that by copying the following folders from Orchard.Web project to the Orchard.Azure.Web allows to run Orchard in Azure emulator:
Core\
Media\
Modules\
Themes\
After this everything runs fine and I am able to debug the project from Visual Studio (quite slow, however).

Is it possible to merge projects Orchard.Web.csproj and Orchard.Azure.Web.csproj and build different versions based on solution configuration? For example Debug would build an usual MVC Web App, while DebugAzure would build an Azure Web App. Similar approach is used in the SharpDX project where the same csproj is built for several platforms at once depending on solution configuration.

I've tried to this myself, but didn't sorted yet all differences - as the Orchard.Azure.Web seems to reference same assemblies with different versions (as it is, for example, with the System.Web.WebPages.Deployment assembly - for Orchard.Web it is 2.0.0.0 and for Orchard.Azure.Web it is 1.0.0.0). Also they have quite significant configuration differences.

Does someone have any ideas? Maybe something is already done in this area?
Developer
Oct 28, 2013 at 9:30 PM
I have toyed with the idea of one day moving the Orchard.Web and Orchard.Azure.Web into the same folder, whereby they could both publish the Core, Media, Modules and Themes subfolder contents in the same way. But the problem is Web.config, as you say it differs substantially between the two. It could be handled using transformations, but then we would need two Azure specific build configurations and I think that gets plain ugly.

Honestly, now that Microsoft has introduced live remote debugging against a deployed cloud service (including edit-and-continue) with Windows Azure SDK 2.2, I don't see much purpose for the local compute emulator anymore. It seems much more sensible to quickly publish to a new cloud service and debug there with full fidelity, rather than mess with all the limitations and differences of the local compute emulator.

I'm going to try and upgrade Orchard to Windows Azure SDK 2.2 soon, and after that I don't really see the point in jumping through hoops to get the local compute emulator stuff to work. In fact, my guess is the emulator is actually being removed from the SDK.
Oct 28, 2013 at 10:15 PM
Edited Oct 28, 2013 at 10:18 PM
Great Jumping 2.2, thanks for all your work


local compute emulator is very usefull when you have no internet connection and this is a really interesting feature I appreciate for my non Orchard WebRole projects and would like to have with Orchard
Mar 20 at 10:51 AM
i would appreciate having orchard running in a local compute emulator, i'm exploring deploying orchard to azure and would like to mess around and understand the source more before i proceed.
Apr 24 at 4:21 PM
The easy solution is to update the project file so I copies the folders listed above whenever you do a Debug build, I added the following targets to my Orchard.Azure.Web.csproj

<Target Name="DeleteDebugFiles" AfterTargets="AfterBuild">
<RemoveDir Directories="Themes;Core;Modules" />
</Target>

<Target Name="CopyDebugFiles" AfterTargets="DeleteDebugFiles" Condition="'$(Configuration)' == 'Debug'">
<PropertyGroup>
  <SrcFolder>..\..</SrcFolder>
</PropertyGroup>
<ItemGroup>
  <Excluded Include="$(SrcFolder)\**\bin\**\*;$(SrcFolder)\**\obj\**\*;$(SrcFolder)\**\*.user;$(SrcFolder)\**\*.cs;$(SrcFolder)\**\*.csproj;$(SrcFolder)\**\.hg\**\*" />
  <Src-Themes Include="$(SrcFolder)\Orchard.Web\Themes\**\*" Exclude="@(Excluded)" />
  <Src-Core Include="$(SrcFolder)\Orchard.Web\Core\**\*" Exclude="@(Excluded)" />
  <Src-Modules Include="$(SrcFolder)\Orchard.Web\Modules\**\*" Exclude="@(Excluded)" />
</ItemGroup>

<Copy SourceFiles="@(Src-Themes)" DestinationFolder="Themes\%(RecursiveDir)" />
<Copy SourceFiles="@(Src-Core)" DestinationFolder="Core\%(RecursiveDir)" />
<Copy SourceFiles="@(Src-Modules)" DestinationFolder="Modules\%(RecursiveDir)" />
</Target>