ESRI AppRef 抛出 Com 8000FFFF 错误

发布于 2024-11-03 10:06:50 字数 483 浏览 1 评论 0 原文

我正在使用 arcGIS api 为 arcFM 制作插件,当我尝试运行此代码时,

 Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
                System.Object obj = Activator.CreateInstance(t);
                pApp = obj as IApplication;

我得到了

System.Runtime.InteropServices.COMException(0x8000FFFF): Creating an instance of the component with CLSID {Appref CLSID HERE} from the IClassFactory faileddue to the following error: 8000ffff

谢谢

i am using the arcGIS api to make a plugin for arcFM, when i try to run this code

 Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
                System.Object obj = Activator.CreateInstance(t);
                pApp = obj as IApplication;

i get

System.Runtime.InteropServices.COMException(0x8000FFFF): Creating an instance of the component with CLSID {Appref CLSID HERE} from the IClassFactory faileddue to the following error: 8000ffff

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心如荒岛 2024-11-10 10:06:50

这是不可能的我需要使用 arcMap 而不是 ArcFM

This was impossible i needed to be using arcMap not ArcFM

乜一 2024-11-10 10:06:50

AppRef CoClass文档中,它说:

请注意,您只能使用 AppRef
对象如果你的代码正在里面运行
ArcGIS 应用程序之一
流程。

论坛帖子似乎确认这与违反此约束时出现的错误相同:

来自 http://forums.esri.com/Thread.asp?c=93&f=1729&t=217861

据我了解,有
确实没有办法访问
IApplication 实例来自
地理处理脚本。

理论上,如果你的任务纯粹是
地理处理,你应该能够
无需访问即可完成这一切
IApplication 对象。

看起来上述论坛帖子的 OP 能够通过“使用 IToolboxWorkspace 并直接访问 Esri 工具箱”来解决他们的问题。这是她的代码:

public IGPTool GetTool(string _sToolName, string _sToolboxName)
{
    IWorkspaceFactory pGPTFact;
    IToolboxWorkspace pToolboxWorkspace;
    IGPToolbox pGPToolbox;
    IGPTool pGPTool;

    pGPTFact = new ToolboxWorkspaceFactoryClass();

    pToolboxWorkspace =  pGPTFact.OpenFromFile(
        ArcGISInstallFolder + @"\ArcToolbox\Toolboxes", 0) as IToolboxWorkspace;
    pGPToolbox = pToolboxWorkspace.OpenToolbox(_sToolboxName); 
    pGPTool = pGPToolbox.OpenTool(_sToolName);
    return pGPTool;
}

private string ArcGISInstallFolder
{
    get
    {
        if (string.IsNullOrEmpty(this.m_sArcGISInstallFolder))
        {
          Microsoft.Win32.RegistryKey regkey;
          regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
                                                 @"Software\ESRI\ArcGIS", false);
          this.m_sArcGISInstallFolder = regkey.GetValue("InstallDir") as String;
        }
        return this.m_sArcGISInstallFolder;
    }
}

也许您可以在没有 AppRef 对象的情况下或通过从应用程序内部运行脚本来实现您的目标。

In the AppRef CoClass documentation, it says:

Note you can only use the AppRef
object if your code is running inside
one of the ArcGIS application
processes.

Forum posts seem to confirm that this is the same error which is seen when this constraint has been violated:

From http://forums.esri.com/Thread.asp?c=93&f=1729&t=217861:

It is my understanding that there is
indeed no way to access the
IApplication instance from a
geoprocessing script.

In theory, if your task is purely
geoprocessing, you should be able to
do it all without accessing the
IApplication object.

It looks like the OP of the above forum post was able to get around their problem by "using IToolboxWorkspace and accessing directely the Esri-toolboxes". This was her code:

public IGPTool GetTool(string _sToolName, string _sToolboxName)
{
    IWorkspaceFactory pGPTFact;
    IToolboxWorkspace pToolboxWorkspace;
    IGPToolbox pGPToolbox;
    IGPTool pGPTool;

    pGPTFact = new ToolboxWorkspaceFactoryClass();

    pToolboxWorkspace =  pGPTFact.OpenFromFile(
        ArcGISInstallFolder + @"\ArcToolbox\Toolboxes", 0) as IToolboxWorkspace;
    pGPToolbox = pToolboxWorkspace.OpenToolbox(_sToolboxName); 
    pGPTool = pGPToolbox.OpenTool(_sToolName);
    return pGPTool;
}

private string ArcGISInstallFolder
{
    get
    {
        if (string.IsNullOrEmpty(this.m_sArcGISInstallFolder))
        {
          Microsoft.Win32.RegistryKey regkey;
          regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
                                                 @"Software\ESRI\ArcGIS", false);
          this.m_sArcGISInstallFolder = regkey.GetValue("InstallDir") as String;
        }
        return this.m_sArcGISInstallFolder;
    }
}

Perhaps you can accomplish your goal either without the AppRef object or by running your script from inside the application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文