Exception while saving to Raven - .net-core

I'm getting an exception while trying to save an entity to Raven in one of our environments.
Here are details:
Application Target Framework: .NET Core 2.1
RavenDB.Client Version: 4.1.2
.Net Core Runtime and Hosting Bundle installed on the server:
2.0.5
2.1.3
2.1.6
2.2.0
(We have multiple versions installed since it is a shared environment with multiple applications hosted)
Exception:
System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Sparrow.Json.UnmanagedWriteBuffer.Write(Byte* buffer, Int32 count)
at Sparrow.Json.BlittableWriter`1.WriteValue(Byte* buffer, Int32 size, FastList`1 escapePositions, BlittableJsonToken& token, UsageMode mode, Nullable`1 initialCompressedSize) in C:\Builds\RavenDB-Stable-4.1\src\Sparrow\Json\BlittableWriter.cs:line 555
at Sparrow.Json.BlittableJsonDocumentBuilder.ReadInternal[TWriteStrategy]() in C:\Builds\RavenDB-Stable-4.1\src\Sparrow\Json\BlittableJsonDocumentBuilder.cs:line 320
at Sparrow.Json.JsonOperationContext.ReadObjectInternal(Object builder, String documentId, UsageMode mode, IBlittableDocumentModifier modifier) in C:\Builds\RavenDB-Stable-4.1\src\Sparrow\Json\JsonOperationContext.cs:line 619
at Raven.Client.Documents.Session.InMemoryDocumentSessionOperations.StoreEntityInUnitOfWork(String id, Object entity, String changeVector, DynamicJsonValue metadata, ConcurrencyCheckMode forceConcurrencyCheck) in C:\Builds\RavenDB-Stable-4.1\src\Raven.Client\Documents\Session\InMemoryDocumentSessionOperations.cs:line 741
at Raven.Client.Documents.Session.InMemoryDocumentSessionOperations.StoreInternal(Object entity, String changeVector, String id, ConcurrencyCheckMode forceConcurrencyCheck) in C:\Builds\RavenDB-Stable-4.1\src\Raven.Client\Documents\Session\InMemoryDocumentSessionOperations.cs:line 673
at Raven.Client.Documents.Session.InMemoryDocumentSessionOperations.StoreAsyncInternal(Object entity, String changeVector, String id, ConcurrencyCheckMode forceConcurrencyCheck, CancellationToken token) in C:\Builds\RavenDB-Stable-4.1\src\Raven.Client\Documents\Session\InMemoryDocumentSessionOperations.cs:line 703
<Project Specific StackTrace>
at lambda_method(Closure , Object )
at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at System.Threading.Tasks.ValueTask`1.get_Result()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
Interestingly the application works perfectly fine in one of the very similar machine with identical set up and same set of framework installed. I'm not sure what is causing this Raven to fail. Any pointers is highly appreciated.

Looks like System.Runtime.CompilerServices.Unsafe is not installed correctly.
Try:
1. Installing and using the latest RavenDB client package -OR-
2. Try to manually install from
https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/
Install-Package System.Runtime.CompilerServices.Unsafe -Version 4.5.2

After fiddling around for more than day. I was able to reproduce the issue on my local machine with following setup:
No DOTNET Core SDK installed
Installed .NET Core Hosting and Runtime for .NET Core 2.1.3 and .NET Core 2.2.0
If I ALSO had .NET Core 2.1.6 Hosting and Runtime installed on my machine (with or without 2.1.3) the issue disappeared.
That made me to believe that .NET Core 2.1.6 installation on affected environment was somehow corrupt. So I uninstalled and reinstalled .NET Core 2.1.6 Hosting and Runtime, and this magically fixed issue.
However, this has now made our IT a bit nervous and jittery as they now feel Hosting and Runtimes cannot be trusted anymore. You literally are shooting in dark in such issues are encountered.

Related

How to resolve .NET Core reference and NuGet package version conflicts When using Dapper library in Hangfire project?

When using Hangfire library into .net core application, There is a version conflict occured between two different Dapper library. One version is V1.5.0 from Nuget package, and another version is V1.0.0 reference from my local .net core project. There is an error when running program.
System.IO.FileLoadException
HResult=0x80131040
Message=Could not load file or assembly 'Dapper, Version=1.50.1.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=Hangfire.SqlServer
StackTrace:
at Hangfire.SqlServer.SqlServerObjectsInstaller.Install(DbConnection connection, String schema)
at Hangfire.SqlServer.SqlServerStorage.<>c__DisplayClass24_0.<UseConnection>b__0(DbConnection connection)
at Hangfire.SqlServer.SqlServerStorage.UseConnection[T](DbConnection dedicatedConnection, Func`2 func)
at Hangfire.SqlServer.SqlServerStorage.UseConnection(DbConnection dedicatedConnection, Action`1 action)
at Hangfire.SqlServer.SqlServerStorage.Initialize()
at Hangfire.SqlServerStorageExtensions.UseSqlServerStorage(IGlobalConfiguration configuration, String nameOrConnectionString)
Unfortunately, I have to keep the old version library rather to replcace it. How can I resolve the package version conflict meanwhile two library exist together. Hope someone can find a nice solution. Thanks!
Uninstall Dapper in Nuget and install the version that it is looking for, in my case 1.50.1.0. Not sure why Hangfire is coded to a specific version, but this solves the issue.
Hopefully this is a not a permanent bug on their end, but this will work until it is fixed.

Setting up .net site in IIS 8.5 (AWS)

My .net project (Any CPU) is referring to Oracle.dataaccess x86 version . In my local GAC the odac version is x86. But in the web server where it was installed previously was having AMB64 version of odac in GAC . The site was working without any problem . Now I need to move the site to AWS .The windows instance in AWS has the below configuration.
OS version : Microsoft windows server 2012 R2 Standard .
IIS 8.5
The server is clean and does not have any software installed .
When I try to create a site , I ended up seeing **could not load file or assembly one of its dependencies **. Through forums I installed various libraries from Oracle but I don't understand what are the exact steps needed . I was just doing trial and error.
Please let me know the software or steps to follow which needs do be installed such that my .net site which is connecting to its Oracle database works .
Edit 1 :
Hi ,
I performed the following steps .
As suggested by you I added Oracle.managedDataaccess dll(x86) . It worked well in my local.
Deployed the same code in the server.
I installed the oracle_12.1.0.1.0
In C:/oracle_12.1.0.1.0/odp.net/managed/x86 I ran the bat file for configuring the managed odac in the server. I was able to see the changes in the machine.config file .
5.Now when I ran the site I got the below error .
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.TypeInitializationException: The type initializer for
'Oracle.DataAccess.Client.OracleClientFactory' threw an exception.
---> System.DllNotFoundException: Unable to load DLL 'OraOps12.dll': The specified module could not be found. (Exception from HRESULT:
0x8007007E) at
Oracle.DataAccess.Client.OpsInit.CheckVersionCompatibility(String
version) at Oracle.DataAccess.Client.OracleInit.Initialize() at
Oracle.DataAccess.Client.OracleClientFactory..cctor() --- End of
inner exception stack trace --- --- End of inner exception stack
trace --- at System.RuntimeFieldHandle.GetValue(RtFieldInfo field,
Object instance, RuntimeType fieldType, RuntimeType declaringType,
Boolean& domainInitialized) at
System.Reflection.RtFieldInfo.UnsafeGetValue(Object obj) at
System.Reflection.RtFieldInfo.GetValue(Object obj) at
System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
at
System.Data.Entity.Internal.LazyInternalConnection.CreateConnectionFromProviderName(String
providerInvariantName) at
System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings
appConfigConnection) at
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String
name, AppConfig config) at
System.Data.Entity.Internal.LazyInternalConnection.Initialize() at
System.Data.Entity.Internal.LazyInternalConnection.get_Connection()
at Sample.Data.AbstractEFUnitOfWork2.SetClientId(String clientId)
at Sample.Web.Controllers.ApiControllerBase1..ctor(IUow uow,
IConnectionManager cm, IEnumerable`1 allowedAppUserbases, String
connectionName, Boolean allowSaves)
In order to fix this I added OraOps12 dll from c:/oracle_12.1.0.1.0/bin to the wwwroot/site/bin folder. Then I got the below error .
System.ArgumentException: Unable to find the requested .Net Framework
Data Provider. It may not be installed. at
System.Data.Common.DbProviderFactories.GetFactory(String
providerInvariantName) at
System.Data.Entity.Internal.LazyInternalConnection.CreateConnectionFromProviderName(String
providerInvariantName) at
System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings
appConfigConnection) at
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String
name, AppConfig config) at
System.Data.Entity.Internal.LazyInternalConnection.Initialize() at
System.Data.Entity.Internal.LazyInternalConnection.get_Connection()
at Sample.Data.AbstractEFUnitOfWork2.SetClientId(String clientId)
at Sample.Web.Controllers.ApiControllerBase1..ctor(IUow uow,
IConnectionManager cm, IEnumerable`1 allowedAppUserbases, String
connectionName, Boolean allowSaves)
Checking to resolve this .
Appreciate your suggestions.

While deploying under release I get "LinkAssemblies failed" error

Just created a new project, Haven't touched anything yet except create some custom classes. Haven't touched the UI part, tried to deploy in release and I get this error:
The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Reference to metadata item 'System.Void Android.Support.V4.Widget.DrawerLayout::AddDrawerListener(Android.Support.V4.Widget.DrawerLayout/IDrawerListener)' (defined in 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null') from 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.Support.V4.Widget.DrawerLayout::AddDrawerListener(Android.Support.V4.Widget.DrawerLayout/IDrawerListener)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
--- End of inner exception stack trace ---
at Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() TakeAm.Droid C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1571
I really don't know what I've done wrong I've tried changing the target and compile versions to the latest versions but still nothing. My Forms Nuget is Updated also.
This is a known bug.
Bug 48014 - blank xaml app (xamarin.forms portable) release build fails
The bug was fixed in an alpha release:
Jose Gallardo 2016-12-02 19:54:01 UTC
.../...
We're going to replace the old cross-platform templates with a new set of templates where this issue is fixed.
That new version will be out in the next XVS 4.3 preview (which will be available in the Alpha channel probably next week).
To add to my answer, there's other issues that may need to be addressed with that update.
Taken from Xamarin Android no longer builds release after Xamarin Update, John Miller:
Check that you have the following installed:
XVS 4.2.0.703
Android SDK Tools 25.2.2
Android Platform-tools 24.0.3
Android
Build-tools 24.0.3
Android support repository 38
Java 1.8 (8u101) 64 bit (Remove Java 1.7 if you have it, see more info
here:
https://developer.xamarin.com/releases/android/xamarin.android_7/xamarin.android_7.0/)
Make sure you have API 23 or 24 installed to compile the Android
project against.

SQLite cannot execute from F# FSI

None of the SQLite .NET packages work in FSI, even when referencing a module in a fs project. I've tried System.Data.SQLite, SQLitePCL.raw, and Microsoft.Data.Sqlite.
From System.Data.SQLite docs:
If the executable that starts the process consists entirely of managed code, it will run with the native processor architecture of the machine, which will be x64 on an x64 machine. Later on, this will cause assemblies containing any native code compiled for x86 (e.g. the "System.Data.SQLite.dll" mixed-mode assembly, the "SQLite.Interop.dll" native interop assembly, or the "sqlite3.dll" native library) to fail to load, typically resulting in a BadImageFormatException being thrown.
The error thrown typically looks like
System.DllNotFoundException: Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Microsoft.Data.Sqlite.Interop.NativeMethods.sqlite3_open_v2(IntPtr filename, Sqlite3Handle& ppDb, Int32 flags, IntPtr vfs)
at Microsoft.Data.Sqlite.Interop.NativeMethods.sqlite3_open_v2(String filename, Sqlite3Handle& ppDb, Int32 flags, String vfs)
at Microsoft.Data.Sqlite.SqliteConnection.Open()
at <StartupCode$FSI_0009>.$FSI_0009.main#() in E:\BitSync\NonGitProjects\SQLiteSandbox\Microsoft.DataSandbox\Scripts\Script1.fsx:line 7
Demo gist
Has anyone found a solution to this? SQLite works just fine in compiled F# programs and in debug mode.
The artice Loading Native DLLs in F# Interactive has correct techniques for solving the problem of loading native DLLS.
In my case in my case I successfully tried
System.Environment.CurrentDirectory <- #"D:\Projects\SQLiteSandbox\SQLiteSandbox\bin\Debug\x86"

Trying to integrate PayPal checkout express, using classes\dll provided by PayPal, getting: Could not load file or assembly 'log4net

Using .Net framework 4. I am assuming this log4net version that the PayPal library is dependent on
requires an older version or I don't have the file at all? Do I need to get this file somewhere or
is there another work around ?
Update, after installing latest version of log4net I now get the same error except the file is found
this time and says**:
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
com.paypal.sdk.profiles.BaseAPIProfile..cctor() +0
Line 23: {
Line 24: NVPCallerServices caller = new NVPCallerServices();
Line 25: **IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();**
code.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'log4net, Version=1.2.0.30714, Culture=neutral, PublicKeyToken=b32731d11ce58905' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.]
com.paypal.sdk.profiles.BaseAPIProfile..cctor() +0
[TypeInitializationException: The type initializer for 'com.paypal.sdk.profiles.BaseAPIProfile' threw an exception.]
com.paypal.sdk.profiles.BaseAPIProfile..ctor() +0
com.paypal.sdk.profiles.SignatureAPIProfile..ctor() +29
com.paypal.sdk.profiles.ProfileFactory.createSignatureAPIProfile() +39
GenerateCodeNVP.ECSetExpressCheckout.ECSetExpressCheckoutCode(String returnURL, String cancelURL, String amount, String paymentType, String currencyCode) in C:\Users\Admin\Documents\Visual Studio 2010\Projects\MyProject\DotNetNVPGenerate\ECSetExpressCheckout.cs:25
NeoCart.WebUI.Controllers.CheckoutController.Payment() in C:\Users\Admin\Documents\Visual Studio 2010\Projects\MyProject\NeoCart.WebUI\Controllers\CheckoutController.cs:179
lambda_method(Closure , ControllerBase , Object[] ) +96
Log4net is a separate open-source project.
You can get it from within Visual Studio using NuGet, or you can download it from Apache's website.
This question is a little old, but wanted to let you know, I was having the same issue, and found the proper library for this issue. You'll want to go to the Beta 8 archive for the sourceforge project here: http://sourceforge.net/projects/log4net/files/log4net/1.2.0%20Beta8/
Download this repository, and look in log4net-1.2.0-beta8\log4net-1.2.0-beta8\bin\net\1.0\release, the log4net.dll has the version 1.2.0.30714
Even if you don't use this, someone else might run into this question, and hopefully this response will help fix the issue for anyone else.

Resources