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.

作者: 峻祁连
邮箱:junqilian@163.com 
出处: http://junqilian.cnblogs.com 
转载请保留此信息。




本文转自峻祁连. Moving to Cloud/Mobile博客园博客,原文链接:http://www.cnblogs.com/junqilian/archive/2012/10/15/2724880.html ,如需转载请自行联系原作者
相关文章
|
5月前
Collection和Map的遍历方式
Collection和Map的遍历方式
31 0
|
27天前
|
算法
你对Collection中Set、List、Map理解?
你对Collection中Set、List、Map理解?
31 5
|
5月前
|
存储 算法 Java
盘点Java集合(容器)概览,Collection和Map在开发中谁用的最多?
盘点Java集合(容器)概览,Collection和Map在开发中谁用的最多?
61 0
|
5月前
|
存储 算法 Java
【Java 集合框架API接口】Collection,List,Set,Map,Queue,Deque
【Java 集合框架API接口】Collection,List,Set,Map,Queue,Deque
|
存储 人工智能 Java
Java Collection与Map详解
Java Collection与Map详解
140 0
|
存储 安全 Java
Java Review - 集合框架=Collection+Map
Java Review - 集合框架=Collection+Map
70 0
|
存储 安全 Java
Java中容器学习(一) —— Collection和Map
Java中容器学习(一) —— Collection和Map
Java中容器学习(一) —— Collection和Map
|
存储 安全 Java
【Java 集合】Java 集合主要脉络 ( Collection | Map | List | Set )
【Java 集合】Java 集合主要脉络 ( Collection | Map | List | Set )
119 0
|
存储 索引 容器
List、Set、Map是否继承自Collection接口?
List、Set 是,Map 不是。Map是键值对映射容器,与List和Set有明显的区别,而Set存储的零散的元素且不允许有重复元素(数学中的集合也是如此),List是线性结构的容器,适用于按数值索引访问元素的情形。
1024 0
|
Docker 容器
Template parsing error: template: :1:2: executing at &lt;Volumes&gt;: map has no entry for key "Volume
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34173549/article/details/80400454 报错: [root@ops-ip-statistic ~]# docker inspect -f {{.
2336 0