Menu

Problem with LoadFlowsheet in DWSIM v7.1.2

2021-12-12
2021-12-16
  • Lucas Francisco dos Santos

    Hey all,

    I just updated DWSIM from version 7 to 7.1.2, and I am facing an issue with DWSIM.Automation.Automation2.LoadFlowsheet when loading a DWSIM simulation into my Python package. It was working properly right before updating. Does anybody have the same issue? I am pasting the error verbose here:

    FileNotFoundException: Não foi possível carregar arquivo ou assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' ou uma de suas dependências. O sistema não pode encontrar o arquivo especificado.
       em SkiaSharp.SKManagedStream.CopyTo(SKWStream destination)
       em SkiaSharp.SKManagedStream.ToMemoryStream()
       em SkiaSharp.SKTypeface.FromStream(SKStreamAsset stream, Int32 index)
       em DWSIM.Drawing.SkiaSharp.GraphicsSurface..ctor() na C:\Users\Daniel\source\repos\DanWBR\dwsim\DWSIM.Drawing.SkiaSharp\GraphicsSurface\DesignSurface.vb:linha 87
       em DWSIM.FlowsheetBase.FlowsheetBase..ctor() na C:\Users\Daniel\source\repos\DanWBR\dwsim\DWSIM.FlowsheetBase\FlowsheetBase.vb:linha 42
       em DWSIM.UI.Forms.Flowsheet.InitializeComponent() na C:\Users\Daniel\source\repos\DanWBR\dwsim\DWSIM.UI.Desktop.Forms\Forms\Flowsheet\Flowsheet.eto.cs:linha 161
       em DWSIM.Automation.Automation2.LoadFlowsheet(String filepath) na C:\Users\Daniel\source\repos\DanWBR\dwsim\DWSIM.Automation\Interface.cs:linha 158
    

    Ps1: I checked the path to the simulation, and it is accurate.
    Ps2: The references to the DWSIM dlls have been added successfully, i.e I can instanciate a DWSIM.Automation.Automation2.LoadFlowsheet object but I cannot load a simulation.

     
  • Daniel Medeiros

    Daniel Medeiros - 2021-12-13

    Try adding a reference to System.Buffers.dll, it should be there in DWSIM's directory.

     
  • Lucas Francisco dos Santos

    I added reference to System.Buffers.dll, but I still got the same issue:

    Traceback (most recent call last): File "C:\Users\lfsfr\Desktop\pyDWSIMopt\examples\SMR_LNG\bug_LoadFlowsheet.py", line 33, in <module> flowsheet = interf.LoadFlowsheet(path2sim) System.IO.FileNotFoundException: Não foi possível carregar arquivo ou assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' ou uma de suas dependências. O sistema não pode encontrar o arquivo especificado. em SkiaSharp.SKManagedStream.CopyTo(SKWStream destination) em SkiaSharp.SKManagedStream.ToMemoryStream() em SkiaSharp.SKTypeface.FromStream(SKStreamAsset stream, Int32 index) em DWSIM.Drawing.SkiaSharp.GraphicsSurface..ctor() na C:\Users\Daniel\source\repos\DanWBR\dwsim\DWSIM.Drawing.SkiaSharp\GraphicsSurface\DesignSurface.vb:linha 87 em DWSIM.FlowsheetBase.FlowsheetBase..ctor() na C:\Users\Daniel\source\repos\DanWBR\dwsim\DWSIM.FlowsheetBase\FlowsheetBase.vb:linha 42 em DWSIM.UI.Forms.Flowsheet.InitializeComponent() na C:\Users\Daniel\source\repos\DanWBR\dwsim\DWSIM.UI.Desktop.Forms\Forms\Flowsheet\Flowsheet.eto.cs:linha 161 em DWSIM.Automation.Automation2.LoadFlowsheet(String filepath) na C:\Users\Daniel\source\repos\DanWBR\dwsim\DWSIM.Automation\Interface.cs:linha 158

    I am running:
    - Python 3.9.1,
    - DWSIM v7.1.2,
    - pythonnet 2.5.2

    A minimalistic code to reproduce the error:

    import pythoncom
    pythoncom.CoInitialize()
    import clr
    
    path2dwsim = "C:\\Users\\lfsfr\\AppData\\Local\\DWSIM7\\"
    
    clr.AddReference(path2dwsim + "CapeOpen.dll")
    clr.AddReference(path2dwsim + "DWSIM.Automation.dll")
    clr.AddReference(path2dwsim + "DWSIM.Interfaces.dll")
    clr.AddReference(path2dwsim + "DWSIM.GlobalSettings.dll")
    clr.AddReference(path2dwsim + "DWSIM.SharedClasses.dll")
    clr.AddReference(path2dwsim + "DWSIM.Thermodynamics.dll")
    clr.AddReference(path2dwsim + "DWSIM.UnitOperations.dll")
    
    clr.AddReference(path2dwsim + "DWSIM.Inspector.dll")
    clr.AddReference(path2dwsim + "DWSIM.MathOps.dll")
    clr.AddReference(path2dwsim + "TcpComm.dll")
    clr.AddReference(path2dwsim + "Microsoft.ServiceBus.dll")
    clr.AddReference(path2dwsim + "System.Buffers.dll")
    clr.AddReference(path2dwsim + "SkiaSharp.dll")
    
    path2sim = "C:\\path\\to\\sim.dwxmz"
    
    from DWSIM.Automation import Automation2
    interf = Automation2() # create automation manager
    
    # load simulation
    flowsheet = interf.LoadFlowsheet(path2sim)
    
     
  • Daniel Medeiros

    Daniel Medeiros - 2021-12-16

    The current workaround is to put this dll somewhere else and then add a reference to it in your python code before creating the automation instance.

     
    • Lucas Francisco dos Santos

      That worked! Thanks a lot Daniel!

      For the record, one may need to register this new System.Buffers.dll in order to add a reference to it in a python code.

       
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.