I am trying to connect to an Oracle Database using nHibernate. I can connect using the .Net driver:
<property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
However I would prefer to use the OracleDataClientDriver that ships with Oracle (or nHibernate? I forget). Anyway I was using the instructions of this blog:
http://tiredblogger.wordpress.com/2008/11/07/using-oracle-odp-with-nhibernate-from-a-c-class-library/
All is fine but when I add the app.config with the following setting to my Unit Test class:
<runtime>
<assemblyBinding xmlns=“urn:schemas-microsoft-com:asm.v1“>
<qualifyAssembly partialName=“Oracle.DataAccess“
fullName=“Oracle.DataAccess,
Version=2.111.6.20,
Culture=neutral,
PublicKeyToken=89b483f429c47342“ />
</assemblyBinding>
</runtime>
And attempt to run my test I get the following error:
Test 'M:UTOracleImporter.UT_SchemaDAO.Test_GetCustomer' failed: Could not load type 'TestDriven.Framework.Resident.IResidentTestRunner' from assembly 'TestDriven.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=50ecb853f8c6b8d2'.
System.TypeLoadException: Could not load type 'TestDriven.Framework.Resident.IResidentTestRunner' from assembly 'TestDriven.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=50ecb853f8c6b8d2'.
at TestDriven.TestRunner.AdaptorTestRunner.Run(ITestListener testListener, ITraceListener traceListener, String assemblyPath, String testPath)
at TestDriven.TestRunner.ThreadTestRunner.Runner.Run()
Any advice?
Edit: I have added the Test Driven assemblies to the GAC and now am getting a different error:
NHibernate.HibernateException : The
IDbCommand and IDbConnection
implementation in the assembly
Oracle.DataAccess could not be found.
Ensure that the assembly
Oracle.DataAccess is located in the
application directory or in the Global
Assembly Cache. If the assembly is in
the GAC, use
element in the application
configuration file to specify the full
name of the assembly.
Which is the same error that it meant to be addressed in the App.Config. The Oracle.DataAccess has been added to the GAC and I have also tried it in the application folder. Yet error still appears.
I don't see any references to Oracle (or NHibernate) in that error.
In any case, I recommend you upgrade to NH 3.0 Alpha2. The assemblyBinding stuff isn't needed anymore.
Related
I am setting up my first Windows IoT Core background application that is running on a Raspberry Pi, but I am running into a problem with conflicting assembly versions and I have been unable to resolve them.
Specifically, I am getting an error message that states:
No way to resolve conflict between "System.Data.Common, Version=4.2.1.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Data.Common,
Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing
"System.Data.Common, Version=4.2.1.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
Upon closer inspection, there are two versions of the System.Data.Common.dll that my application is referencing.
The first is coming from the installed package Microsoft.NETCore.UniversalWindowsPlatform (v 6.2.8). The assembly version of System.Data.Common here is 4.2.1.0 (which is the version I want to use):
Assembly System.Data.Common version 4.2.1.0
C:\Users\mikel\.nuget\packages\Microsoft.NETCore.UniversalWindowsPlatform\6.2.8\ref\uap10.0.15138\System.Data.Common.dll
The second is apparently being included as a dependency with the .netstandard:
Assembly System.Data.Common version 4.1.0.0
C:\Users\mikel\.nuget\packages\System.Data.Common\4.3.0\ref\netstandard1.2\System.Data.Common.dll
I am having a little harder time pinpointing exactly what is forcing NuGet to download and install the second package. Perhaps one of my other packages that I need is referencing it as a dependency (not sure).
Either way, I would like to setup assembly binding remapping so that any attempt to reference 4.1.0.0 will redirect and use 4.2.1.0.
When I do a build of my project, I get this warning:
1> Consider app.config remapping of assembly "System.Data.Common, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" from Version "4.1.0.0"
[C:\Users\mikel\.nuget\packages\System.Data.Common\4.3.0\ref\netstandard1.2\System.Data.Common.dll]
to Version "4.2.1.0"
[C:\Users\mikel\.nuget\packages\Microsoft.NETCore.UniversalWindowsPlatform\6.2.8\ref\uap10.0.15138\System.Data.Common.dll]
to solve conflict and get rid of warning.
However from what I have read, Universal Windows Projects do not support the use of app.config files. At any rate though, I added an app.config file to the root of my project, set the build action to Embedded Resource, selected Copy Always and put this in the file (to no affect):
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data.Common" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="4.1.0.0" newVersion="4.2.1.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I have also tried setting the NuGet project management format to PackageReference and added <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> to each PropertyGroup in my .csproj file. This did not have any impact.
My Universal Windows project targets are as follows:
Target version: Windows 10 Fall Creators Update (10.0; Build 16299)
Minimum Version: Windows 10 Fall Creators Update (10.0; Build 16299)
I should also state that I want to use the 4.2.1.0 version of the assembly, as 4.1.0.0 is missing a few things I need to implement the wrapper I am using around SQLite. My preference is to not have to re-write those wrappers.
At this point I am very confused as to how to resolve this conflict. How do I enable binding redirects to resolve this error?
Any help would be greatly appreciated.
I am developing a plugin that uses ADAL nuget package. My plugin assembly throws an exception when I execute due to missing Microsoft.IdentityModel.Clients.ActiveDirectory dll. The assembly is referencing and merged properly in the merged dll and this is what I see in ILSpy tool:
Here is the list of references in my plugin assembly:
Any ideas how to fix this issue?
After i tried multiple tools to merge my dlls using ILMerge and ILRepack i am facing the same issue. How can i find out Clients.ActiveDirectory dependencies which i think it is the root cause of the error?
This plugin is deployed into a CRM online instance, so I can't add dlls into GAC as we do on-premise.
Here is the exact error message I see from the Plugin Registration tool when I execute my plugin that uses ADAL nuget package:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: **Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=4.4.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencie**s. The system cannot find the file specified.
Detail: <OrganizationServiceFault xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ActivityId>00000000-0000-0000-0000-000000000000</ActivityId>
<ErrorCode>-2147220970</ErrorCode>
<ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<KeyValuePairOfstringanyType>
<a:key>CallStack</a:key>
<a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema"> at Microsoft.Dynamics.PerceptionAnalytics.Plugins.ProvisionFloorPlan.<Execute>d__0.MoveNext()
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Dynamics.PerceptionAnalytics.Plugins.ProvisionFloorPlan.Execute(IServiceProvider serviceProvider)
at PluginProfiler.Library.PluginAppDomainProxy.ExecuteCore(Stopwatch watch, ProfilerExecutionReport report, Object instance, Object executionParameter)
at PluginProfiler.Library.AppDomainProxy.Execute(ProfilerExecutionConfiguration configuration, ProfilerExecutionReport report)</a:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=4.4.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.</Message>
<Timestamp>2019-01-03T18:30:29.4049324Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true" />
<InnerFault i:nil="true" />
<OriginalException i:nil="true" />
<TraceText i:nil="true" />
</OrganizationServiceFault>
As per this article, using ILMerge in plugins is unsupported.
Are you trying to use ADAL to access CRM, or another Azure system? If you're accessing CRM, you can use the native IOrganizationService.
If you're targeting another system, you may want to consider using an Azure aware plugin to escape the sandbox and run your logic outside of CRM.
You have to merge all the necessary dlls into single plugin dll and then register it. You can use ILMERGE to do it.
Read more
Even you can have a post build Powershell commands script to do it automatically.
you can check if you added this reference from GAC.
If yes, then you may want to set jt to copy to ouput directory.
You can check if the file is existing in the execution directory.
Another reason can be that you have multiple projects referring to this adal. Each referring to different version.
Both of them set to copy to output directory. But the final build output does not have the version expected by the plug-in.
For this error, I have tried multiple solutions which is provided by Github. But, none of them worked. Please help to check whether this issue reopen on new environment like below.
Environment:
VS 2017 Version 15.4.1
Dotnet Version 2.0.2
Reproduce Steps:
Create an Asp.Net Core Web Application->.NET Core and Asp.net Core 2.0-> Web Application(Model-View-Controller)
Create an xUnit Test Project(.NET Core)
Follow this link Integration testing in ASP.NET Core
Add true to Test.csproj which is pointed at above link.
Run test method will return below error.
Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException : One or more compilation failures occurred:
ewiqttdv.z4g(4,62): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
Update:
After following this suggestion , this error gone, but, it produce below new error.
Message: System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.VisualStudio.Web.CodeGeneration, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
What is the possible way to resolve "Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException"?
Any help would be appreciated.
A bit late, but I ran in to the same problem today and managed to fix the "Could not load file or assembly 'Microsoft.VisualStudio.Web.CodeGeneration ..." error by adding the following reference to my integration test project:
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.1" PrivateAssets="All" />
I am trying to connect my application to ORACLE 12c but while i run the application specific windows service, getting the below error.
Earlier I had both 11g and 12c and the issue appeared. So, I removed both of them and installed fresh 12c.
Checked the frameworks folder for the said Oracle.DataAccess File. It is there. Also checked in odp.net folder of oracle installation. File is there with correct version.
Can anyone help me out????
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.]
Edit: My question comes down to, what are all the steps I need to take to build a web app that uses SQL Server CE in medium trust?
I had copied my desktop version into my bin directory before I posted this, but I'm sure there are more steps to take, as that did not work.
Error: Possible file version mismatch detected between ADO.NET Provider and native binaries of SQL Server Compact which could result in an incorrect functionality. This could be due to the presence of multiple instances of SQL Server Compact of different versions or due to wrong binaries with same name as SQL Server Compact binaries. Please install SQL Server Compact binaries of matching version.
Web App: MVC 3 built with VS 2010
Everything works fine on my dev machine.
After reading this post, I got rid of my references and copied SqlServerCE.dll and SqlServerCe.Entity.dll to my bin directory.
That changed the error from
Could not load file or assembly 'System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
to the current one.
I copied SqlServerCE.dll from my desktop folder, so I could run under medium trust.
From my Web.config file:
` <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
<assemblyIdentity name="System.Data.SqlServerCe"
publicKeyToken="89845dcd8080cc91" culture="neutral"/>
<bindingRedirect oldVersion="4.0.0.0-4.0.0.1" newVersion="4.0.0.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>`
Edit: Thanks everyone.
I do have SqlServerCompact.4.0.8852.1 in my packages directory.
I removed SqlServerCE.dll and SqlServerCe.Entity.dll from my bin directory, as they are in my packages. I copied the Native Binaries into my bin (and they are included in the project), but I still get this message:
Possible file version mismatch detected between ADO.NET Provider and
native binaries of SQL Server Compact which could result in an
incorrect functionality. This could be due to the presence of multiple
instances of SQL Server Compact of different versions or due to wrong
binaries with same name as SQL Server Compact binaries. Please install
SQL Server Compact binaries of matching version.
I was unable to use the nuget package you suggested as I have a newer version of Entity Framework and it rolled back the install.
I'm ready to start over with a new project if anyone can recommend a setup of SQL Server CE that will work in Medium trust on a shared hosting server.
This is what I have been doing (and does not work) when I created my project.
a. Install-Package SqlServerCompact
b. Install-Package System.Web.Providers
c. Install-Package EntityFramework
d. Install-Package EntityFramework.SqlServerCompact
Check at your packages directory if your SqlCompact is this version: SqlServerCompact.4.0.8852.1
If yes, you need to copy the files inside packages\SqlServerCompact.4.0.8852.1\NativeBinaries because they are different.
But this version don´t run at medium trust, because they changed the SqlCompact version to 4.0.0.1 and only the 4.0.0.0 is authorized by default at .NET 4 config file. If you need a version that run at medium trust, try this one https://nuget.org/packages/EntityFramework.SqlServerCompact/4.1.8482.2