zoukankan      html  css  js  c++  java
  • Failed to add FS to collection at ResourceService.SetResource in Map 3D 2013

    By Daniel Du

    If you are migrating your application to Map 3D 2013 and run into this problem, this post may be helpful for you. Let’s say you have a custom command to add resource with Resource Service,for example, you are connecting to a feature source, like the implementation in the “BuildMap” sample of SDK. If you happen to run your custom command in session context:

    <CommandMethod("MyCommand", CommandFlags.Session> _
    or

    [CommandMethod("MyCommand", CommandFlags.Session)]

    or trying to add FDO connection from a pallet set.

    You may get the error message at ResourceService.SetResource():

    “Failed to add FS to collection“

    The solution is to add DocumentLock before setting resource. Here is a pseudo code snippet:

        [CommandMethod("MyCommand", CommandFlags.Session)]

        public void MyCommand() // This method can have any name

        {

          Document doc = Application.DocumentManager.MdiActiveDocument;

     

          // You must lock the document in Map 3D 2013

          using (DocumentLock docLock = doc.LockDocument())

          {

            // ...

     

            ResourceService.SetResource(...);

            //...

          }

     

        }

    And here is the explanation:

    In Map 3D 2012, the Resource Manager was not an AcDbObject – so you did not need to have a DB Lock to access it.  Thus, it was OK to run the custom command in Session context.

    In Map 3D 2013, the Resource Manager is moved into the Database, so you are now required to have a Document Lock to access it.  Therefore, the custom command can no longer be run in Session context.

    Hope this helps.

  • 相关阅读:
    按钮-全选复选框 PENGHAO
    ASP.NET技术内幕的电子书中文版 PENGHAO
    hotmail和gmail 邮件中背景图片无效不显示的解决办法
    Silverlight之DataGrid的列格式化日期
    MS SQL基础
    JS获得当前地址栏url
    Javascript实现复制到剪贴板
    C#.NET画验证码与Cookie验证
    网站部署与定制
    操作SQL数据库常用语句
  • 原文地址:https://www.cnblogs.com/junqilian/p/2724880.html
Copyright © 2011-2022 走看看