c# 简单的 skype 应用抛出 COM 异常

标签 c# forms skype visual-c#-express-2010 skype4com

我正在制作我的第一个 Skype 应用程序,它可以简单地向用户发送消息,但是当我调试时,我遇到了一个异常,导致我的应用程序崩溃。 这是代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using skype_app;
using SKYPE4COMLib;

namespace skype_app
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }



        private void button2_Click(object sender, EventArgs e)
        {
            var oskype = new SKYPE4COMLib.Skype();
            oskype.PlaceCall(textBox1.Text);
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
           var oskype = new SKYPE4COMLib.Skype();
           oskype.SendMessage(textBox1.Text, textBox2.Text);
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

我使用了一些额外的引用资料 引用文献列表:

  • 微软.Csharp
  • SKYPE4COMlib
  • SkypeDialoglib
  • 系统
  • 系统核心
  • 系统数据
  • system.data.DataSetEXTensions
  • 系统部署
  • 系统图
  • 系统.Windows.forms
  • 系统.xml.linq

这是我得到的异常: System.RUntime.InteropServices.ComException:{“连接被拒绝”} 所以我想我的主要问题是为什么当 Skype 甚至没有打开询问我是否允许连接的对话时我的连接被拒绝?

最佳答案

问题是您正尝试在 Visual Studio 中进行调试。不幸的是,according to Skype themselves ,他们不支持在 VS 中使用此 API 和调试:

根据链接:

The most comment cause for this is you are trying to debug the program in Visual Studio. Going forward we will not be able to support using the visual studio hosting process for debugging. You can turn it off by:

  • Open your project in VS
  • Open your projects properies
  • click the debug tab
  • untick "use visual studio hosting process"
  • rebuild your application and begin debugging and it should work ok.

关于c# 简单的 skype 应用抛出 COM 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17580146/

相关文章:

javascript - 试图通过隐藏字段获取后面代码中的时间偏移值。但我得到空字符串 ("")而不是偏移量

c# - 在 C# 中创建 ASN1 编码签名以发送到 Java

javascript - 检查输入类型文本何时被填充

delphi - 在 Windows XP/7 中,我能否收到有关我未生成的进程正在关闭的通知?

delphi - 如何使用 DSPACK 将自定义音频缓冲区注入(inject) DirectX 过滤器图表?

c# - 根事务回滚时嵌套事务会回滚吗?

c# - 如何使用 Knockout.js 通过 ("map"创建 "observables") 复杂类型?

javascript - React 无法从多选表单中进行选择

javascript - 是否存在一个插件,可以在下拉菜单中创建 "Other"选项,并在选择“其他”时创建用于替代输入的文本框?

p2p - Skype 或 Hamachi 如何使用对称 NAT 连接用户?