GithubHelp home page GithubHelp logo

Comments (16)

ENikS avatar ENikS commented on July 28, 2024

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.

plcrosby avatar plcrosby commented on July 28, 2024

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.

plcrosby avatar plcrosby commented on July 28, 2024

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.

ENikS avatar ENikS commented on July 28, 2024

It seems to be related to this issue

from container.

skolima avatar skolima commented on July 28, 2024

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.

ENikS avatar ENikS commented on July 28, 2024

from container.

s-bauer avatar s-bauer commented on July 28, 2024

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.

s-bauer avatar s-bauer commented on July 28, 2024

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.

s-bauer avatar s-bauer commented on July 28, 2024

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.

ENikS avatar ENikS commented on July 28, 2024

If you use 4.5.0 you run into this issue

from container.

s-bauer avatar s-bauer commented on July 28, 2024

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.

ENikS avatar ENikS commented on July 28, 2024

You might be right. Deployed 5.9.5 with the fix.

from container.

s-bauer avatar s-bauer commented on July 28, 2024

Yep seems to be fixed with Version 5.9.5. I can no longer reproduce this!

from container.

ENikS avatar ENikS commented on July 28, 2024

@s-bauer Thank you for your help!

from container.

plcrosby avatar plcrosby commented on July 28, 2024

I got the new package and everything is working great.

Thank you for your help!

from container.

s-bauer avatar s-bauer commented on July 28, 2024

@ENikS I'm glad I was able to help!

from container.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.