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

I receive the exception, if i do the following steps:
Test 1:
MainApp-Project:
Added Nuget Package Autofac Version 4.5.0
Added Nuget Package Autofac.WCF Version 4.0
Module-Project:
Added Nuget Package Autofac.WCF Version 4.0 (Autofac 3.3.1 will be installed automatically)
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:
Install Autofac 4.5.0 with nuget manager
Install Autofac.WCF with nuget manager
Module:
Install Autofac 4.5.0 with nuget manager
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:
Autofac 4.5.0 + Autofac.WCF 4.0.0 + Prism.WPF
Modules shall be loaded from directory
MainApp starts a executable
Modules:
Autofac 4.5.0 + Autofac.WCF 4.0.0 (namedpipe) + Prism.WPF
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.

I solved with these steps:
My Module:
Removed Autofac + Autofac.WCF with nuget package manager in my module
Installed Autofac 4.5.0 with nuget package manager in my module
Download Autofac.WCF Sourcecode
Open the solution
Removed the entry for the autofac reference
Load Autofac 4.5.0 via nuget package manager
Build Release of Autofac.WCF Project
Copy the DLL to my module and made the reference

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.

Related

Cannot upgrade Ninject to latest version in Nuget

I have a ASP.NET WebForms application that uses some Ninject packages, but I am stuck at a certain version. When I try to upgrade to the latest version, I get "Unable to resolve dependencies" issues.
The packages in question are:
Package InstalledVer LatestVer
------------------------------------------------------
Ninject v3.2.2 v3.3.4
Ninject.Web v3.2.1 ✔ v3.2.1
Ninject.Web.Common v3.2.3 v3.3.1
Ninject.Web.Common.WebHost v3.2.3 v3.3.1
If I try updating Ninject, I get:
Unable to resolve dependencies. 'Ninject 3.3.4' is not compatible with
'Ninject.Web 3.2.1 constraint: Ninject (>= 3.2.0 && < 3.3.0)'
but Ninject.Web is already at the latest version!
Should I change the Dependency behaviour of Ninject.Web or would this be unsafe? If I do, what should I change the Dependency behavior to?
Thanks
Okay, so this is how to fix:
Remove the Ninject.Web package completely. This package is no longer required as it is now integrated into Ninject.Web.Common (well, version v3.3+ anyway)
Update the packages Ninject, Ninject.Web.Common and Ninject.Web.Common.WebHost. These should now upgrade okay. For me, they are both v3.3.1.
As part of the package upgrade a new file App_Start\Ninject.Web.Common.cs will have been added. This is just a rename of the existing App_Start\NinjectWeb.Common.cs so either [a] delete the new file or [b] migrate over your Ninject module registrations and remove the old file.
In web.config, you should now remove the OnePerRequestModule module:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="OnePerRequestModule" type="Ninject.Web.Common.OnePerRequestHttpModule" />
</modules>
</system.webServer>
This is because this module, is registered dynamically on loadup in the App_Start\Ninject.Web.Common.cs file's Start() method:
public static void Start()
{
DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
bootstrapper.Initialize(CreateKernel);
}
If you don't remove this entry from web.config then you can expect a type exception when launching your application, not least because as part of the version update, the class has moved from the Ninject.Web.Common namespace to Ninject.Web.Common.WebHost.
You can also remove the file App_Start\NinjectWeb.cs for the same reason (registering NinjectHttpModule)
If OnePerRequestHttpModule doesn't resolve in App_Start\Ninject.Web.Common.cs then add the following using statement to the file using Ninject.Web.Common.WebHost; (I think this is a missing reference in v3.3.1 of the package.
Hope this helps others.

.NET Core Azure Function missing reference

I've added a Nuget-package to my .NET Core "Azure Function"-project:
Install-Package SharePointPnPCoreOnline -Version 2.22.1801
But I receive an error in my code:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception
while executing function: StoreInDatabase --->
System.IO.FileNotFoundException : Could not load file or assembly
'SharePointPnP.IdentityModel.Extensions, Version=1.2.3.0,
Culture=neutral, PublicKeyToken=5e633289e95c321a' or one of its
dependencies. The system cannot find the file specified.
This assembly should be included from the Nuget Package, but it doesn't.
As I'm new to .NET Core and Azure Functions, does anyone know how to solve this one?
Update
I see the package has another version number than in the error-details.
But still no idea how to solve this... any ideas?
Looking at the nuget package with the wrong version number, I saw that previous versions are "hidden" in NuGet...
https://www.nuget.org/packages/SharePointPnP.IdentityModel.Extensions/
I solved this by installing the latest version of the package
So in my case, I just ran the command:
Install-Package SharePointPnP.IdentityModel.Extensions -Version 1.2.3

nuget package is not compatible with netcoreapp2.0

I created nuget package yet while
PS C:\Users\vicky\Documents\ThreadBasedJobQueue\Testnuget> dotnet add package abhi.TaskQueueLib --version 1.0.0
Writing C:\Users\vicky\AppData\Local\Temp\tmp44DF.tmp
info : Adding PackageReference for package 'abhi.TaskQueueLib' into project 'C:\Users\vicky\Documents\ThreadBasedJobQueue\Testnuget\Tes
tnuget.csproj'.
log : Restoring packages for C:\Users\vicky\Documents\ThreadBasedJobQueue\Testnuget\Testnuget.csproj...
info : GET https://api.nuget.org/v3-flatcontainer/abhi.taskqueuelib/index.json
info : OK https://api.nuget.org/v3-flatcontainer/abhi.taskqueuelib/index.json 1139ms
info : GET https://api.nuget.org/v3-flatcontainer/abhi.taskqueuelib/1.0.0/abhi.taskqueuelib.1.0.0.nupkg
info : OK https://api.nuget.org/v3-flatcontainer/abhi.taskqueuelib/1.0.0/abhi.taskqueuelib.1.0.0.nupkg 1424ms
log : Installing abhi.TaskQueueLib 1.0.0.
error: Package abhi.TaskQueueLib 1.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package abhi.TaskQueueLib 1.0.0
supports: root (Root,Version=v0.0)
error: Package 'abhi.TaskQueueLib' is incompatible with 'all' frameworks in project 'C:\Users\vicky\Documents\ThreadBasedJobQueue\Testn
uget\Testnuget.csproj'.
The following documentation has the answers you are seeking:
https://learn.microsoft.com/en-us/nuget/create-packages/supporting-multiple-target-frameworks
Irrespective of whether you target one framework or multiple frameworks, you should create the ‘framework’ folder under the lib directory and then put the dll into that framework folder. This folder for the target framework is called Target Framework Moniker or TFM in short. List of all the allowed TFMs for NuGet is captured here:
https://learn.microsoft.com/en-us/nuget/schema/target-frameworks#supported-frameworks
Found the issue in lib folder i had to make folder by framework Name and then had to pack.
Un knowing i was keeping my Dll in Lib Folder
please refer https://learn.microsoft.com/en-us/nuget/create-packages/creating-a-package

Unable to connect to MySQL on ASP.Net Core 2.0

I created a new Asp.Net core 2.0 project, added MySql.Data
When I try:
mySqlConnection.Open();
then this exception occurs:
An unhandled exception occurred while processing the request.
FileNotFoundException: Could not load file or assembly 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. O sistema não pode encontrar o arquivo especificado.
MySql.Data.MySqlClient.MySqlConnectAttrs.get_OSDetails()
TargetInvocationException: Exception has been thrown by the target of an invocation.
System.RuntimeMethodHandle.InvokeMethod(object target, Object[] arguments, Signature sig, bool constructor)
I searched and did not find System.Management on NuGet for ASP.Net Core.
Also on the Dependencies (References),
This shows on:
Package 'MySql.Data.6.9.9' was restored using
'.NETFramework,Version=v4.6.1' instead of the project target framework
'.NETCoreApp,Version=v2.0'. This package may not be fully compatible
with your project.
How to connect to MySQL using Nuget on this situation?
For the .net core only the pre-release nugets work. As of now the latest version is 8.0.8-dmr. To access these you can either check the "include prereleases" option in your nuget manager or for packet manager you can use:
Install-Package MySql.Data -Version 8.0.8-dmr
Or on CLI you can use:
dotnet add package MySql.Data --version 8.0.8-dmr

Type or Namespace "Dapper" could not be found: in Hangfire Source code in Visual Studios?

I've imported the Hangfire Source code from Github into my existing VS 2013 solution. When I attempted to build all projects within my solution, I get several errors:
Error 6 The type or namespace name 'Dapper' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Jerry_Dev\Documents\GitHub\Hangfire\src\Hangfire.SqlServer\SqlServerDistributedLock.cs 20 7 Hangfire.SqlServer
In Package Manager, when I do: "Install-Package Dapper", it says
'Dapper 1.38' already installed.
Hangfire.SqlServer already has a reference to 'Dapper 1.38'.
I see Dapper dot net installed in my Manage Nuget Packages Window in my Hangfire.SqlServer project
We don't store the packages folder under source control to reduce the source code size. Hangfire uses Automatic Package Restore in Visual Studio instead of obsolete MSBuild-integrated package restore. The Automatic Restore downloads missing packages automatically on each build, but it works only with NuGet ≥ 2.7, so you have the following options:
Update NuGet to the latest version
Please see the official docs.
Run the build script
Go to the root Hangfire directory and run the build.bat file. It will automatically restore all the missing packages.