'Migrating a .NET Application from 32 bit to 64 bit Architecture

I have a .net application which is using third party libraries gotten from applications that my company's electrical designers use. This application (AKA Utility) allows automation for them to make their drawings and makes more reports based on their electrical drawings. Now they have decided to update the third party application to another version which is built in a 64 bit architecture and as such the application needs to be updated.

I was successful in changing the application to 64 bit architecture and making it build. However The application has two parts, A launcher and a utility, the launcher has a few selections for the user (different products) which will then allow the utility to show different options based on the selections made in the launcher. After updating the application to 64 bit architecture, the launcher will run however when it comes to running the utility it gives me the following error:

System.IO.FileLoadException: 'The path is too long after being fully qualified. Make sure the full path is less than 260 characters and the directory name is less than 248 characters.'

I have made sure the path to the assembly opening up is much much smaller than 260 characters. I even changed it so that the path would be pointing to something like C:/Temp/anotherfolder/assembly and yet i still get the same issue. This obviously works perfectly fine when running the solution in x86 rather than x64.

This is my function where the application will fail currently:

private void RunCfgUtilty()
{       
    string startupPath = @"C:/Temp/TestFolder/App.exe";

    string cachePath =
        Path.Combine( launcherPath,
                      "App" );

    string configFile = Path.Combine( startupPath, "App.exe.config" );

    string assembly = Path.Combine(startupPath, "App.exe" );
    string[] args = new string[ ] {/* some arguments */};
    
    AppDomainSetup setup = new AppDomainSetup( );
    setup.ApplicationName = "App";
    setup.CachePath = cachePath;
    setup.ShadowCopyFiles = "true";
    setup.ConfigurationFile = configFile;

    AppDomain domain = AppDomain.CreateDomain(
        "App",
        AppDomain.CurrentDomain.Evidence,
        setup );

    domain.ExecuteAssembly( assembly, args );

}

It fails at the domain.ExecuteAssembly( assembly, args ) line telling me my path is too long no matter what the assembly variable is assigned to.

Seeing this I looked into the library the execute was coming from (System.dll). this library (along with all of the System libraries) are located in the c:/program files(x86) location. I am not sure if this is correct or not as i tried reinstalling the .NET framework with a 64/86 bit installer and it put these files in the same location. As such, i do not understand what it is that i'm doing wrong here. This is, of course, the first time i'm trying to migrate a 32 bit application to a 64 bit architecture. Therefore, any help will be appreciated and I will try to provide more information if needed.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source