Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ActiveX "Object doesn't support this property or method" error

686 views
Skip to first unread message

gerotica

unread,
Mar 12, 2009, 5:58:20 PM3/12/09
to
I made an ActiveX control in c# using VS 2008.
Can anybody tell me why I get this error message "Object doesn't
support this property or method"?

C# Code:
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Reflection;

namespace ActiveXClassLib1
{
[Guid("39891D85-C85F-41c0-99D4-045E04239CCA")]
public interface IAXClassLib1
{
string MyMessage { get; set; }
int AXClassLibTest();
}

[ClassInterface(ClassInterfaceType.None)]
[Guid("1E557493-CB5C-4f72-9755-6B3017A5A596")]
public class AXClassLib1 : IAXClassLib1
{
public AXClassLib1()
{
MessageBox.Show("InitAX7");
}

public string MyMessage
{
get { return "Oi"; }
set { MessageBox.Show(value); }
}

public int AXClassLibTest()
{
MessageBox.Show("Test OK");
return 0;
}
}

aspx object:
<object id="MyActiveX" name="MyActiveX" classid="clsid:1E557493-
CB5C-4f72-9755-6B3017A5A596"
width="300" height="300" >
</object>
<input type="button" value="Click me" onclick="OpenActiveX2();"/>
<script language="jscript" type="text/jscript" >
function OpenActiveX2() {
document.MyActiveX.MyMessage = "Ok!!!!!!";
}
</script>

OLEView tlb output:
// Generated .ODL file (by Ole2View)
//
// typelib filename: ActiveXClassLib1.tlb
[
uuid(1A5F41E0-7835-4B50-80D9-750DF17BBEC4),
version(1.0)
]
library ActiveXClassLib1
(
// NOTE: There most likely were "importlib()" statements in
// in the source. This version of Ole2View does not support
// identifying and displaying them.
//
[
odl,
uuid(39891D85-C85F-41C0-99D4-045E04239CCA),
version(1.0),
dual,
oleautomation
]
interface IAXClassLib1 : IDispatch {
[id(0x60020000), propget] HRESULT _stdcall MyMessage([out,
retval] BSTR* pRetVal);
[id(0x60020000), propput] HRESULT _stdcall MyMessage([in] BSTR
pRetVal);
[id(0x60020002)] HRESULT _stdcall AXClassLibTest([out, retval]
long* pRetVal);
};

[
uuid(1E557493-CB5C-4F72-9755-6B3017A5A596),
version(1.0),
cancreate
]
coclass AXClassLib1 {
dispinterface _Object;
[default] dispinterface IAXClassLib1;
};
);

When I start IE I get the message "InitAX7" from the ActiveX
constructor, but no other methods or properties work.

Thanks!

Pavel Minaev

unread,
Mar 12, 2009, 7:07:02 PM3/12/09
to
On Mar 12, 2:58 pm, gerotica <pgerot...@gmail.com> wrote:
> I made an ActiveX control in c# using VS 2008.
> Can anybody tell me why I get this error message "Object doesn't
> support this property or method"?
> ...

>   <object id="MyActiveX" name="MyActiveX" classid="clsid:1E557493-
> CB5C-4f72-9755-6B3017A5A596"
>             width="300" height="300" >
>   </object>
>    <input type="button" value="Click me" onclick="OpenActiveX2();"/>
>         <script language="jscript" type="text/jscript" >
>             function OpenActiveX2() {
>                 document.MyActiveX.MyMessage = "Ok!!!!!!";
>             }
>     </script>

Because "document" object does not have a property "MyActiveX". Use
"document.all.MyActiveX", or document.getElementById("MyActiveX").

gerotica

unread,
Mar 12, 2009, 7:26:25 PM3/12/09
to
Thanks for your reply.
I tried "document.all" but it didn't work...

Pavel Minaev

unread,
Mar 12, 2009, 7:46:38 PM3/12/09
to
On Mar 12, 4:26 pm, gerotica <pgerot...@gmail.com> wrote:
> Thanks for your reply.
> I tried "document.all" but it didn't work...

Do you mean that you get the exact same error?

Try getting rid of the chained property calls, and rewrite it so that
each intermediate step is saved to a variable:

var obj = document.all.MyActiveX;
obj.MyMessage = "Ok!":

then see at which line you get the problem.

gerotica

unread,
Mar 12, 2009, 9:35:40 PM3/12/09
to
Same error on obj.MyMessage = "Ok!"...

this doesn't seem to be a javascript error....
if I use var obj = new ActiveXObject(...), the constructor message
appears again, and I get the "Automation server can't create the
object".

gerotica

unread,
Mar 12, 2009, 10:03:55 PM3/12/09
to
Funny thing....
If I add
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
at the interface declaration, it stops giving the error, but nothing
happens, except a small resize of the activex container, when I click
the button....
Other funny thing... Inspecting the activex with IE Developer tool,
the outerHtml property gives me

<object id="MyActiveX" name="MyActiveX" classid="clsid:1E557493-
CB5C-4f72-9755-6B3017A5A596"
width="300" height="300" MyMessage="Ok">
</object>
What is that "MyMessage" doing there????

gerotica

unread,
Mar 12, 2009, 10:53:49 PM3/12/09
to
Problem solved!!!
Thanks to "skaoth" and his post http://www.dreamincode.net/forums/showtopic38890.htm
the problem was solved.... I think the problem is that i need an
implementation of IObjectSafety. I don't know why, but it worked after
I adjusted the code to be like the one in the post...
Thanks to Pavel Minaev for the answers...

Leon Lambert

unread,
Mar 13, 2009, 6:11:03 AM3/13/09
to
Take a look at this article on codeproject.
http://www.codeproject.com/KB/vb-interop/VB6InteropToolkit2.aspx?display=PrintAll&fid=422404&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2705037
This will tell you how to get and use the "Interop Forms Toolkit 2.0"
from Microsoft to make ActiveX components in .Net. It makes the process
of making an ActiveX component in .Net pretty easy.

Hope that helps
Leon Lambert

0 new messages