Reputation: 36070
on both applications I have added the skype4com.dll reference
The code: SKYPE4COMLib.Skype oSkype = new SKYPE4COMLib.Skype();
gives an: InvalidCastExeption
stating:
Unable to cast COM object of type 'System.__ComObject' to interface type 'SKYPE4COMLib.Skype'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B1878BFE-53D3-402E-8C86-190B19AF70D5}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
but when I run the same line of code in my wpf application I don't get an exception. why!?
My console application was running great until skype updated. I uninstalled skype, installed it again in order to try to solve the problem but that did not help.
Upvotes: 1
Views: 1406
Reputation: 36070
After long hours of trying I decided I where going to make my wpf application a console application by adding the necessary references and classes. Then I compared and I noticed that if I added:
[System.STAThreadAttribute()]
to the main method it works!!!!!
as a result my main method now should look like:
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace ConsoleApplication3
{
class Program
{
[System.STAThreadAttribute()]
static void Main(string[] args)
{
SKYPE4COMLib.Skype oSkype = new SKYPE4COMLib.Skype();
}
}
}
on asp.net there is not a main method. well not one that I know of. so in asp.net I had to add the AspCompat attribute equal to true.
so my asp.net aspx pages now look like:
<%@ Page AspCompat="true" Language="C#" .... etc
Upvotes: 0
Reputation: 1705
Don't use the client profile for you Console app, set it to the full .Net version.
You change it by going into the project properties -> Application -> Target Framework (Drop Down) -> Set it to .Net Framework 4 (If it's that version of .net you are running)
Upvotes: 7