Ticket Q554890
Visible to All Users

The "Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0 ...'" error message is thrown in Visual Studio 2012

created 11 years ago

Hi DevExpress Team,

I have created a sample web MVC project
according to your wizard. But it seems that it cannot work out. The VS
is always telling me:<italic>Could not load file or assembly
'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The located
 assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040).

I have deleted the bin and obj folder, rebuilt the project like a thousand times, but the error is the same. So could you please help me with this? Please find the sample project in the attachment.

</italic>Here is the stack trace:

C#
[FileLoadException: Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start() +0 [InvalidOperationException: The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).] System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +550 System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +90 System.Web.Compilation.BuildManager.ExecutePreAppStart() +135 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516 [HttpException (0x80004005): The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874840 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Show previous comments (1)

    Hi Helen,

    Thanks for your reply. I think I do not recall any changes to the settings or something else. I used the windows logging tool, it shows that the vs is looking for something older. In my reference, the DotNetOpenAuth is of version 4.1.XXX, not 4.0.0.0. I do not know why it is looking for this old version. In the root web.config, I have added the following code, but the result is the same…
    <dependentAssembly>
      <assemblyIdentity name="DotNetOpenAuth.AspNet"
                        publicKeyToken="2780ccd10d57b246"
                        culture="neutral" />
      <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="DotNetOpenAuth.Core"
                        publicKeyToken="2780ccd10d57b246"
                        culture="neutral" />
      <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
    </dependentAssembly>
    I have also tried to use NuGet uninstall the DotNetOpenAuth and reinstall it, still does not work out. I just do not know why the vs is looking for this old version. Do you have any idea how this works?
    In the end, in order to make it running, I have to deleted all the code and reference refers to the DotNetOpenAuth…Then it works fine.
    BTW, can you open my sample project correctly?
    Here is the Log in the attachment.

    Artem (DevExpress Support) 11 years ago

      Hello Spencer,
      The cause of this problem is described in the context of the DotNetOpenAuth.Asp Couldnt Load Assembly or one of its dependencies and The located assembly's manifest definition does not match the assembly reference articles.
      I believe that the best solution is to place necessary assemblies in GAC and change assembly references manually to avoid these problems. I haven't managed to run your project since I don't have the required versions on my computer. However, if I create a new project, correct versions are specified in the pakages.config file on my side. Would you please make a screencast that demonstrates how you create this project (for example, using the Jing Tool)?

      CS CS
      Cadiou Sylvain (Imagine-Editions) 11 years ago

        Hello Artem,
        I'm facing the same issue of Spencer. You could find the video describing this problem in attachement.
        Regards
        Sylvain

        Answers approved by DevExpress Support

        created 11 years ago (modified 11 years ago)

        Hello,
        Thank you for this report. We found that if the newer package is already loaded on your computer, this problem may occur. There are two ways to solve this problem:

        1. Uninstall previous libraries.
        2. Override bindings in the following manner (for the new version 4.1.):
        XML
        <dependentAssembly> <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780CCD10D57B246" culture="neutral" /> <bindingRedirect oldVersion="1.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780CCD10D57B246" culture="neutral" /> <bindingRedirect oldVersion="1.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> </dependentAssembly> </assemblyBinding>

        I've attached a project that demonstrates the second approach.
        I hope this information will help you.

          Show previous comments (2)
          Artem (DevExpress Support) 11 years ago

            Hello,
            I believe the problem may occur if you didn't change a version in the package.config file and didn't update references. I've tried your approach based on these notes, and everything works correctly on my side (see the attached video).
            I've attached a modified project that also works with the DotNetOpenAuth library version 4.3.4.13329.

              I personally tried this but found for one reason or another I have 4.1.0.0 and didn't realize it until I checked the properties on the References. I modified the version from 4.3 to 4.1 and voila it worked.

              Artem (DevExpress Support) 11 years ago

                Hello John,

                I am happy to hear that this solution has helped you. If you created an MVC4 project based on our template, this should be fixed in the context of the    "Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0 …'" error is thrown in VS 2013 when running a project if it's created based on MVC4 DevExpress project template thread.

                Let me know if you need further clarification on this issue.

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.