Open bairog opened 3 years ago
I'm encountering the same issue. Looking forward to get the solution.
The development and support for this project is on pause until financial situation is improved https://github.com/unitycontainer/unity/discussions/368
I have a solution with the following structure:
NET5ClassLibraryInterface - .NET 5.0.6 class library with net5.0-windows TFM. Refefences latest Unity.Container 5.11.11 and Unity.Configuration 5.11.2 nuget packages. Contains
IDataCreate
interface and a static class that calls functions from that interface (usescontainer.Resolve<IDataCreate>()
). Compiled as x86. Also contains App.config:DataCreate
class that implementsIDataCreate
interface. Compiled as x86.When I run NET5ClassLibraryInteropTest line
var dataGreate = container.Resolve<IDataCreate>();
throws an exception:I've investigated the problem deeper and found out that if I manually add the following line to NET5ClassLibraryInterop.vcxproj:
the problem transforms. Line
var section = c.GetSection("unity") as UnityConfigurationSection
now returnssection = null
despite of the fact thatc.GetSection("unity")
is exactly{Microsoft.Practices.Unity.Configuration.UnityConfigurationSection}
:Sample repo -https://github.com/bairog/NET5ClassLibraryWithUnityInteropTest Compile it (for some reason you need to compile twice for compiling NET5ClassLibraryInteropTest project) and start debugging NET5ClassLibraryInterop project (it starts NET5ClassLibraryInteropTest in project Debug settings)
Version information
Target framework: .NET 5.0.6 Operating system: Windows 10 x64 1909 IDE: Visual Studio 2019 16.10.0 REL Community