ActiveX control hosting using the concept of Alex Feinman

F

Frank

Hi,

I try to host an ActiveX control in a C# and a VB.NET application. I
try to use the concept of Alex Feinman, who has shown, how something
like that works with the windows media player control. The original
sample of Alex Feinman works fine. I try to change this sample so that
I can host my own ActiveX controls. I get several errors. I use AxImp
to get the source code for the wrapperclass of my ActiveX controls.
This file could not be compiled, because of two errors: The code line
System.ComponentModel.DefaultEvent is not valid and the code line
[assembly: System.Reflection.AssemblyVersion("1.0.0.0")] is not valid.
I remove this two lines. Now I can compile my sample app. ( Was it
wrong to remove this two lines?)
Now I want to insert my control from the toolbar in a form of my app. I
got an error while doing this: "Failed to create 'MyControlCtrl'.
'System.InvalidCastException: Unable to cast object of type
'Microsoft.CompactFramework.UnsafeControl' to type
'System.Windows.Forms.AxHost'.
I solve this problem, but I can't remember how. Now I can build my app.
If I run my app on my device, I got an error in line 315 - 317 of
AxHost.cs ( protected virtual void ResizeControl() ) :
IOleWindow wnd = GetOcx() as IOleWindow;
IntPtr hwnd;
wnd.GetWindow(out hwnd);

The problem is that wnd is null. (The return value of GetOcx() is not
null, but GetOcx() as IOleWindow is null.)

How can I solve this problem. I don't think, that the ActiveX control I
want to host is the problem. I tried to host a dummy control, that does
not implement any methods/events, too. I tried to host the controls
with a modification of the original sample and with a new C# app and
with a new VB.nET app. Every time with the same errors.

Frank
 
J

jetcat

If I run my app on my device, I got an error in line 315 - 317 of
AxHost.cs ( protected virtual void ResizeControl() ) :
IOleWindow wnd = GetOcx() as IOleWindow;
IntPtr hwnd;
wnd.GetWindow(out hwnd);
The problem is that wnd is null. (The return value of GetOcx() is not
null, but GetOcx() as IOleWindow is null.)

I encounter exactly the same problem as you. Does anyone know how to
solve this error?
 
J

jetcat

If I run my app on my device, I got an error in line 315 - 317 of
I encounter exactly the same problem as you. Does anyone know how to
solve this error?

In addition, here is the error message and stack trace:

System.NullReferenceException was unhandled
Message="COM interface with IID
'{00000114-0000-0000-C000-000000000046}' cannot be created due to the
following error: No such interface supported ."
StackTrace:
at System.Windows.Forms.AxHost.ResizeControl()
at System.Windows.Forms.AxHost.OnResize()
at System.Windows.Forms.Control.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at System.Windows.Forms.IOleObject.DoVerb()
at System.Windows.Forms.AxHost.DoVerb()
at System.Windows.Forms.AxHost.MakeVisibleWithShow()
at System.Windows.Forms.AxHost.TransitionUpTo()
at System.Windows.Forms.AxHost.GetOcx()
at System.Windows.Forms.AxHost..ctor()
at System.Windows.Forms.AxHost..ctor()
at AxMapXLib.AxMap..ctor()
at MapXMobilePrototype.MainForm.InitializeComponent()
at MapXMobilePrototype.MainForm..ctor()
at MapXMobilePrototype.Program.Main()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top