跳至主內容

搜尋

搜尋

Documents.open() Causing Error: Attempted To Read Or Write Protected Memory.

評論

5 條評論

  • Avatar
    Fernando Ramos Miracle

    Hello Josh,

     

    1. Could you let me know if your code is running as an application or as a service? If the latter, under what type of user account?

     

    2. Could you let me know the exact path where your documents are stored? Are they saved locally or on a networked folder?

     

    If you test with a locally stored document, do you get the same issue?

     

    Regards.

    0
  • Avatar
    Legacy Poster

    Fernando,

     

    Thank you for your response.

     

    1.  The code is running as a service.  And the user it runs under is an Administrator.

     

    2.  The path is local its C:\Labels\.  I've also made sure none of the files are read only.

     

    Additionally, I hadn't thought about the user that the service is running under, so I logged in with that user to the machine and opened bartender.  From there I opened the label file and I was able to successfully print.

    0
  • Avatar
    Fernando Ramos Miracle

    Hello Josh,

     

    Could you verify that the path to the labels and the printer name are correctly passed to the BTPrint method? Could it be that BarTender is trying to open a document with an incorrect path or using a non-existing printer?

     

    *I'm understanding from your error report that the code is stumbling in the first command of your code: LabelFormatDocument btFormat = m_btEng.Documents.Open(s_label_app_path, s_printer);

     

    If that is not the case, please let me know.

     

    Regards.

    0
  • Avatar
    Legacy Poster

    Fernando,

     

    The path is correct, because when I pass in a path that doesn't exist I get this error: "The document could not be found. Try checking the spelling of the file name or try another file name."  Also, I did set the printer to a name that didn't exist and it gave the "Attempted to read or write protected memory."  So not much was changing.  Also yes it is occurring at first command.

     

    However, I have good and bad news.  Good news is that it works now.  The bad news is that I have no way to reproduce it, and I have a feeling it's a product of Windows failing to manage memory (which is surprising for Server 2008).  Everything started working after I made a few User Account Settings for the user that was running the service.  This required a restart.  When the computer returned, I ran my code and it worked.  So to confirm that the changes I made to security were the issue, I returned them to the original settings hoping to cause the error again.  Yet, the code worked.  So the only thing I can think of is that restarting the computer fixed it (i.e. cleaned up memory artifacts).  This is troublesome, but I'm moving forward again.  

     

    Sorry for any confusion this may have caused.  This was an unfortunate circumstance and doesn't yield an answer for either of us.  I appreciate your quick responses greatly.

     

    Take care.

    0
  • Avatar
    Fernando Ramos Miracle

    Hello Josh,

     

    Many thanks for your feedback; I'm glad you were able to solve your issue (that is indeed the important part).

     

    Regarding a possible memory leak please note that since v10.0 applications based on the BarTender Print Server SDK now benefit from a number of performance enhancements. This includes the same stability improvements that Commander received as part of BarTender 9.4 SR3. It's possible that you might be able to benefit of this enhancements to prevent this sort of issues.

     

    New capabilities include:

     

    - Restarting the BarTender process if it becomes unresponsive.
     
    - Automatically restarting the BarTender process on a schedule.
     
    - Document caching.
     
    The new properties and methods are summarized here. (For more detail, please consult the SDK documentation.)
     
    - IsResponsive property added to Engine and TaskEngine classes.
     
    - ResponsiveTimeout property added to Engine, TaskEngine, and TaskEngines classes.
     
    - RestartSchedule and StartupCommand properties added to TaskManager class.
     
    - Additional Start() method added to TaskManager class in support of document caching features.
     
    - CloseFormatAfterCompletion property added to all tasks that open BarTender documents.
     
    - Priority property added to Task class.
     
    Regards
    0

登入寫評論。