Comments (16)
I can not reproduce your error. Although VS gave me a conflict warning with 4.0.4 version, it did not throw during the run (It did copy correct dll to bin dir as well).
Did you set your NuGet client to resolve dependencies with primary packages?
from container.
I created a sample application today to send and although I get the warning I am not reproducing the issue.
I can find how to exclude assets for NuGet but not resolve with primary packages. How is this done with PackageReference?
from container.
This is reproducing. When I RegisterType I can call Resolve and get the newly created object. If I create an object during the boot strap and RegistgerInstance I can also resolve this by calling Resolve on the container. However, if the interface associated with the registered object is in the constructor of the resolution failed. This even occurs if I pass the IUnityContainer in the constructor.
Unity.ResolutionFailedException
HResult=0x80131500
Message=Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Exception occurred while:
for parameter: 'trace'
on constructor: DialogManager(ITrace trace)
•resolving type: 'IDialogManager' mapped to 'DialogManager'
Source=Unity.Container
StackTrace:
at Unity.UnityContainer.ExecuteValidatingPlan(BuilderContext& context)
at Unity.UnityContainer.Unity.IUnityContainer.Resolve(Type type, String name, ResolverOverride[] overrides)
at Unity.UnityContainerExtensions.Resolve[T](IUnityContainer container, ResolverOverride[] overrides)
at CompanyName.Technology.Product.App.MainWindow..ctor(IUnityContainer container) in C:\TFS\Engr\Core\Application\Applications\CompanyName.Technology.Product.App\CompanyName.Technology.Product.App\MainWindow.xaml.cs:line 29
at CompanyName.Technology.Product.App.Bootstrapper.Run() in C:\TFS\Engr\Core\Application\Applications\CompanyName.Technology.Product.App\CompanyName.Technology.Product.App\Bootstrapper.cs:line 41
at CompanyName.Technology.Product.App.App.OnStartup(StartupEventArgs e) in C:\TFS\Engr\Core\Application\Applications\CompanyName.Technology.Product.App\CompanyName.Technology.Product.App\App.xaml.cs:line 18
at System.Windows.Application.<.ctor>b__1_0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInTechnologyContext(Object state)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at CompanyName.Technology.Product.App.App.Main() in C:\TFS\Engr\Core\Application\Applications\CompanyName.Technology.Product.App\CompanyName.Technology.Product.App\obj\Debug\App.g.cs:line 50
Inner Exception 1:
FileLoadException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
from container.
It seems to be related to this issue
from container.
I'm getting this since 5.9.3 (had to keep to 5.8.13 - 5.9.3 was first 5.9.x I've tried), across multiple projects.
from container.
from container.
I can reproduce this! I've create a sample which throws the exception: https://github.com/s-bauer/UnityReproSample
Can u reproduce it locally with this example?
from container.
Unity seems to require Version 4.0.4.1, but Version 4.0.4.0 was copied to the bin/Debug directory. An assembly redirect fixes the issue:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
from container.
Oh it seems that the WPF Project template is using the nuget version 4.5.0 of "System.Runtime.CompilerServices.Unsafe". Unity is using version 4.5.2, so that's where the conflict is coming from. So upgrading the "System.Runtime.CompilerServices.Unsafe" nuget package in the WPF project solves the issue.
from container.
If you use 4.5.0 you run into this issue
from container.
I've looked at the nupgk of version 5.9.4 of the Unity
package. In the contained .nuspec file it specifies
<dependency id="System.Runtime.CompilerServices.Unsafe" version="4.5.0" exclude="Build,Analyzers" />
I guess this conflicts with the Unity.Container
build as it's build against version 4.5.2
of this package.
from container.
You might be right. Deployed 5.9.5 with the fix.
from container.
Yep seems to be fixed with Version 5.9.5
. I can no longer reproduce this!
from container.
@s-bauer Thank you for your help!
from container.
I got the new package and everything is working great.
Thank you for your help!
from container.
@ENikS I'm glad I was able to help!
from container.
Related Issues (20)
- Possible regression in nested containers and ContainerControlled lifetime HOT 4
- Upgrading from 4.0.1 to 5.11.8. Question about TearDown and IBuilderPolicy HOT 3
- UnityContainerExtensions.Resolve(this IUnityContainer container, Type t, string name, params ResolverOverride[] overrides) seems to be missing HOT 1
- BuildUp with InjectionMethod run-time configuration and Diagnostic() throws "Injected method could not be matched with any public methods"
- Empty Version Zip And Tar.gz files (unity-5.8.13.576) HOT 1
- Unity.nuspec does not explicitly list DLL dependencies, which cause runtime issues
- Unable to resolve from ChildContainer when using singleton HOT 1
- Is it really necessary for a UnityContaner to hold the list of the ChildContainers created by it? HOT 16
- Is there a possibility to remove Extensions that have been added with container.AddExtension(....)? HOT 1
- Enabling diagnostic breaks functionality HOT 1
- RegisterInstance() throws incorrect exception
- ResolvedParameter() and OptionalParameter() ignore name of the dependency
- Is CommonServiceLocation replaced with CommonServiceLocator HOT 1
- Intermittent Failure During Resolve Process HOT 1
- VerificationException in TransientLifetimeManager on Azure DevOps HOT 1
- Override MethodProcessor HOT 6
- RegisterType throws InvalidOperationException when no constructor could be matched with injected member
- Invalid ("dead") license URL for NuGet package 'Unity'
- Stackoverflow even with `Diagnostic` extension enabled HOT 8
- ResolverOverride Legacy Extension not working in Unity > 5.11.6 when using .NET Framework 4.8, or .NET6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from container.