Closed ChipsetSV closed 5 years ago
Hello, I too facing the exact error. any help would be highly appreciated.
Please provide unit test so I could reproduce the issue
Enough 1 line:
Container.RegisterTypes(new[] { typeof(DummyType) }, WithMappings.FromAllInterfaces, WithName.Default, WithLifetime.ContainerControlled);
.
Exception throws on Net.Framework 4.6.1 project (and also tried on 4.5.2, exception throws too).
Facing the same error after updating to version 2.1.6
. I'm using Unity in a Plugin for Microsoft Dynamics 365, so I'm running in a sandbox with a limited PermissionSet!
Gentlemen, if you want me to fix this issue you need to be a bit more helpful. You want me to spend my time but too busy to write one Unit Test?
Your unit tests cover this scenario, but this PR dropped support of .NET Framework for them. My commit brings support for all frameworks and now you can see this:
I ran into this exact same error today. @ENikS, what can I do to help get this merged in?
Send me a PR that fixes this issue?
Uhm I think it should be pretty straight forward. Take a look at https://msdn.microsoft.com/en-us/library/ms182315(v=vs.80).aspx
The GetObjectData
override in DuplicateTypeMappingException is missing [SecurityPermissionAttribute(SecurityAction.Demand,SerializationFormatter=true)]
I'll take a look at this myself once Visual Studio is updated :)
@s-bauer
Excellent. If it is strait forward you, @kalebpederson or perhaps someone else should be able to fix it and submit PR.
I have to admit, this particular library is not on my priority list at the moment. So, unless someone sends a PR this will have to wait until Unity 5.9.0 is released.
@ENikS I will in a few minutes / hours. I just had to update my Visual Studio installation first.
@s-bauer nice to hear it. Also please include my changes to prevent similar situations in the future.
Thank you all! I'll help and/or test as needed, so please let me know.
@kalebpederson @GreenKn1ght @ChipsetSV
Please let me know if you are OK with the PR. If no complains I'll merge and release it.
@ENikS, I approved these changes. @s-bauer, thanks ))
Posted few questions for you.
Released 2.1.9
It appears that the Unity build is broken. Is this why the fix is not getting into the NuGet release for Unity?
@NeoXtreem The fix is already on Nugget: https://www.nuget.org/packages/Unity.RegistrationByConvention/
It's a separate package!
@s-bauer I see that, but isn't it pulled in by projects that only reference the Unity package because, according to here, Unity is a 'composite' of all the other packages including Unity.RegistrationByConvention? Therefore, my understanding is that, if the build is working, then the composite Unity package would be released and include the updated Unity.RegistrationByConvention package, right?
@NeoXtreem Technically you right but Unity package is released on different schedule so if you want this change now you might want to link to individual package instead.
@ENikS I tried this and I got the following error:
System.IO.FileLoadException: 'Could not load file or assembly 'Unity.RegistrationByConvention, Version=2.1.7.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'
I think the best solution for people trying to get their projects working without having to mess around with references too much is to downgrade to Unity 5.8.6 until it is updated. But this does result in version conflicts that I have been unable to resolve as I have a mixture of .NET Framework class libraries using NuGet PackageReference and ASP.NET websites using NuGet packages.config. So, downgrading Unity.Container to 5.8.6 also and Unity.Abstractions to 3.3.0 on the ASP.NET websites didn't cut it unfortunately.
Any idea when the Unity package will be updated to 5.9.0?
@s-bauer I am assuming it works for you? Could you be so kind and help @NeoXtreem with proper setup?
Take a look at this very basic example: https://github.com/s-bauer/UnitySample
You just need Unity.Abstractions
, Unity.Container
and Unity.RegistrationByConvention
as dependencies. Do not add the Unity
package as a NuGet refernce.
Hello. I catched exception, when I use RegisterTypes with v2.1.6: Inheritance security rules violated while overriding member: "Unity.RegistrationByConvention.Exceptions.DuplicateTypeMappingException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)". Security accessibility of the overriding method must match the security accessibility of the method being overriden. I use package with Net.Framework 4.6.1.