Mashi
Mashi
CC#
Created by lexbit on 8/22/2023 in #help
❔ System.BadImageFormatException: Cannot load a reference assembly for execution.
I see, I didn't know there were versions of Window 10 that didn't support any version of .NET Framework 4. 🤔
17 replies
CC#
Created by lexbit on 8/22/2023 in #help
❔ System.BadImageFormatException: Cannot load a reference assembly for execution.
using System;
using System.IO;
using System.Reflection;

public class Example
{
public static void Main()
{
String[] args = Environment.GetCommandLineArgs();
if (args.Length == 1) {
Console.WriteLine("\nSyntax: PlatformInfo <filename>\n");
return;
}
Console.WriteLine();

// Loop through files and display information about their platform.
for (int ctr = 1; ctr < args.Length; ctr++) {
string fn = args[ctr];
if (! File.Exists(fn)) {
Console.WriteLine("File: {0}", fn);
Console.WriteLine("The file does not exist.\n");
}
else {
try {
AssemblyName an = AssemblyName.GetAssemblyName(fn);
Console.WriteLine("Assembly: {0}", an.Name);
if (an.ProcessorArchitecture == ProcessorArchitecture.MSIL)
Console.WriteLine("Architecture: AnyCPU");
else
Console.WriteLine("Architecture: {0}", an.ProcessorArchitecture);

Console.WriteLine();
}
catch (BadImageFormatException) {
Console.WriteLine("File: {0}", fn);
Console.WriteLine("Not a valid assembly.\n");
}
}
}
}
}
using System;
using System.IO;
using System.Reflection;

public class Example
{
public static void Main()
{
String[] args = Environment.GetCommandLineArgs();
if (args.Length == 1) {
Console.WriteLine("\nSyntax: PlatformInfo <filename>\n");
return;
}
Console.WriteLine();

// Loop through files and display information about their platform.
for (int ctr = 1; ctr < args.Length; ctr++) {
string fn = args[ctr];
if (! File.Exists(fn)) {
Console.WriteLine("File: {0}", fn);
Console.WriteLine("The file does not exist.\n");
}
else {
try {
AssemblyName an = AssemblyName.GetAssemblyName(fn);
Console.WriteLine("Assembly: {0}", an.Name);
if (an.ProcessorArchitecture == ProcessorArchitecture.MSIL)
Console.WriteLine("Architecture: AnyCPU");
else
Console.WriteLine("Architecture: {0}", an.ProcessorArchitecture);

Console.WriteLine();
}
catch (BadImageFormatException) {
Console.WriteLine("File: {0}", fn);
Console.WriteLine("Not a valid assembly.\n");
}
}
}
}
}
17 replies
CC#
Created by lexbit on 8/22/2023 in #help
❔ System.BadImageFormatException: Cannot load a reference assembly for execution.
There's some code here for troubleshooting
17 replies
CC#
Created by lexbit on 8/22/2023 in #help
❔ System.BadImageFormatException: Cannot load a reference assembly for execution.
17 replies
CC#
Created by lexbit on 8/22/2023 in #help
❔ System.BadImageFormatException: Cannot load a reference assembly for execution.
If you're using Visual Studio, the NuGet manager usually tells you if there are any versioning issues. Though, I have found it to be finicky for large solutions.
17 replies
CC#
Created by lexbit on 8/22/2023 in #help
❔ System.BadImageFormatException: Cannot load a reference assembly for execution.
What happens if you restore all NuGet packages?
17 replies
CC#
Created by lexbit on 8/22/2023 in #help
❔ System.BadImageFormatException: Cannot load a reference assembly for execution.
This is a runtime error?
17 replies