无法转换类型为“CommunicatorAPI.MessengerClass”的 COM 对象接口类型“CommunicatorAPI.IMessengerAdvanced”

发布于 2024-12-02 06:46:35 字数 2591 浏览 3 评论 0原文

在遵循多个 communicatorAPI 指南之后,我似乎陷入了困境。一般来说,它可以归结为无法将信使对象转换为接口。无论是信使 obj 还是信使类 obj 类。

在尝试转换对象时,我收到以下异常。

无法将“CommunicatorAPI.MessengerClass”类型的 COM 对象转换为“CommunicatorAPI.IMessengerAdvanced”接口类型。此操作失败,因为对 IID 为“{DA0635E8-09AF-480C-88B2-AA9FA1D9DB27}”的接口的 COM 组件上的 QueryInterface 调用因以下错误而失败:不支持此类接口(HRESULT 异常:0x80004002 (E_NOINTERFACE)) .

这是我尝试运行的代码示例,精简为仅抛出异常的内容。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommunicatorAPI;

namespace OCA
{
    class OCA_main
    {
        static void Main(string[] args)
        {
            OCA m = new OCA();
            m.subscribe();
            m.startconvo("emailaddress");

        }
    }

    class OCA
    {
        MessengerClass msgr = new MessengerClass();
       // Messenger msgr = new Messenger(); //Tried this too... :(

        IMessengerAdvanced msgrAdv;


        public void subscribe()
        {
            msgr.OnIMWindowCreated += new DMessengerEvents_OnIMWindowCreatedEventHandler(msgr_OnIMWindowCreated);
        }

        public void unsubscribe()
        {
            msgr.OnIMWindowCreated -=new DMessengerEvents_OnIMWindowCreatedEventHandler(msgr_OnIMWindowCreated);
        }

        void msgr_OnIMWindowCreated(object pIMWindow)
        {
            try
            {

                IMessengerAdvanced msgrAdv = (IMessengerAdvanced)msgr;
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}", ex.Message);
            }

            throw new NotImplementedException();
            //... stuff
        }

        public void startconvo(string users)
        {
            try
            {

                IMessengerAdvanced msgrAdv = (IMessengerAdvanced)msgr;
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}", ex.Message);
            }
        }

    }
}

我还使用“Messenger msgr = new Messenger();”尝试了上面的代码没有运气。

无法将“CommunicatorAPI.MessengerClass”类型的 COM 对象转换为“CommunicatorAPI.IMessengerAdvanced”接口类型。此操作失败,因为对 IID 为“{DA0635E8-09AF-480C-88B2-AA9FA1D9DB27}”的接口的 COM 组件上的 QueryInterface 调用因以下错误而失败:不支持此类接口(HRESULT 异常:0x80004002 (E_NOINTERFACE)) .

我对 C# 非常陌生,并且在使用 communicatorAPI 方面已经停滞不前。顺便说一句,参考文献已添加。嵌入选项是错误的,我被难住了。想知道是否有人找到了解决方案。

另外,我已经用以下内容实例化了界面:“msgAdv = msgr as IMessengerWndAdvanced;” 没有运气。变量 msgAdv 每次都为 null。我尝试过 M$ 的不同示例,但没有成功。而且,我已经阅读了SDK附带的“OCSDK.chm”帮助文件。没有提及“HRESULT 异常:0x80004002 (E_NOINTERFACE)”错误。

帮助?

After following multiple communicatorAPI guides I seem to be stuck. In general it boils down to the inability to cast an messenger object as an interface. Whether it's the messenger obj or the messengerclass obj classes.

Upon attempting to cast the object, I recieve the following exception.

Unable to cast COM object of type 'CommunicatorAPI.MessengerClass' to interface type 'CommunicatorAPI.IMessengerAdvanced'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{DA0635E8-09AF-480C-88B2-AA9FA1D9DB27}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

This is an example of the code I am trying to run, stripped down to just what throws the exception.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommunicatorAPI;

namespace OCA
{
    class OCA_main
    {
        static void Main(string[] args)
        {
            OCA m = new OCA();
            m.subscribe();
            m.startconvo("emailaddress");

        }
    }

    class OCA
    {
        MessengerClass msgr = new MessengerClass();
       // Messenger msgr = new Messenger(); //Tried this too... :(

        IMessengerAdvanced msgrAdv;


        public void subscribe()
        {
            msgr.OnIMWindowCreated += new DMessengerEvents_OnIMWindowCreatedEventHandler(msgr_OnIMWindowCreated);
        }

        public void unsubscribe()
        {
            msgr.OnIMWindowCreated -=new DMessengerEvents_OnIMWindowCreatedEventHandler(msgr_OnIMWindowCreated);
        }

        void msgr_OnIMWindowCreated(object pIMWindow)
        {
            try
            {

                IMessengerAdvanced msgrAdv = (IMessengerAdvanced)msgr;
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}", ex.Message);
            }

            throw new NotImplementedException();
            //... stuff
        }

        public void startconvo(string users)
        {
            try
            {

                IMessengerAdvanced msgrAdv = (IMessengerAdvanced)msgr;
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}", ex.Message);
            }
        }

    }
}

I have also tried the above code using "Messenger msgr = new Messenger();" With no luck.

Unable to cast COM object of type 'CommunicatorAPI.MessengerClass' to interface type 'CommunicatorAPI.IMessengerAdvanced'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{DA0635E8-09AF-480C-88B2-AA9FA1D9DB27}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

I am horribly new to c#, and I have come to a stand still with working with the communicatorAPI. Btw, the references are added. The Embed option is false, and I am stumped. Wonder if anyone has figured out a solution.

Also, I have instantiated the interface with something to effect of: "msgAdv = msgr as IMessengerWndAdvanced;"
with no luck. The variable msgAdv is null every time. I have tried the different examples from M$ and to no avail. Moreover, I have read through the "OCSDK.chm" help file that came with the SDK. There isn't a mention of the "Exception from HRESULT: 0x80004002 (E_NOINTERFACE)" error.

Help?

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

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

发布评论

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

评论(2

甲如呢乙后呢 2024-12-09 06:46:35

根据此 MSDN 页面,< strong>Messenger 仅实现 IMessenger3 和 DMessengerEvents,因此您无法将 Messenger 对象 msgr 转换为 IMessengerAdvanced。

如果您需要使用 IMessengerAdvanced,那么您需要找到一个实现该接口的类。否则,您将不得不使用 IMessenger3 接口的方法。

According to this MSDN page, Messenger only implments IMessenger3 and DMessengerEvents, so you cannot cast your Messenger object msgr to IMessengerAdvanced.

If you need to use IMessengerAdvanced then you need to find a class that implements that interface. Otherwise you are stuck with using methods of the IMessenger3 interface.

木緿 2024-12-09 06:46:35

在所有示例中,我可以发现它是 Messenger msgr = new Messenger(); 但更重要的是,转换为 IMessengerAdvanced 仅在 msgr.AutoSign()< 之后发生/code> 被成功调用...这与您的代码不同。

由于 IMessengerAdvanced 只是 IMessenger3 的一些补充,它的可用性取决于服务器端配置,它只能在您登录后在运行时可用。

In all examples I could find it was Messenger msgr = new Messenger(); BUT even more important the cast to IMessengerAdvanced only occurs AFTER msgr.AutoSign() is called successfully... which is a difference to your code.

Since IMessengerAdvanced is just some addition to IMessenger3 and the availibility of it is something depending on server-side configuration it only could become available at runtime AFTER you are signed in.

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