This project is read-only.

Orchard fails startup with error : Could not load type 'System.Net.Http.Formatting.DefaultContentNegotiator'

Topics: Installing Orchard, Troubleshooting
Apr 2, 2013 at 8:50 PM
I've installed Orchard successfully once in the past. This time the simple steps haven't worked and I'm getting an error.

Here's what I've done:
  1. Unzip the archive into a directory
  2. Point my local IIS 7 (on windows 7) to the directory as a site with a host header.
  3. Set the AppPool to ASP.NET 4.0, Integrated.
  4. Update my hosts file to point my local domain (which does match the host header) to
  5. Point a browser at that domain.
The error I'm receiving is:

Could not load type 'System.Net.Http.Formatting.DefaultContentNegotiator' from assembly 'System.Net.Http.Formatting, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

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.TypeLoadException: Could not load type 'System.Net.Http.Formatting.DefaultContentNegotiator' from assembly 'System.Net.Http.Formatting, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[TypeLoadException: Could not load type 'System.Net.Http.Formatting.DefaultContentNegotiator' from assembly 'System.Net.Http.Formatting, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
System.Web.Http.Services.DefaultServices..ctor(HttpConfiguration configuration) +0
System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection routes) +408
System.Web.Http.GlobalConfiguration.<.cctor>b__0() +93
System.Lazy1.CreateValue() +455
System.Web.Http.GlobalConfiguration.get_Configuration() +165
1 registrations) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Environment\OrchardStarter.cs:148
Orchard.Web.MvcApplication.HostInitialization(HttpApplication application) in c:\Users\sebros\My Projects\Orchard\src\Orchard.Web\Global.asax.cs:48
Orchard.WarmupStarter.<>c__DisplayClass3.<LaunchStartupThread>b__2(Object state) in c:\Users\sebros\My Projects\Orchard\src\Orchard.WarmupStarter\Starter.cs:89

[ApplicationException: Error during application initialization]
Orchard.WarmupStarter.Starter`1.OnBeginRequest(HttpApplication application) in c:\Users\sebros\My Projects\Orchard\src\Orchard.WarmupStarter\Starter.cs:63

[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) +229
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +193
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +35
System.Web.Util.ArglessEventHandlerProxy.Callback(Object sender, EventArgs e) +74
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

Any help would be greatly appreciated!
Apr 2, 2013 at 10:00 PM
Edited Apr 2, 2013 at 10:01 PM
Ok, I'm getting closer. It seems there is a copy of the System.Net.Http.Formatting dll in the GAC which does not have the DefaultContentNegotiator class. The two versions are signed the same with the same version (v. so the GAC version is being referenced by the application.

I guess I'm down to finding out which version is newer, and if I can update the GAC version.
Apr 2, 2013 at 10:06 PM
I uninstalled the problem dll from the GAC and Orchard loaded just fine.

Wonder what else I broke though. :-S