博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Failed to add FS to collection at ResourceService.SetResource in Map 3D 2013
阅读量:4697 次
发布时间:2019-06-09

本文共 1516 字,大约阅读时间需要 5 分钟。

By

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.

转载于:https://www.cnblogs.com/junqilian/archive/2012/10/15/2724880.html

你可能感兴趣的文章
【POJ 3461】Oulipo
查看>>
Alpha 冲刺 (5/10)
查看>>
使用Siege进行WEB压力测试
查看>>
斑马为什么有条纹?
查看>>
android多层树形结构列表学习笔记
查看>>
Android_去掉EditText控件周围橙色高亮区域
查看>>
《构建之法》第一、二、十六章阅读笔记
查看>>
arrow:让Python的日期与时间变的更好
查看>>
(转)Excel的 OleDb 连接串的格式(连接Excel 2003-2013)
查看>>
Java并发编程
查看>>
Git Stash用法
查看>>
sql server 2008学习8 sql server存储和索引结构
查看>>
Jquery radio选中
查看>>
postgressql数据库中limit offset使用
查看>>
测试思想-集成测试 关于接口测试 Part 2
查看>>
php生成器使用总结
查看>>
T-SQL中的indexof函数
查看>>
javascript基础之数组(Array)对象
查看>>
mysql DML DDL DCL
查看>>
RAMPS1.4 3d打印控制板接线与测试1
查看>>