I'm attempting to load a .NET 2.0 assembly into a C# .NET 4.0 PowerShell module. If I attempt to reference the assembly, I get a PlatformNotSupported message indicating the 2.0 assembly doesn't support .NET 4. I'm also loading the 2.0 assembly via reflection.
I tried creating an net40AssemblyName.dll.config with the below configuration, but that doesn't work either.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
</configuration>
</xml>
I'm unsure if this is due to the dll.config not working, or if this would have to be applied at the PowerShell.exe.config level.
I ended up separating out the specific cmdlet that targeted one platform vs. another into separate projects. I was then able to package both projects into a single MSI and provide an option during installation about which platform to target.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.