Exception .net activex loaded with axhost

  • Thread starter Thread starter Martijn Boven
  • Start date Start date
M

Martijn Boven

I created a activex control in c# (vs 2005)

--------------------------------------------
[Guid("41D7A3C7-B891-4379-BE33-5195A2CFF913"), ComVisible(true)]

public partial class ActiveTest : UserControl

{

public ActiveTest()

{

InitializeComponent();

}

}

--------------------------------------------

I created a axhost derived class to load it:

-----------------------------------------------

public class AxWindows : AxHost

{

public AxWindows()

: base("41D7A3C7-B891-4379-BE33-5195A2CFF913")

{

}

}

------------------------------------------------

When I load it on a form like this:
------------------------------------------------
AxWin.AxWindows ax = new AxWin.AxWindows();

this.Controls.Add(ax);

------------------------------------------------
It works just fine until I close the form. I get the exception:

{"The object's type must be __ComObject or derived from
__ComObject.\r\nParameter name: o"}

Does someone know what the problem is?
 
Hello,

If you create the wrapper class with Aximp.exe, will it also generate the
error?

Windows Forms ActiveX Control Importer-Tool (Aximp.exe):
http://msdn2.microsoft.com/en-us/library/8ccdh774.aspx

Regards,

Luke Zhang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Because it is a .net activex it is impossible to create a wrapper wit
aximp..
(AxImp Error: Error loading type library/DLL. (Exception from HRESULT:
0x80029C4A (TYPE_E_CANTLOADLIBRARY))
 
Thank you for the information. I also get same error ("The object's type
must be __ComObject or derived from __ComObject.\r\nParameter name: o")
with a similiar test project. When the form is closing, Axhost will try to
release its loaded ActiveX control (a COM object). However, it is actual a
..NET component. Since you will use a .NET control on a .NET form, why do
you need to add an Axhost "Shell"?


Luke Zhang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
I am making an application with driver support. The drivers are created in
com. The com objects can supply a setup display through activex.
I don't use .net components and load them dynamically because I want other
parties to create drivers written in other languages (MFC activex etc).

Is this behavior a bug (You should be able to load activex components in
..net even if they are written themselve in .net) ?

Martijn Boven
 
|I am making an application with driver support. The drivers are created in
| com. The com objects can supply a setup display through activex.
| I don't use .net components and load them dynamically because I want other
| parties to create drivers written in other languages (MFC activex etc).
|
| Is this behavior a bug (You should be able to load activex components in
| .net even if they are written themselve in .net) ?
|

No, because you can't author ActiveX controls in .NET. ActiveX controls can
only be written using native tools like Delphi, VB and C++. You can't even
write COM components in .NET, you can only 'expose' .NET objects as COM
components to COM clients, but .NET objects aren't exposed as COM objects to
..NET clients.

Willy.
 
Ok, didn't know that. I thought they where full active components. Still
rather strange that I only get the error when I close the form.

Thanks for the info..
 
| Ok, didn't know that. I thought they where full active components. Still
| rather strange that I only get the error when I close the form.
|

That's because the AxHosts tries to release an 'AxControl' which isn't there
as explained by Luke.

Willy.

| Thanks for the info..
|
|
| | >
| > | > |I am making an application with driver support. The drivers are created
| > in
| > | com. The com objects can supply a setup display through activex.
| > | I don't use .net components and load them dynamically because I want
| > other
| > | parties to create drivers written in other languages (MFC activex
etc).
| > |
| > | Is this behavior a bug (You should be able to load activex components
in
| > | .net even if they are written themselve in .net) ?
| > |
| >
| > No, because you can't author ActiveX controls in .NET. ActiveX controls
| > can
| > only be written using native tools like Delphi, VB and C++. You can't
even
| > write COM components in .NET, you can only 'expose' .NET objects as COM
| > components to COM clients, but .NET objects aren't exposed as COM
objects
| > to
| > .NET clients.
| >
| > Willy.
| >
| >
| >
| >
| >
|
|
 
If what you need is a TLB equivalent to use as a CCW (COM Callable
Wrapper) for use in COM UIs such as MFC you can use regasm to generate
one. But as stated before there is no need to make your UserControl COM
interoperable if you are using it in a .NET UI.
 
Back
Top