As I was preparing for tutorial of using SharpStyle Neutron to develop an ActionScript project and Windows Forms within one solution, I ran into the following issue: while there are a number of references on the web on how to use Flash OCX within Visual Studio 2003, there are only a handful of results related to Visual Studio 2005 and most of them document the problems that people are having.
Following the steps from this article (Macromedia – Developer Center Embedding Macromedia Flash Player in a C# Application) produce the following errors:
- There is a popup stating that VS ”Failed to import the ActiveX control. Please ensure it is properly registered“
- If you examine Error List, under Warnings, you will see the following
Could not resolve dependent COM reference “stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”.
Failed to create the wrapper assembly for type library “AxShockwaveFlashObjects”. Exception of type ‘Microsoft.Build.Tasks.ComReferenceResolutionException’ was thrown.
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.
I found the following Unable to add Flash 8 control in VS2005 – Tentative workaround blog post from 2005-12-07, but the instructions there didn’t work. After doing a few more searches I found the following forum page in French (translated page / original page)
Here is what needs to be done:
- Open Visual Studio 2005 command prompt and execute the following:
aximp.exe -source “C:\WINDOWS\system32\Macromed\Flash\Flash9b.ocx”
- This will generate the following files. Items in bold are the important ones:
- AxShockwaveFlashObjects.dll
- AxShockwaveFlashObjects.pdb
- ShockwaveFlashObjects.dll
- AxShockwaveFlashObjects.cs
- In Visual Studio, add the references to the 2 dlls generated by aximp (I copied them from “C:\Program FIles\Microsoft Visual Studio 8\VC” to the root of the project):
- Add namespaces to the imports section
using AxShockwaveFlashObjects;
using ShockwaveFlashObjects;
-
And here is some sample code to display SWF
AxShockwaveFlash axShockwaveFlash = new AxShockwaveFlash(); axShockwaveFlash.Location = new System.Drawing.Point(50, 50); this.Controls.Add (axShockwaveFlash); //this.Show(); // Avoids InvalidActiveXStateException. axShockwaveFlash.Movie = "D:\\test.swf"; //* it is important to set Size after specifying Movie property //* if Size is specified before, it is ignored axShockwaveFlash.Size = new System.Drawing.Size(20, 20); axShockwaveFlash.Play();
References:
- Macromedia – Developer Center Embedding Macromedia Flash Player in a C# Application to Display Stock Information – an outdated article about embedding Flash Player in a C# Application using Visual Studio 2003
- Unable to add Flash 8 control in VS2005 – Tentative workaround – post from 2005-12-07 that outlines the issue. Provided workaround didn’t work for me. Might be related to the fact that I have Service Pack 1 for VS installed
- Add Flash to Your .NET WinForms to Create Skinable UIs – an older article from 2004 with source code. Didn’t try it.
- Re Faied to import the ActiveX control. (Load Macromedia Flash) – MSDN Forums – post on MSDN forums with a link to the following article: User Interface Controls in Visual Basic 6 and Visual Basic 2005. Article talks about upgrading VB6 project to VB.NET 2005.
~Mike
[...] Flash OCX control and Visual Studio 2005 issues March 28th, 2007 Cross posted here SharpStyle Neutron [...]
I follow your guidelines..
but
i get error “AxImp Error: Unable to locate input ActiveX library: ‘C:\WINDOWS\system32\Macromed\Flash\Flash9b.ocx’.
so, what shall i do ?
tq…
You might not have the latest Flash OCX installed. You have 2 options:
+ install the latest Flash Player
+ look in your “C:\WINDOWS\system32\Macromed\Flash” directory and change above command line to match the OCX you find there.
~Mike
just wondering, is it possible to capture a frame from an flv file and convert it to jpeg ? thanks
hello all!
can anybody answer my Question?
i wanna to set transparent setting for my ShockwaveFlash component in my Visual C#.NET or Visual VB.NET.
we know with Transparet setting for ShockwaveFlash component, the background colour of ShockwaveFlash will be removed.
can i use this product to solve it?
Hello,
SharpStyle Neutron helps create SWF using Visual Studio, it is not meant to “embed” SWF into Windows Forms. Unfortunately we don’t know the answer to your question.
Consider looking at http://www.f-in-box.com/