When using Visual Studio .NET 2005's Designer to drag and drop a Shockwave Flash control (as presented in Embedding and Communicating with the Macromedia Flash Player in C# Windows Applications), you may see the following error:
Failed to import the ActiveX control. Please ensure it is properly registered.
Additionally, you may see the following warnings:
Warning 1 Could not resolve dependent COM reference "stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".[...] Warning 2 Failed to create the wrapper assembly for type library "AxShockwaveFlashObjects". Exception of type 'Microsoft.Build.Tasks.ComReferenceResolutionException' was thrown. AxShockwaveFlashObjects[...] Warning 3 The referenced component 'AxShockwaveFlashObjects' could not be found. Failed to create the wrapper assembly for type library "AxShockwaveFlashObjects". Exception of type 'Microsoft.Build.Tasks.ComReferenceResolutionException' was thrown.
Add the OLE Automation COM reference (stdole) to the project.
When attempting to dynamically embed a Shockwave Flash control (as opposed to using the Designer), you may see the following runtime error:
A first chance exception of type 'System.Windows.Forms.AxHost.InvalidActiveXStateException' occurred in AxInterop.ShockwaveFlashObjects.dll
Hide the parent control before adding the AxShockwaveFlash object.
using System.Windows.Forms; using AxShockwaveFlashObjects; using ShockwaveFlashObjects; [...] // Create Shockwave Flash object. AxShockwaveFlash asf_ = new AxShockwaveFlash(); // Add object to parent control, but hide before and show after. Change "parentControl". parentControl.Hide(); parentControl.Controls.Add(asf_); parentControl.Show(); // Load movie. asf_.LoadMovie(0, "C:\\sample.swf"); // Note: If setting size, do so *after* loading movie. asf_.Size = new Size(200,200);
Why anyone would do this way, I don't know.
using System.ComponentModel;
using System.Windows.Forms;
using AxShockwaveFlashObjects;
using ShockwaveFlashObjects;
[...]
// Create Shockwave Flash object.
AxShockwaveFlash asf_ = new AxShockwaveFlash();
// Add object to parent control. Change "parentControl".
parentControl.Controls.Add(asf_);
// Change "Form1".
// Note: Side-effects of this method are unknown.
ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
asf_.OcxState = ((AxHost.State)(resources.GetObject("asf_.OcxState")));
((ISupportInitialize)(asf_)).EndInit();
// Load movie.
asf_.LoadMovie(0, "C:\\sample.swf");
// Note: If setting size, do so *after* loading movie.
asf_.Size = new Size(200,200);