-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Could not load file or assembly 'System.Configuration.ConfigurationManager' error when using .NET 5.0.6 class library via C++\CLI wrapper #18088
Comments
Are you only referencing |
@pinkfloydx33 Referencing that nuget is a possible workaround also (in addition it is needed to remove |
Tagging subscribers to this area: @vitek-karas, @agocke, @CoffeeFlux, @VSadov Issue DetailsI have a solution with the following structure:
When I run NET5ClassLibraryInteropTest it throws an exception:
NB! If manually I add the following line to NET5ClassLibraryInterop.vcxproj - the problem goes away
But nothing directly points to the real core of the problem and this possible workaround. NB2! Instead of NET5ClassLibraryInterop.vcxproj modification there is another workaround (if Sample repo - https://github.com/bairog/NET5ClassLibraryInteropTest Version informationTarget framework: .NET 5.0.6
|
This is effectively a mismatch of TFMs between the library and the application. The library specified Moving this issue to SDK - more likely to find somebody who knows. <ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WindowsForms" />
</ItemGroup> Effectively makes the app |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Library with |
You're right it's the C++/CLI wrapper not the app, my bad. The core underlying issue is that the Also it would not be technically correct, similar issue would happen if the library required ASP.NET framework instead of WindowsDesktop. |
Well from my point of view C++/CLI project type should use
Again from my point of view such library (that requires ASP.NET framework instead of WindowsDesktop) is a much rarer use case. Absolute most common use case for C++/CLI technology is wrapping Windows C# libraries. |
Similar problem exists when using latest Unity.Container and Unity.Configuration (it uses System.Configuration.ConfigurationManager nuget package under the hood) in NET5ClassLibrary. UPDATE. Same problem with another IoC container - Autofac.Configuration. |
@wli3 who is the C++ team contact? Do we want them to take a look at this? |
@vitek-karas @agocke @CoffeeFlux @VSadov @sfoslund @wli3 Any updates on this issue? |
I have a solution with the following structure:
When I run NET5ClassLibraryInteropTest it throws an exception:
NB! If I manually add the following line to NET5ClassLibraryInterop.vcxproj - the problem goes away
But nothing directly points to the real core of the problem and this possible workaround.
NB2! Instead of NET5ClassLibraryInterop.vcxproj modification there is another workaround (if
UseWindowsForms
is used only for theConfigurationManager
class and nothing else) - add reference to System.Configuration.ConfigurationManager nuget package, removeUseWindowsForms
tag and addCopyLocalLockFileAssemblies
tag to NET5ClassLibrary.csproj. Thx to @pinkfloydx33.Same workaround can be used for other classes - Microsoft.Win32.Registry, etc.
Sample repo - https://github.com/bairog/NET5ClassLibraryInteropTest
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
The text was updated successfully, but these errors were encountered: