0

Actually in my Application .net Framework and .net standard was there which is working Fine And the bootstrapper packages are installing fine.

due to some reason we have migrated one of the project to .net 6, then I was able to build , but during installation of the packages i am getting the error

Couldn't Load the assembly 'System.Runtime.dll version=6.0.0.0' 
Exception has been thrown by the target of an invocation.

during debugging I found that the exception raise in one of the .net standard calss the code where the error is occurring is

cobj = Activator.CreateInstance(<classType>,
                            BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
                            null, args, null);

and the actual line of the class constructor where it fails to create a object is

/config = ConfigurationManager.OpenExeConfiguration(GetType().Assembly.Location);

ConfigurationManager is present under namespace System.Configuration;

I feel since earlier .net standard and .net framework were there this piece of code was working ,but one of the component is in .net 6 so this line giving exception .

is there any alter solution is there .

  • Is the .NET 6 project used by any of .NET Framework ones (directly or transitively)? – Guru Stron Mar 29 '23 at 12:01
  • yes the .net 6 has a reference project which is a .net framework 4.8 class library – Aditya Dalai Mar 29 '23 at 12:04
  • actually earlier i thought may be because of the framework library this issue is coming during installation ,so i have migrate that to .net standard library but still the issue has not resolve – Aditya Dalai Mar 29 '23 at 12:07
  • Migrate that lib to .NET Standard - see [this](https://stackoverflow.com/q/70005465/2501279) – Guru Stron Mar 29 '23 at 12:09
  • HI @GuruStron I have migrate that library to .net standard 2.0 build is getting pass but still during installation this paricular line gives error ConfigurationManager.OpenExeConfiguration(GetType().Assembly.Location); and gives unable to load error in windows event viewer . – Aditya Dalai Mar 31 '23 at 02:41
  • Hi @GuruStron actually for setup I am using wix project there I haven't mention anything for installing .net 6 , i thought since in my local pc .net 6 is there it can work, is it wrong ? – Aditya Dalai Mar 31 '23 at 06:41
  • Based on docs [`ConfigurationManager.OpenExeConfiguration`](https://learn.microsoft.com/en-us/dotnet/api/system.configuration.configurationmanager.openexeconfiguration?view=dotnet-plat-ext-7.0) seems to be not a part of the .NET Standard/.NET. – Guru Stron Mar 31 '23 at 06:55
  • Hi @GuruStron , then can I write something else other then ConfigurationManager.OpenExeConfiguration that can support .net framework assemblies also . – Aditya Dalai Mar 31 '23 at 07:19
  • You need conditional compilation for that. – Guru Stron Mar 31 '23 at 07:20
  • I have put if (RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework")) for validating .net framework assembly but still the error is coming while installing the package in event viewer in visual studio debugging i couldn't reproduce the same error – Aditya Dalai Mar 31 '23 at 16:43
  • hi @GuruStron can you please suggest what is the correct alternate for ConfigurationManager.OpenExeConfiguration in .net standard 2.0 – Aditya Dalai Apr 01 '23 at 13:41
  • hi @GuruStron actually they have taken wix toolset for creating Setup flle, but after I migrate one of its component into .net 6 i have done any changes to the wix projects does that cause any issue because file tag inside component tag we have to remove assembly manifest ,because .net 6 doesn't support that – Aditya Dalai Apr 07 '23 at 04:32

0 Answers0