Click here to Skip to main content
14,447,096 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello,

I'm translating a VB.net Application to C#.
In C#, I already get an error in the IDE when entering the following line:

if (mediaPlayer.Error.errorCount != 0)


Error message:
Ambiguous reference:
"WMPLib._WMPOCXEvents_EventHandler Error (in interface_WMPOCXEvents_Event)"
"WMPLib.IWMPError Error (ininterface IWMPPlayer4)

The VB program works and even the C # application works except for the one line.

I use VS 2010 and both Applications work with .NetFramework 3.0

thx for our help

What I have tried:

- I checked the references to wmp.dll and included them again
- All settings of the WMPLib link with the one checked in VB.Net (all the same)
- I just tried it in a new test project with the following lines - without success:

var sVideo = "C:\\Temp\\Test.mpeg";
var mediaPlayer = new WMPLib.WindowsMediaPlayer {URL = sVideo};
mediaPlayer.controls.play ();

if (mediaPlayer.Error.errorCount! = 0)
{
}
Posted
Updated 19-Aug-19 2:45am
Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Hello Maciej Los,
thanks for your help.

The post you mentioned was not the right one. But she put me on the right path. :-)

The mistake in my code was that I used the namesspace MediaPlayer instead of the MediaplayerClass when initializing the variable mediaplayer.

Thus, the line is:
var mediaPlayer = new WMPLib.WindowsMediaPlayerClass () {URL = sVideo};

instead of

var mediaPlayer = new WMPLib.WindowsMediaPlayer {URL = sVideo};
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100