[MS 8i C++] Resource files : how can we save a resource file

Hi everybody,

In our applications, we have used this to save a resource file:

    mdlResource_closeFile(ggAlmHdlGblSys);
    ggAlmHdlGblSys = 0;
    mdlResource_openFile(&ggAlmHdlGblSys, filename, RSC_READWRITE);

It has always worked fine but since Connect Advisor has been installed with MicroStation, the function mdlResource_openFile always return MDLERR_FILEREADONLY

If we uninstall Connect Advisor, everything is ok. Is there any other solution save our resource file?
We used to save this resource file to avoid to lost all the modifications we do in this file in case of a bug in our software... may be it's not really necessary?

Regrads

Hervé

  • Hi Hervé,

    as usually: specify MicroStation version exactly, in this case also Advisor version too!

    Regards,

      Jan

  • I've just installed the latest version for connect advisor : 10.1.0.270 64 bits
    And we use MicroStation 08.11.09.910

    Regards

    Hervé

  • It has always worked fine but since Connect Advisor has been installed with MicroStation, the function mdlResource_openFile always return MDLERR_FILEREADONLY

    That implies that, for whatever reason, CONNECT Advisor has locked your resource file.  Why would it do that? 

    CONNECT Advisor is not part of MicroStation, and can be uninstalled.

     
    Regards, Jon Summers
    LA Solutions

  • Of course John, it can be uninstalled
    But it's is installed automatically when you install Microstation, so on all the Microstation of our customers...

  • we have used this to save a resource file:

    Is this your own RSC-file, ore are you trying to wirte to a Bentley RSC-file like the UPF-file?

    In this case I would strongly recommend to use only your  own RSC-files. There are also other traps when You try to write in Bentley owned RSC-Files, even if it is sometimes shown as possible.

    Mit freundlichen Grüßen / Best regards
    Volker Hüfner

    |  AB_DATE Engineering  Software   |  ab-date.de  |

  • Hi ,

    A few suggestions to consider and try.

    1. It is recommended to always Capture and Verify all function Return Codes that returns one. Many times a (specific trappable and decodable) error occurs and can be reacted to. Compiler optimizations may optimize calling functions/methods in a more optimized way for functions/methods that do not capture return codes that can best ensure sequential code execution/progression.  Unfortunately this can only be seen at assembly level, experience, and/or bizarre and unexplained behaviors. 
    2. My first suspicion leans more towards timing (possibly #1 and/or) client: Antivirus, Malware and/or Synchronization software; likely not having proper exceptions for known production software and/or data files.  Consider enabling CONNECT Advisor and exclude/make exceptions for: MicroStation, CONNECT Advisor, and your application resource folder(s) to determine if other enterprise virus, malware, or synchronization software obtains a temporary file handle blocking the READWRITE access request. At time, its all about the timing and need to wait and/or try again for x-number of times, y-seconds apart before throwing your own error codes.
    3. Find Evidence or Provide a Test Case.
      1. Find Evidence. Microsoft Process Monitor logs (Save as PML, ALL Events) can provide sufficient evidence to "point a finger" or "shine a flashlight" on exactly what software and components are involved/at play - where otherwise guesswork troubleshooting may or may not lead to a proper fix (or less desired - work-around) needed.
      2. Provide a Test Case.  Two quick and easy options. Try adding the same code the same way you feed and call it in a Delivered Example, or provide a sometimes required (simple, exact and reproducible) test case to zip and attach to your post for review.  You could add your (exact) code to Myapp to verify it is reproducible in different code for the given conditions, or another SDK Example app (some listed below) that performs RSC_READWRITE operations.

        In theory if CONNECT Advisor is responsible for the problem (given #1 and #2 considerations/changes preformed first) then the problem should be portable and reproducible for other users outside your organization; like Bentley or any other forum user too.

    REFERENCE: MicroStation V8i Examples using RSC_READWRITE

    C:\Users\robert.hook\Documents\MDLProjects V8i (SELECTseries 4)>s RSC_READWRITE *
    resmover\resmover.cpp:483:    if ((mdlResource_openFile (rfHandleP, fileNameP, RSC_READWRITE))
    smgrapi\smgrapi.mc:267:     (readWrite == RSC_READWRITE))
    smgrapi\smgrapi.mc:273: if (readWrite == RSC_READWRITE)
    smgrapi\smgrapi.mc:368:    if (smgrapi_openSettingsFile (&rscFh, RSC_READWRITE) != SUCCESS)
    smgrapi\smgrapi.mc:437:    if (smgrapi_openSettingsFile (&rscFh, RSC_READWRITE) != SUCCESS)

    HTH,
    Bob



  • Hi Hervé,

    I think resource closing operation may fail. I tried to suggest you to check return value of mdlResource_closeFile() but it doesn't return any status code.

    void mdlResource_closeFile
    (
    RscFileHandle rfHandle
    );

    You may check ggAlmHdlGblSys variable after mdlResource_closeFile().

    Kind regards,

    Sedat Alis
    AEC Technology Inc.