473,467 Members | 2,327 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

System.Windows.Forms.AxHost+InvalidActiveXStateExc eption (C#.Net)

Hi All,
I am doing one INTERESTING work with Context Menu Strip. I am
trying to insert a custom control / .Net control in Context menu as a
context menu strip. I tried inserting MonthCalender in Context Menu as
a context menu strip, it worked.
Now, i tried same with Windows Media Player ( a control available in
C#.Net). But I'm not able to set its URL property (i.e. path of the
media file). and i'm getting the exception like
System.Windows.Forms.AxHost+InvalidActiveXStateExc eption.

Those who are interested may read below extended information:

I have created one class named as Class2 i.e. Class2.cs file : Code
are as below

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using AxWMPLib;
using System.ComponentModel.Design.Serialization;

namespace ToolStripBaseRenderer
{
class Class2 : ToolStripControlHost
{
public Class2() : base(new AxWMPLib.AxWindowsMediaPlayer())
{ }

public AxWindowsMediaPlayer AxWPlayer
{
get
{
return Control as AxWindowsMediaPlayer;
}
}

public System.Drawing.Size WPlayerSize
{
get { return AxWPlayer.Size; }
set
{
AxWPlayer.Size = value;
}
}

public AxHost.State WPlayerAXHost
{
set
{
AxWPlayer.OcxState = value;
}
get
{
return AxWPlayer.OcxState;
}
}

public string WPlayerURL
{
get
{
return AxWPlayer.URL;
}
set
{
AxWPlayer.URL = value;
}
}
}
}
One windows form i.e. Form1.cs

Load event of Form1 is as below:
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;

private void Form1_Load(object sender, EventArgs e)
{
Class2 cls2 = new Class2();
cls2.WPlayerSize = new System.Drawing.Size(237, 180);
string fpath = "C:\\a.wmv";
cls2.WPlayerURL = fpath;
contextMenuStrip1.Items.Add(cls2);
}


Now in above code i'm getting an exception while assigning 'fpath'
value to URL of windows media player
i.e. at statement cls2.WPlayerURL = fpath;

Exception is like "System.Windows.Forms.AxHost
+InvalidActiveXStateException".

If i set OcxState property (i.e here it is WPlayerAXHost in Class2.cs
file) of windows media player from Form1_Load event than it may solve
problem ....but the issue is i' dont know exactly WHY i need to set
that property and how to set that property....

If ne body have ne solution plz help me out.....if above data is not
enough to understand i can send the whole project...but plz help me....

Mar 29 '07 #1
0 5278

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ángel Cabrera | last post by:
I'm using Visual Studio .NET 2003. I get a "Form1.h(242): error C2065: 'PlaySound' : undeclared identifier" error all the time, I've been looking in MSDN for a couple of hours with no luck, no...
2
by: Greg Bacchus | last post by:
Hi, I'm getting an exception that really has me stumped. It's sporadic at best, it's only happened a handful of times. This particular time it happened when the user pressed 'Alt-S' to save the...
4
by: Bilo | last post by:
I have a Windows Forms Class MainGUI I have declared MainGUI maingui; public System.ComponentModel.Container components = new Container(); in the Class I call another class MediaDriver with...
18
by: jrhoads23 | last post by:
Hello, I am trying to find a way to tell if an .NET windows forms Button (System.Windows.Forms.Button) is "depressed" (pushed down). For my application, I can not use a check box control set to...
2
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item...
5
by: Richard Lionheart | last post by:
Hi All, I tried creating a C# Form using Petzold's "Programming MS Windows with C#" guidance. He recommended using the namespace System.Windows.Forms. However, VS.NET claims "the type or...
2
by: Markus Eßmayr | last post by:
Hello, I'm writing an extension class for the winforms button control using MC++. I created a class, derived from System::Windows::Forms::Button. In my class I want to extend the functionality...
2
by: David Kanter | last post by:
Hi, I am relatively inexperienced with VB.Net, but I am familiar with many concepts from programming; I have some basic level of competence with C/C++ and Perl, but I just started using VB this...
3
by: jdlwright | last post by:
Hi, if someone could answer this please I would be grateful - I have looked online but can't find the answer. In C# I can do this for example m = new System.Windows.Forms.Form() but of...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.