473,788 Members | 2,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Windows. Forms.AxHost+In validActiveXSta teException (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+In validActiveXSta teException.

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.Collecti ons.Generic;
using System.Text;
using System.Windows. Forms;
using AxWMPLib;
using System.Componen tModel.Design.S erialization;

namespace ToolStripBaseRe nderer
{
class Class2 : ToolStripContro lHost
{
public Class2() : base(new AxWMPLib.AxWind owsMediaPlayer( ))
{ }

public AxWindowsMediaP layer AxWPlayer
{
get
{
return Control as AxWindowsMediaP layer;
}
}

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

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

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.ContextMe nuStrip contextMenuStri p1;

private void Form1_Load(obje ct sender, EventArgs e)
{
Class2 cls2 = new Class2();
cls2.WPlayerSiz e = new System.Drawing. Size(237, 180);
string fpath = "C:\\a.wmv" ;
cls2.WPlayerURL = fpath;
contextMenuStri p1.Items.Add(cl s2);
}


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
+InvalidActiveX StateException" .

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 5398

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

Similar topics

2
699
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 idea, it's my first program, if you are so kind and could explain me in detail. Sorry for my english. Regards.
2
3797
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 data that they were entering. Following is all exception information. Any thoughts much appreciated. Cheers
4
464
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 the Constructor class MediaDriver {
18
3070
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 button style, I must use a System.Windows.Forms.Button. I can not find a way to tell when it is momentaraly pressed. I tried calling the API SendMessage with the button handle and BM_GETSTATE to get the state of the button. This will only return...
2
7845
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 in treeview i display the content item in axWebBrowser, i close the sub form normally when i close the main the following error is generated An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll ...
5
9544
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 namespace name 'Windows' does not exist in the class or namespace 'System'." But I read it, MSDN seems to think it's fine at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsformclasstopic.asp.
2
2097
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 of the Image-property, so I added the followind functions: public __gc class ExtendedButton : public System::Windows::Forms::Button { public:
2
11601
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 morning. I am trying to write an .exe file that is essentially a script. It will open an application, send it some commands via the keyboard, then wait for the results and close the application.
3
1650
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 course in VB.NET the same would be wrong m = New System.Windows.Forms.Form()
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10173
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6750
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4070
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 we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.