Menu

Error with Automation2 on Windows 10 Pro - Could not load file or assembly 'DWSIM.UI.Desktop'

2022-06-02
2022-06-09
  • Alfonso Villegas

    Hello,

    I just changed my workstation and I am now operating on Windows 10 Pro, using Microsoft Visual Studio 2019.

    Both my old code or the example code snippet to create a flowsheet using Python give the same error:

    Message=Could not load file or assembly 'DWSIM.UI.Desktop, Version=7.5.5.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
    at DWSIM.Automation.Automation2..ctor()
    Source=C:\Users\alfonso.villegas\source\repos\PythonApplication2\PythonApplication2\PythonApplication2.py
    StackTrace:
    File "C:\Users\alfonso.villegas\source\repos\PythonApplication2\PythonApplication2\PythonApplication2.py", line 35, in <module> (Current frame)
    interf = Automation2()</module>

    Could you help me with this?

     
  • Alfonso Villegas

    Hello,

    I am unfortunately still blocked on this issue... I've tried looking for ways to solve this for the past few days but I have not made any progress. I would really appreciate any hint on how to solve this.

    Here are a few more information from the Assembly binding log:

    Message=Could not load file or assembly 'DWSIM.UI.Desktop, Version=7.5.5.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
    File name: 'DWSIM.UI.Desktop, Version=7.5.5.0, Culture=neutral, PublicKeyToken=null'
    at DWSIM.Automation.Automation2..ctor()

    Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
    Running under executable C:\Users\alfonso.villegas\AppData\Local\Programs\Python\Python36-32\pythonw.exe
    --- A detailed error log follows.

    === Pre-bind state information ===
    LOG: DisplayName = DWSIM.UI.Desktop, Version=7.5.5.0, Culture=neutral, PublicKeyToken=null
    (Fully-specified)
    LOG: Appbase = file:///C:/Users/alfonso.villegas/AppData/Local/Programs/Python/Python36-32/
    LOG: Initial PrivatePath = NULL
    Calling assembly : DWSIM.Automation, Version=7.5.5.0, Culture=neutral, PublicKeyToken=null.
    ===**
    LOG: This bind starts in LoadFrom load context.
    WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
    LOG: No application configuration file found.
    LOG: Using host configuration file:
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
    LOG: Attempting download of new URL file:///C:/Users/alfonso.villegas/AppData/Local/Programs/Python/Python36-32/DWSIM.UI.Desktop.DLL.
    LOG: Attempting download of new URL file:///C:/Users/alfonso.villegas/AppData/Local/Programs/Python/Python36-32/DWSIM.UI.Desktop/DWSIM.UI.Desktop.DLL.
    LOG: Attempting download of new URL file:///C:/Users/alfonso.villegas/AppData/Local/Programs/Python/Python36-32/DWSIM.UI.Desktop.EXE.
    LOG: Attempting download of new URL file:///C:/Users/alfonso.villegas/AppData/Local/Programs/Python/Python36-32/DWSIM.UI.Desktop/DWSIM.UI.Desktop.EXE.
    LOG: Attempting download of new URL file:///C:/Users/alfonso.villegas/AppData/Local/DWSIM7/DWSIM.UI.Desktop.DLL.
    LOG: Attempting download of new URL file:///C:/Users/alfonso.villegas/AppData/Local/DWSIM7/DWSIM.UI.Desktop/DWSIM.UI.Desktop.DLL.
    LOG: Attempting download of new URL file:///C:/Users/alfonso.villegas/AppData/Local/DWSIM7/DWSIM.UI.Desktop.EXE.
    LOG: Attempting download of new URL file:///C:/Users/alfonso.villegas/AppData/Local/DWSIM7/DWSIM.UI.Desktop/DWSIM.UI.Desktop.EXE.

    Source=C:\Users\alfonso.villegas\source\repos\PythonApplication2\PythonApplication2\PythonApplication2.py
    StackTrace:
    File "C:\Users\alfonso.villegas\source\repos\PythonApplication2\PythonApplication2\PythonApplication2.py", line 35, in <module> (Current frame)
    interf = Automation2()</module>

    Thanks a lot,
    Alfonso

     
  • Daniel Medeiros

    Daniel Medeiros - 2022-06-06

    Did you set

    Directory.SetCurrentDirectory(dwsimpath)
    

    correctly?

     
  • Alfonso Villegas

    Hi Daniel,

    Yes, I set it to the right folder, the code can access all the .dll files that I reference, the error occurs only when I call interf = Automation2().

    This is my code:

    import pythoncom
    pythoncom.CoInitialize()
    
    import clr
    
    from System.IO import Directory, Path, File
    from System import String, Environment
    
    dwsimpath = "C:\\Users\\alfonso.villegas\\AppData\\Local\\DWSIM7\\"
    
    Directory.SetCurrentDirectory(dwsimpath)
    
    clr.AddReference(dwsimpath + "CapeOpen.dll")
    clr.AddReference(dwsimpath + "DWSIM.Automation.dll")
    clr.AddReference(dwsimpath + "DWSIM.Interfaces.dll")
    clr.AddReference(dwsimpath + "DWSIM.GlobalSettings.dll")
    clr.AddReference(dwsimpath + "DWSIM.SharedClasses.dll")
    clr.AddReference(dwsimpath + "DWSIM.Thermodynamics.dll")
    clr.AddReference(dwsimpath + "DWSIM.UnitOperations.dll")
    
    clr.AddReference(dwsimpath + "DWSIM.Inspector.dll")
    clr.AddReference(dwsimpath + "DWSIM.MathOps.dll")
    clr.AddReference(dwsimpath + "TcpComm.dll")
    clr.AddReference(dwsimpath + "Microsoft.ServiceBus.dll")
    
    from DWSIM.Interfaces.Enums.GraphicObjects import ObjectType
    from DWSIM.Thermodynamics import Streams, PropertyPackages
    from DWSIM.UnitOperations import UnitOperations
    from DWSIM.Automation import Automation2
    from DWSIM.GlobalSettings import Settings
    
    Directory.SetCurrentDirectory(dwsimpath)
    
    # create automation manager
    
    interf = Automation2()
    
    sim = interf.CreateFlowsheet()
    
     

    Last edit: Alfonso Villegas 2022-06-07
  • Daniel Medeiros

    Daniel Medeiros - 2022-06-07

    maybe DWSIM is blocked by Windows. Try opening DWSIM.UI.Desktop.exe manually.

     
  • Alfonso Villegas

    Yes, I can open DWSIM.UI.Desktop.exe manually.

     
  • Alfonso Villegas

    Hello,

    So the issue was that the installed Python interpreter on the workstation was 32-bit instead of 64-bit. Now everything works!

     

Log in to post a comment.