我正在制作我的第一个 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/