Could not load file or assembly 'Autofac, Version=3.0.0.0 after install of Autofac.WCF

0

I receive the exception, if i do the following steps:

Test 1:

MainApp-Project:

  1. Added Nuget Package Autofac Version 4.5.0
  2. Added Nuget Package Autofac.WCF Version 4.0

Module-Project:

  1. Added Nuget Package Autofac.WCF Version 4.0 (Autofac 3.3.1 will be installed automatically)
  2. Updated via Nuget Manager Autofac to 4.5.0 During Moduleload via Directorycatalog, then the bootstrapper of the MainApp throws this exception.

Autofac.WCF has the dependencies Autofac >=3.3.1 && < 5.0.0

Exception in Bootstrapper.cs: An unhandled exception of type 'System.IO.FileLoadException' occurred in Prism.Wpf.dll

Additional information: Die Datei oder Assembly "Autofac, Version=3.3.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da" oder eine Abhängigkeit davon wurde nicht gefunden. Eine bestimmte Datei konnte nicht gefunden oder geladen werden. (Ausnahme von HRESULT: 0x80131621)

Test 2:

I tried these steps too:

MainApp:

  1. Install Autofac 4.5.0 with nuget manager
  2. Install Autofac.WCF with nuget manager

Module:

  1. Install Autofac 4.5.0 with nuget manager
  2. Install Autofac.WCF with nuget manager

Could be possible, that I do a mistake, because i use Autofac and Autofac.WCF for the first time. I used before unity IoC.

Bootstrapper.cs:

using Autofac;
using Prism.Autofac;
using PrismAutofacApp2.Views;
using System.Windows;
using Prism.Modularity;

namespace PrismAutofacApp2
{
    class Bootstrapper : AutofacBootstrapper
    {
        protected override DependencyObject CreateShell()
        {
            return Container.Resolve<MainWindow>();
        }

        protected override void InitializeShell()
        {
            Application.Current.MainWindow.Show();
        }

        protected override IModuleCatalog CreateModuleCatalog()
        {
            var modulecatalog = new DirectoryModuleCatalog() { ModulePath = @".\Modules" };

            return modulecatalog;
        }

    }
}

Module:

using Prism.Modularity;
using Prism.Regions;
using System;
using Autofac;


namespace PrismModule2
{
    public class PrismModule2Module : Module
    {
        IRegionManager _regionManager;

        public PrismModule2Module(IRegionManager regionManager)
        {
            _regionManager = regionManager;
        }
    }
}

Update

I uninstalled as requested in comment the packages and then I reinstalled everything with the mentioned steps under Test 2., the problem still keeps.

If I deactived the module load by remove the overide method CreateModulecatalog, then the problem doesnt occures not anymore, means Autofac 4.5.0 + Autofac.WCF 4.0.0 in the MainApp works, but not if i load the module (incl. Autofac 4.5.0 and Autofac.WCF) with the CreateModulecatalog Autofac 4.5.0 and Autofac.WCF.

Please keep in mind the Module has no app.config, because is a module (dll) project.

Is very importend for me to get a project to run with the following requirements:

MainApp:

  1. Autofac 4.5.0 + Autofac.WCF 4.0.0 + Prism.WPF
  2. Modules shall be loaded from directory
  3. MainApp starts a executable

Modules:

  1. Autofac 4.5.0 + Autofac.WCF 4.0.0 (namedpipe) + Prism.WPF
  2. The Modules must host the WCF service, because the mainapp starts a executable and these executable has to consum the wcf service + ioc.

Everything is blocked for me, because is not possible to load the module with autofac + autofac.wcf without exception in the mainapp (bootstrapper).

If somebody can support me, then I'm able to setup a teamviewer session with shared desktop to solve my issue and to give me guidance.

autofac
autofac-module
asked on Stack Overflow May 11, 2017 by Shazter • edited May 12, 2017 by Shazter

2 Answers

1

I solved with these steps:

My Module:

  1. Removed Autofac + Autofac.WCF with nuget package manager in my module
  2. Installed Autofac 4.5.0 with nuget package manager in my module
  3. Download Autofac.WCF Sourcecode
  4. Open the solution
  5. Removed the entry for the autofac reference
  6. Load Autofac 4.5.0 via nuget package manager
  7. Build Release of Autofac.WCF Project
  8. Copy the DLL to my module and made the reference
answered on Stack Overflow May 12, 2017 by Shazter
0

I did what Shazter recommended. I went to the GitHub link and downloaded the source. Once loaded up I removed the default Autofac that gets restored by NuGet. I then added the latest Autofac through NuGet and rebuilt a release version. I then referenced my new dll and no more problem.

answered on Stack Overflow May 15, 2017 by Geens

User contributions licensed under CC BY-SA 3.0