Autofac EnableInterfaceInterceptors Error - autofac

We updating to Autofac 2.4.4 after moving up to MVC3 and are receiving an exception when we include EnableInterfaceInterceptors on our registration. The exception does not appear until DependencyResolver.Current.GetService<ISite>() is called.
Exception:
Could not load type 'System.Func`2' from assembly 'App.AutofacContrib.DynamicProxy2, Version=2.4.4.705, Culture=neutral, PublicKeyToken=null'.
Registration:
builder.RegisterType<SendEmailTask>().As<ITask>().InstancePerDependency().EnableInterfaceInterceptors();
Note: In order to deal with conflicts in the different versions of Castle we performed an ILMerge on AutofacContrib.DynamicProxy2.dll and Castle.Core.dll.

Looks like a problem with the IL merge - rather than merging, have you tried assembly binding redirects?

Related

System.TypeLoadException in IBM.Data.DB2Types.DB2DynArray

I am new to use the DB2. I have added a reference for IBM.Data.DB2 DLL. The Path of the DLL is from X86 directory and also the Local Copy is set to False.
I am using the VisualStudio 2015 with the debug property of is set for x86.
I am able to build the project successfully, but getting following runtime error:
Server Error in '/' Application.
Could not load type 'IBM.Data.DB2Types.DB2DynArray' from assembly 'IBM.Data.DB2, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208'.
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 'IBM.Data.DB2Types.DB2DynArray' from assembly 'IBM.Data.DB2, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208'.
Let me know if anyone can help me on it or need any other details to investigate it.
If your code explicitly uses the class DB2DynArray , it looks like IBM removed that class from Db2 starting from V9.7 (i.e. DB2DynArray was available in versions up to V9.5 only).
Note that Db2-LUW V9.5 and V9.7 are no longer supported by IBM (current Db2 for Linux/Unix/Windows version is V11.x).
Consider an alternate solution unless the risks of running an unsupported version are signed-off by the business.
IBM registration is required to download Db2-versions(including fixpack) from this site.

Is there a way to migrate EF in .netstandard with Xamarin.Forms package?

I have a .netstandard Model layer that referenced from Xamarin.forms.
I set Xamarin.Forms package in Model layer => PrivateAssets="All".
My .netstandard Data layer referenced from Model layer.
When I run this command in PowerShell :
dotnet ef --startup-project ../Eela.Web/ migrations add v1
I have this error :
C:\Users*.nuget\packages\xamarin.forms\2.3.4.231\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(40,3): error MSB4062: The
"Xamarin.Forms.Build.Tasks.FixedCreateCSharpManifestResourceName" task
could not be loaded from the assembly
C:\Users*.nuget\packages\xamarin.forms\2.3.4.231\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Build.Tasks.dll.
Could not load file or assembly 'Microsoft.Build.Utilities.v4.0,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
The system cannot find the file specified. Confirm that the
declaration is correct, that the assembly and all its dependencies are
available, and that the task contains a public class that implements
Microsoft.Build.Framework.ITask. [.....\Eela.Model.csproj]
Even I'm using :
<PackageTargetFallback>$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8</PackageTargetFallback>
in Data layer but the problem is persisted,
Is there any way to resolve this problem ?
I did not use the migrations with EntityFramework core in a xamarin forms app. I just used
await db.Database.EnsureCreatedAsync()
If you add a .net core console app to the solution I think you can you can use migrations.

Can't load Entity Framework Core in Azure Function

I'm trying to use Entity Framework Core with a C# Azure Function, and I'm getting tons of errors with libraries. Starting from the default HTTP trigger template, I created a project.json file containing
{
"frameworks": {
"net46":{
"dependencies": {
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0"
}
}
}
}
When the package restore finishes, the compiler can no longer find the extension methods in HttpRequestMessageExtensions:
016-12-21T06:59:24.728 (9,19): error CS1929: 'HttpRequestMessage' does
not contain a definition for 'GetQueryNameValuePairs' and the best
extension method overload
'HttpRequestMessageExtensions.GetQueryNameValuePairs(HttpRequestMessage)'
requires a receiver of type 'HttpRequestMessage'
(and 3 other similar errors).
I don't really need to use those extension methods, and if I delete all code that calls them, instead I get errors about the version of System.Net.Http:
Exception during runtime resolution of assembly 'System.Net.Http,
Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a':
'System.BadImageFormatException: Cannot load a reference assembly for
execution.
at System.Reflection.RuntimeAssembly.nLoadFile(String path,
Evidence evidence)
at System.Reflection.Assembly.LoadFile(String path)
at
Microsoft.Azure.WebJobs.Script.Description.FunctionMetadataResolver.ResolveAssembly(String
assemblyName)
at
Microsoft.Azure.WebJobs.Script.Description.FunctionAssemblyLoadContext.ResolveAssembly(String
name)
at
Microsoft.Azure.WebJobs.Script.Description.FunctionAssemblyLoader.ResolveAssembly(Object
sender, ResolveEventArgs args)'
2016-12-21T07:00:00.522 Unable to find assembly 'System.Net.Http,
Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Are you missing a private assembly file?
When NuGet adds the EntityFrameworkCore package, it installs System.Net.Http version 4.3.0, whereas Azure Functions seems to be looking for the hardcoded version 4.1.1.
I see questions about using EF6 with Azure Functions, but I don't see anything about EF Core.
one solution is changing from Azure Function v2 core to Azure Function v1 framework.

"Could not load file or assembly 'TypeMock.Interceptors, Version=0.0.0.0"

We have just upgraded Typemock from 6.0.2.0 to Typemock 7.3.0.0. And we now get the following error at runtime:
[System.IO.FileNotFoundException] = {"Could not load file or assembly 'TypeMock.Interceptors, Version=0.0.0.0, Culture=neutral, PublicKeyToken=0000000000000000' or one of its dependencies. The system cannot find the file specified.":"TypeMock.Interceptors, Version=0.0.0.0, Culture=neutral, Pu...
During debugging I can see that the source throwing it is mscorlib. The mystifying thing is that I have unloaded all of my projects that have references to Typemock.dlls but still get this error. When I choose "suspend mocking" in the Typemock-menu everything works.
In the GAC I can see that Typemock.Interceptors 7.3.0.0 is installed.
Any ideas?
I called TypeMock support, and they confirmed that it was a bug in TypeMock. They sent me a newer version (7.3.2.0) and the issue has now disappeared.

LINQPad Query Error

Problem: Can't properly setup LINQPad connection to my Entity Framework dll.
I downloaded LINQPad (v4.42.01)
I started to create a new connection using the Entity Framework DbContext POCO driver
At the setup dialog I pointed to my C# project's dll and it found the appropriate DbContext class.
Next I pointed the config file to the app.config of my C# project
When I hit the Test Button I get this error:
Error: The type initializer for
'System.Data.Entity.Internal.AppConfig' thre an exception. An error
occurred creating the configuration section handler for
entityFramework: Could not load file or assembly 'EntityFramework,
Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' on
one of its dependencies. The system cannot find the file specified.
(C:\Code\NET\FTI_Opp_Model\App.Config line 5)
So I tried doing what #Sorax did in this related question and moved my EntityFramework.dll from the one I got from NuGet in my project into the LINQPad.exe folder. This got me a little further along and the Test now worked. I was encouraged because my connection in the LINQPad panel showed all my entities underneath it.
But when I right click on my Borrower entity and chose "Borrower.Take(100)" I received this error from LINQPad:
The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
With an inner exception message:
[A]System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection cannot be cast to
[B]System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection. Type
A originates from 'EntityFramework, Version=4.3.1.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' in the context 'Default' at location
'C:\MarkSisson\LinqPad\EntityFramework.dll'. Type B originates from
'EntityFramework, Version=4.3.1.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' in the context 'LoadFrom' at location
'C:\Users\msisson\AppData\Local\Temp\LINQPad\vlnebssu\shadow_ujjvzp\EntityFramework.dll'.
Any ideas?
Download the latest beta - this problem was fixed in 4.42.05.
Btw the important thing to understand that the type of the assembly also include WHERE IT WAS LOADED.
meaning two same assemblies loaded from different location are not the same type!