473,408 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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 5271

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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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...

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.