473,721 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reflection, base class private properties, etc.

Hi,
I have an old problem which I couldn't solve so far. Now I have found a post
in that group that gave me an idea, but I can not fully understand it.
The problem is: I'm trying to use a Windows.Forms.U serControl in a COM
environment, i.e. I want to host that control in a COM host. So far, so
good, I can host it, but I can not reach the parent COM object from the
control (Parent property is null :( ).
I have stopped the control in the debugger and I found in the watch window
some properties, like ActiveXInstance
{System.Windows .Forms.Control. ActiveXImpl}
The problem is that they are private to the base class, so I can not access
them.

Now the question: is it possible somehow to access these base properties
programmaticall y. I have found a post which mentions something about
reflection (whatever that mean). Can I use a reflection to access these
properties?

Any help will be highly appreciated.

Thanks
Sunny
Nov 15 '05 #1
10 7364
Hi Sunny,
I think that yes, it's possible to access the private properties of a class
using reflection, I haven't tested it but I also saw the post of Nicholas
and until now all that he said is true ;) , the thing is ( also stated in
the post ) what are you planning to do with it? it;s a private property and
you have no idea of how it's used or what it means.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:uO******** *****@tk2msftng p13.phx.gbl...
Hi,
I have an old problem which I couldn't solve so far. Now I have found a post in that group that gave me an idea, but I can not fully understand it.
The problem is: I'm trying to use a Windows.Forms.U serControl in a COM
environment, i.e. I want to host that control in a COM host. So far, so
good, I can host it, but I can not reach the parent COM object from the
control (Parent property is null :( ).
I have stopped the control in the debugger and I found in the watch window
some properties, like ActiveXInstance
{System.Windows .Forms.Control. ActiveXImpl}
The problem is that they are private to the base class, so I can not access them.

Now the question: is it possible somehow to access these base properties
programmaticall y. I have found a post which mentions something about
reflection (whatever that mean). Can I use a reflection to access these
properties?

Any help will be highly appreciated.

Thanks
Sunny

Nov 15 '05 #2
Hi, it seems that I have to guess what property to get, so I'll play with
all of them, but that happen always with combination COM/.Net/Outlook :)
The problem is, that I have read some of docs for reflection, and I still
have no idea where to start and how to access these private members :(
So any example will be helpful.

Sunny

"Ignacio Machin" <ignacio.mach in AT dot.state.fl.us > wrote in message
news:ul******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi Sunny,
I think that yes, it's possible to access the private properties of a class using reflection, I haven't tested it but I also saw the post of Nicholas
and until now all that he said is true ;) , the thing is ( also stated in
the post ) what are you planning to do with it? it;s a private property and you have no idea of how it's used or what it means.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:uO******** *****@tk2msftng p13.phx.gbl...
Hi,
I have an old problem which I couldn't solve so far. Now I have found a

post
in that group that gave me an idea, but I can not fully understand it.
The problem is: I'm trying to use a Windows.Forms.U serControl in a COM
environment, i.e. I want to host that control in a COM host. So far, so
good, I can host it, but I can not reach the parent COM object from the
control (Parent property is null :( ).
I have stopped the control in the debugger and I found in the watch window some properties, like ActiveXInstance
{System.Windows .Forms.Control. ActiveXImpl}
The problem is that they are private to the base class, so I can not

access
them.

Now the question: is it possible somehow to access these base properties
programmaticall y. I have found a post which mentions something about
reflection (whatever that mean). Can I use a reflection to access these
properties?

Any help will be highly appreciated.

Thanks
Sunny


Nov 15 '05 #3
Here is a sample code (in VB but it shouldn't not be difficult to translate
it) I used to get UserMode property:

Dim strAssembly As String
strAssembly =
Type.GetType("S ystem.Object"). Assembly.CodeBa se.Replace("msc orlib.dll",
"System.Windows .Forms.dll")
strAssembly = strAssembly.Rep lace("file:///", String.Empty)
strAssembly = Reflection.Asse mblyName.GetAss emblyName(strAs sembly).FullNam e
Dim unmt As Type = _
Type.GetType(Re flection.Assemb ly.CreateQualif iedName(strAsse mbly,
"System.Windows .Forms.UnsafeNa tiveMethods"))
Dim ioot As Type = unmt.GetNestedT ype("IOleObject ")
Dim mi As Reflection.Meth odInfo = ioot.GetMethod( "GetClientSite" )
Dim site As Object = mi.Invoke(Me, Nothing)
If site Is Nothing Then Return -1

' We are hosted by a COM container

Dim dsite As IDispatch = site

' All the uninitialized arguments work fine in this case
Dim id As Guid
Dim params As DISPPARAMS
Dim lcid As System.UInt32
Dim wFlags As System.UInt16 = System.UInt16.P arse(2.ToString ())
Dim result As Object
dsite.Invoke(-709, id, lcid, wFlags, params, result, Nothing, Nothing)

If result Then
Return 1
Else
Return 0
End If

That should give you an idea how to do what you want. IIRC IOleClientSite
has method GetContainer() which I think you need (not the parent COM
object). BTW You can use ildasm on System.Windows. Forms.dll to make yourself
familiar with the internal classes and implementations .

thanks,
v

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:ui******** ******@tk2msftn gp13.phx.gbl...
Hi, it seems that I have to guess what property to get, so I'll play with
all of them, but that happen always with combination COM/.Net/Outlook :)
The problem is, that I have read some of docs for reflection, and I still
have no idea where to start and how to access these private members :(
So any example will be helpful.

Sunny

"Ignacio Machin" <ignacio.mach in AT dot.state.fl.us > wrote in message
news:ul******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi Sunny,
I think that yes, it's possible to access the private properties of a

class
using reflection, I haven't tested it but I also saw the post of Nicholas
and until now all that he said is true ;) , the thing is ( also stated in the post ) what are you planning to do with it? it;s a private property

and
you have no idea of how it's used or what it means.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:uO******** *****@tk2msftng p13.phx.gbl...
Hi,
I have an old problem which I couldn't solve so far. Now I have found a
post
in that group that gave me an idea, but I can not fully understand it.
The problem is: I'm trying to use a Windows.Forms.U serControl in a COM
environment, i.e. I want to host that control in a COM host. So far,

so good, I can host it, but I can not reach the parent COM object from the control (Parent property is null :( ).
I have stopped the control in the debugger and I found in the watch

window some properties, like ActiveXInstance
{System.Windows .Forms.Control. ActiveXImpl}
The problem is that they are private to the base class, so I can not

access
them.

Now the question: is it possible somehow to access these base properties programmaticall y. I have found a post which mentions something about
reflection (whatever that mean). Can I use a reflection to access these properties?

Any help will be highly appreciated.

Thanks
Sunny



Nov 15 '05 #4
Thank you Vladimir, I'll see what will happen with this and let you know.
Sunny

"Vladimir Kouznetsov" <vl************ *****@REMOVETHI Sngrain.com> wrote in
message news:O9******** ******@TK2MSFTN GP09.phx.gbl...
Here is a sample code (in VB but it shouldn't not be difficult to translate it) I used to get UserMode property:

Dim strAssembly As String
strAssembly =
Type.GetType("S ystem.Object"). Assembly.CodeBa se.Replace("msc orlib.dll",
"System.Windows .Forms.dll")
strAssembly = strAssembly.Rep lace("file:///", String.Empty)
strAssembly = Reflection.Asse mblyName.GetAss emblyName(strAs sembly).FullNam e Dim unmt As Type = _
Type.GetType(Re flection.Assemb ly.CreateQualif iedName(strAsse mbly,
"System.Windows .Forms.UnsafeNa tiveMethods"))
Dim ioot As Type = unmt.GetNestedT ype("IOleObject ")
Dim mi As Reflection.Meth odInfo = ioot.GetMethod( "GetClientSite" )
Dim site As Object = mi.Invoke(Me, Nothing)
If site Is Nothing Then Return -1

' We are hosted by a COM container

Dim dsite As IDispatch = site

' All the uninitialized arguments work fine in this case
Dim id As Guid
Dim params As DISPPARAMS
Dim lcid As System.UInt32
Dim wFlags As System.UInt16 = System.UInt16.P arse(2.ToString ())
Dim result As Object
dsite.Invoke(-709, id, lcid, wFlags, params, result, Nothing, Nothing)

If result Then
Return 1
Else
Return 0
End If

That should give you an idea how to do what you want. IIRC IOleClientSite
has method GetContainer() which I think you need (not the parent COM
object). BTW You can use ildasm on System.Windows. Forms.dll to make yourself familiar with the internal classes and implementations .

thanks,
v

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:ui******** ******@tk2msftn gp13.phx.gbl...
Hi, it seems that I have to guess what property to get, so I'll play with
all of them, but that happen always with combination COM/.Net/Outlook :)
The problem is, that I have read some of docs for reflection, and I still have no idea where to start and how to access these private members :(
So any example will be helpful.

Sunny

"Ignacio Machin" <ignacio.mach in AT dot.state.fl.us > wrote in message
news:ul******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi Sunny,
I think that yes, it's possible to access the private properties of a class
using reflection, I haven't tested it but I also saw the post of Nicholas and until now all that he said is true ;) , the thing is ( also stated in the post ) what are you planning to do with it? it;s a private property and
you have no idea of how it's used or what it means.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:uO******** *****@tk2msftng p13.phx.gbl...
> Hi,
> I have an old problem which I couldn't solve so far. Now I have
found a post
> in that group that gave me an idea, but I can not fully understand
it. > The problem is: I'm trying to use a Windows.Forms.U serControl in a COM > environment, i.e. I want to host that control in a COM host. So far,

so > good, I can host it, but I can not reach the parent COM object from the > control (Parent property is null :( ).
> I have stopped the control in the debugger and I found in the watch

window
> some properties, like ActiveXInstance
> {System.Windows .Forms.Control. ActiveXImpl}
> The problem is that they are private to the base class, so I can not
access
> them.
>
> Now the question: is it possible somehow to access these base properties > programmaticall y. I have found a post which mentions something about
> reflection (whatever that mean). Can I use a reflection to access these > properties?
>
> Any help will be highly appreciated.
>
> Thanks
> Sunny
>
>



Nov 15 '05 #5
Hi Vladimir,
IT WORKS IT WORKS. You are great. I have implemented this in C# and it gave
me the reference I needed. I suppose, that I had to implement all of your
code, but I stopped at the check for site is Nothing, because I can cast it
at the type I want. So, I do not know what the rest of the code have to do.
If you have a little time, pls, explain. Nevertheless so far, you are the
only guy around who have succeeded to solve that problem. I have posted it
allover, with different ideas, but ... nothing.

Thank you again
Sunny

"Vladimir Kouznetsov" <vl************ *****@REMOVETHI Sngrain.com> wrote in
message news:O9******** ******@TK2MSFTN GP09.phx.gbl...
Here is a sample code (in VB but it shouldn't not be difficult to translate it) I used to get UserMode property:

Dim strAssembly As String
strAssembly =
Type.GetType("S ystem.Object"). Assembly.CodeBa se.Replace("msc orlib.dll",
"System.Windows .Forms.dll")
strAssembly = strAssembly.Rep lace("file:///", String.Empty)
strAssembly = Reflection.Asse mblyName.GetAss emblyName(strAs sembly).FullNam e Dim unmt As Type = _
Type.GetType(Re flection.Assemb ly.CreateQualif iedName(strAsse mbly,
"System.Windows .Forms.UnsafeNa tiveMethods"))
Dim ioot As Type = unmt.GetNestedT ype("IOleObject ")
Dim mi As Reflection.Meth odInfo = ioot.GetMethod( "GetClientSite" )
Dim site As Object = mi.Invoke(Me, Nothing)
If site Is Nothing Then Return -1

' We are hosted by a COM container

Dim dsite As IDispatch = site

' All the uninitialized arguments work fine in this case
Dim id As Guid
Dim params As DISPPARAMS
Dim lcid As System.UInt32
Dim wFlags As System.UInt16 = System.UInt16.P arse(2.ToString ())
Dim result As Object
dsite.Invoke(-709, id, lcid, wFlags, params, result, Nothing, Nothing)

If result Then
Return 1
Else
Return 0
End If

That should give you an idea how to do what you want. IIRC IOleClientSite
has method GetContainer() which I think you need (not the parent COM
object). BTW You can use ildasm on System.Windows. Forms.dll to make yourself familiar with the internal classes and implementations .

thanks,
v

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:ui******** ******@tk2msftn gp13.phx.gbl...
Hi, it seems that I have to guess what property to get, so I'll play with
all of them, but that happen always with combination COM/.Net/Outlook :)
The problem is, that I have read some of docs for reflection, and I still have no idea where to start and how to access these private members :(
So any example will be helpful.

Sunny

"Ignacio Machin" <ignacio.mach in AT dot.state.fl.us > wrote in message
news:ul******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi Sunny,
I think that yes, it's possible to access the private properties of a class
using reflection, I haven't tested it but I also saw the post of Nicholas and until now all that he said is true ;) , the thing is ( also stated in the post ) what are you planning to do with it? it;s a private property and
you have no idea of how it's used or what it means.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:uO******** *****@tk2msftng p13.phx.gbl...
> Hi,
> I have an old problem which I couldn't solve so far. Now I have
found a post
> in that group that gave me an idea, but I can not fully understand
it. > The problem is: I'm trying to use a Windows.Forms.U serControl in a COM > environment, i.e. I want to host that control in a COM host. So far,

so > good, I can host it, but I can not reach the parent COM object from the > control (Parent property is null :( ).
> I have stopped the control in the debugger and I found in the watch

window
> some properties, like ActiveXInstance
> {System.Windows .Forms.Control. ActiveXImpl}
> The problem is that they are private to the base class, so I can not
access
> them.
>
> Now the question: is it possible somehow to access these base properties > programmaticall y. I have found a post which mentions something about
> reflection (whatever that mean). Can I use a reflection to access these > properties?
>
> Any help will be highly appreciated.
>
> Thanks
> Sunny
>
>



Nov 15 '05 #6
For a some reason my post didn't come through, so I repeat:

Hi Sunny,

I'm glad that was a help.
I was trying to solve a similar problem and the code was a part of the
solution. I don't think I can convert site to IOleClientSite because the
type is not accessible in compile time - it's defined in a private nested
class. Also for a some reason late binding didn't work for the object
(probably because it's a COM object). So I ComImport-ed IDispatch (couldn't
find anything predefined) and called Invoke() to get UserMode ambient
property. I found a (relatively) simpler way of detecting UserMode:

Dim strAssembly As String
strAssembly = Type.GetType("S ystem.Object"). Assembly.CodeBa se
strAssembly = strAssembly.Rep lace("mscorlib. dll", _
"System.Windows .Forms.dll")
strAssembly = strAssembly.Rep lace("file:///", String.Empty)
strAssembly = Reflection.Asse mblyName.GetAss emblyName(strAs sembly).FullNam e
Dim qualifiedContro lTypeName As String = _
Reflection.Asse mbly.CreateQual ifiedName(strAs sembly,
"System.Windows .Forms.Control" )
Dim ct As Type = Type.GetType(qu alifiedControlT ypeName)
Dim bf As Reflection.Bind ingFlags = _
Reflection.Bind ingFlags.Ignore Case Or _
Reflection.Bind ingFlags.NonPub lic Or _
Reflection.Bind ingFlags.Public Or _
Reflection.Bind ingFlags.Static Or _
Reflection.Bind ingFlags.Instan ce
Dim pi() As Reflection.Prop ertyInfo = ct.GetPropertie s(bf)
Dim axipi As Reflection.Prop ertyInfo = getMemberByName (pi, _
"ActiveXInstanc e")
Dim axi As Object = axipi.GetValue( Me, Nothing)
Dim site As Object = axi.GetClientSi te()
If site Is Nothing Then Return -1

Dim qualifiedActive XImplTypeName As String = _
Reflection.Asse mbly.CreateQual ifiedName(strAs sembly,
"System.Windows .Forms.Control+ ActiveXImpl")
Dim axit As Type = Type.GetType(qu alifiedActiveXI mplTypeName)
pi = axit.GetPropert ies(bf)
Dim dmpi As Reflection.Prop ertyInfo = getMemberByName (pi, "DesignMode ")
Dim ret As Boolean = dmpi.GetValue(a xi, Nothing)
If ret Then Return 1
Return 0

getMemberByName () is function that goes through all array elements and finds
the one with the given name. Note that I had to use "Control+Active XImpl"
type name - GetNestedType() didn't work (any ideas why?). Note that late
binding (GetClientSite( )) works fine now. Note that DesignMode property
actually stores UserMode so it's false in design time.

For a some reason .Net control's properties don't persist in COM containers.
I'm trying now to figure out why. If you have any thought about that I'd
appreciate any input.

thanks,
v

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:O0******** ******@TK2MSFTN GP10.phx.gbl...
Hi Vladimir,
IT WORKS IT WORKS. You are great. I have implemented this in C# and it gave me the reference I needed. I suppose, that I had to implement all of your
code, but I stopped at the check for site is Nothing, because I can cast it at the type I want. So, I do not know what the rest of the code have to do. If you have a little time, pls, explain. Nevertheless so far, you are the
only guy around who have succeeded to solve that problem. I have posted it
allover, with different ideas, but ... nothing.

Thank you again
Sunny

"Vladimir Kouznetsov" <vl************ *****@REMOVETHI Sngrain.com> wrote in
message news:O9******** ******@TK2MSFTN GP09.phx.gbl...
Here is a sample code (in VB but it shouldn't not be difficult to

translate
it) I used to get UserMode property:

Dim strAssembly As String
strAssembly =
Type.GetType("S ystem.Object"). Assembly.CodeBa se.Replace("msc orlib.dll",
"System.Windows .Forms.dll")
strAssembly = strAssembly.Rep lace("file:///", String.Empty)
strAssembly =

Reflection.Asse mblyName.GetAss emblyName(strAs sembly).FullNam e
Dim unmt As Type = _
Type.GetType(Re flection.Assemb ly.CreateQualif iedName(strAsse mbly,
"System.Windows .Forms.UnsafeNa tiveMethods"))
Dim ioot As Type = unmt.GetNestedT ype("IOleObject ")
Dim mi As Reflection.Meth odInfo = ioot.GetMethod( "GetClientSite" )
Dim site As Object = mi.Invoke(Me, Nothing)
If site Is Nothing Then Return -1

' We are hosted by a COM container

Dim dsite As IDispatch = site

' All the uninitialized arguments work fine in this case
Dim id As Guid
Dim params As DISPPARAMS
Dim lcid As System.UInt32
Dim wFlags As System.UInt16 = System.UInt16.P arse(2.ToString ())
Dim result As Object
dsite.Invoke(-709, id, lcid, wFlags, params, result, Nothing, Nothing)

If result Then
Return 1
Else
Return 0
End If

That should give you an idea how to do what you want. IIRC IOleClientSite
has method GetContainer() which I think you need (not the parent COM
object). BTW You can use ildasm on System.Windows. Forms.dll to make

yourself
familiar with the internal classes and implementations .

thanks,
v

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:ui******** ******@tk2msftn gp13.phx.gbl...
Hi, it seems that I have to guess what property to get, so I'll play with all of them, but that happen always with combination COM/.Net/Outlook :) The problem is, that I have read some of docs for reflection, and I still have no idea where to start and how to access these private members :(
So any example will be helpful.

Sunny

"Ignacio Machin" <ignacio.mach in AT dot.state.fl.us > wrote in message
news:ul******** ********@TK2MSF TNGP12.phx.gbl. ..
> Hi Sunny,
>
>
> I think that yes, it's possible to access the private properties of a class
> using reflection, I haven't tested it but I also saw the post of

Nicholas
> and until now all that he said is true ;) , the thing is ( also stated in
> the post ) what are you planning to do with it? it;s a private property and
> you have no idea of how it's used or what it means.
>
> Cheers,
>
> --
> Ignacio Machin,
> ignacio.machin AT dot.state.fl.us
> Florida Department Of Transportation
>
> "Sunny" <su******@icebe rgwireless.com> wrote in message
> news:uO******** *****@tk2msftng p13.phx.gbl...
> > Hi,
> > I have an old problem which I couldn't solve so far. Now I have found
a
> post
> > in that group that gave me an idea, but I can not fully understand it. > > The problem is: I'm trying to use a Windows.Forms.U serControl in a COM > > environment, i.e. I want to host that control in a COM host. So

far, so
> > good, I can host it, but I can not reach the parent COM object
from the
> > control (Parent property is null :( ).
> > I have stopped the control in the debugger and I found in the

watch window
> > some properties, like ActiveXInstance
> > {System.Windows .Forms.Control. ActiveXImpl}
> > The problem is that they are private to the base class, so I can not > access
> > them.
> >
> > Now the question: is it possible somehow to access these base

properties
> > programmaticall y. I have found a post which mentions something about > > reflection (whatever that mean). Can I use a reflection to access

these
> > properties?
> >
> > Any help will be highly appreciated.
> >
> > Thanks
> > Sunny
> >
> >
>
>



Nov 15 '05 #7
Hi Vladimir,
my problem was not so complicated, but what I learned so far is, that to
expose your .Net property, you have to implement/reimplement it in your
component, and most probably to set a corresponding DispID.
The container I targeted (Outlook PropertyPage) needed one Property (bool
Dirty) and 2 methods (void Apply() and void GetPageInfo(ref string HelpFile,
ref int HelpContext)) so I had to implement them. And there was one
undocumented property string Caption for which I had to supply DispID to be
recognized:

[DispId(-518)]
public string Caption
{
get
{return this.Name;}
}
So maybe you have to reimplement some of the properties you want to expose
with a corresponding DispID, expected by the host.

All this stuff is new for me, so I'm just guessing, but maybe it should
work. The COM host should use these DispIDs, else what for are they :)

I'm sure that if I remove the DispID part of the declaration of Caption
property, the host didn't find it. Also I just checked, that if you supply
the correct DispID (in my case -518, which I found somewhere that means
Caption) you can change the name of your property to whatever you want. I
have renamed that property to Capsss, and the host still founds it.

Maybe you have to find what DispID's host is expecting, and just to make a
new properties with that DispID, which supplies the necessary values.

Please, let me know what happened.

Sunny

"Vladimir Kouznetsov" <vl************ *****@REMOVETHI Sngrain.com> wrote in
message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
For a some reason my post didn't come through, so I repeat:

Hi Sunny,

I'm glad that was a help.
I was trying to solve a similar problem and the code was a part of the
solution. I don't think I can convert site to IOleClientSite because the
type is not accessible in compile time - it's defined in a private nested
class. Also for a some reason late binding didn't work for the object
(probably because it's a COM object). So I ComImport-ed IDispatch (couldn't find anything predefined) and called Invoke() to get UserMode ambient
property. I found a (relatively) simpler way of detecting UserMode:

Dim strAssembly As String
strAssembly = Type.GetType("S ystem.Object"). Assembly.CodeBa se
strAssembly = strAssembly.Rep lace("mscorlib. dll", _
"System.Windows .Forms.dll")
strAssembly = strAssembly.Rep lace("file:///", String.Empty)
strAssembly = Reflection.Asse mblyName.GetAss emblyName(strAs sembly).FullNam e Dim qualifiedContro lTypeName As String = _
Reflection.Asse mbly.CreateQual ifiedName(strAs sembly,
"System.Windows .Forms.Control" )
Dim ct As Type = Type.GetType(qu alifiedControlT ypeName)
Dim bf As Reflection.Bind ingFlags = _
Reflection.Bind ingFlags.Ignore Case Or _
Reflection.Bind ingFlags.NonPub lic Or _
Reflection.Bind ingFlags.Public Or _
Reflection.Bind ingFlags.Static Or _
Reflection.Bind ingFlags.Instan ce
Dim pi() As Reflection.Prop ertyInfo = ct.GetPropertie s(bf)
Dim axipi As Reflection.Prop ertyInfo = getMemberByName (pi, _
"ActiveXInstanc e")
Dim axi As Object = axipi.GetValue( Me, Nothing)
Dim site As Object = axi.GetClientSi te()
If site Is Nothing Then Return -1

Dim qualifiedActive XImplTypeName As String = _
Reflection.Asse mbly.CreateQual ifiedName(strAs sembly,
"System.Windows .Forms.Control+ ActiveXImpl")
Dim axit As Type = Type.GetType(qu alifiedActiveXI mplTypeName)
pi = axit.GetPropert ies(bf)
Dim dmpi As Reflection.Prop ertyInfo = getMemberByName (pi, "DesignMode ")
Dim ret As Boolean = dmpi.GetValue(a xi, Nothing)
If ret Then Return 1
Return 0

getMemberByName () is function that goes through all array elements and finds the one with the given name. Note that I had to use "Control+Active XImpl"
type name - GetNestedType() didn't work (any ideas why?). Note that late
binding (GetClientSite( )) works fine now. Note that DesignMode property
actually stores UserMode so it's false in design time.

For a some reason .Net control's properties don't persist in COM containers. I'm trying now to figure out why. If you have any thought about that I'd
appreciate any input.

thanks,
v

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:O0******** ******@TK2MSFTN GP10.phx.gbl...
Hi Vladimir,
IT WORKS IT WORKS. You are great. I have implemented this in C# and it gave
me the reference I needed. I suppose, that I had to implement all of your
code, but I stopped at the check for site is Nothing, because I can cast

it
at the type I want. So, I do not know what the rest of the code have to

do.
If you have a little time, pls, explain. Nevertheless so far, you are the only guy around who have succeeded to solve that problem. I have posted it allover, with different ideas, but ... nothing.

Thank you again
Sunny

"Vladimir Kouznetsov" <vl************ *****@REMOVETHI Sngrain.com> wrote in message news:O9******** ******@TK2MSFTN GP09.phx.gbl...
Here is a sample code (in VB but it shouldn't not be difficult to

translate
it) I used to get UserMode property:

Dim strAssembly As String
strAssembly =
Type.GetType("S ystem.Object"). Assembly.CodeBa se.Replace("msc orlib.dll", "System.Windows .Forms.dll")
strAssembly = strAssembly.Rep lace("file:///", String.Empty)
strAssembly =

Reflection.Asse mblyName.GetAss emblyName(strAs sembly).FullNam e
Dim unmt As Type = _
Type.GetType(Re flection.Assemb ly.CreateQualif iedName(strAsse mbly,
"System.Windows .Forms.UnsafeNa tiveMethods"))
Dim ioot As Type = unmt.GetNestedT ype("IOleObject ")
Dim mi As Reflection.Meth odInfo = ioot.GetMethod( "GetClientSite" )
Dim site As Object = mi.Invoke(Me, Nothing)
If site Is Nothing Then Return -1

' We are hosted by a COM container

Dim dsite As IDispatch = site

' All the uninitialized arguments work fine in this case
Dim id As Guid
Dim params As DISPPARAMS
Dim lcid As System.UInt32
Dim wFlags As System.UInt16 = System.UInt16.P arse(2.ToString ())
Dim result As Object
dsite.Invoke(-709, id, lcid, wFlags, params, result, Nothing, Nothing)

If result Then
Return 1
Else
Return 0
End If

That should give you an idea how to do what you want. IIRC IOleClientSite has method GetContainer() which I think you need (not the parent COM
object). BTW You can use ildasm on System.Windows. Forms.dll to make

yourself
familiar with the internal classes and implementations .

thanks,
v

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:ui******** ******@tk2msftn gp13.phx.gbl...
> Hi, it seems that I have to guess what property to get, so I'll play

with
> all of them, but that happen always with combination COM/.Net/Outlook :)
> The problem is, that I have read some of docs for reflection, and I still
> have no idea where to start and how to access these private members
:( > So any example will be helpful.
>
> Sunny
>
> "Ignacio Machin" <ignacio.mach in AT dot.state.fl.us > wrote in message > news:ul******** ********@TK2MSF TNGP12.phx.gbl. ..
> > Hi Sunny,
> >
> >
> > I think that yes, it's possible to access the private properties of a > class
> > using reflection, I haven't tested it but I also saw the post of
Nicholas
> > and until now all that he said is true ;) , the thing is ( also stated in
> > the post ) what are you planning to do with it? it;s a private

property
> and
> > you have no idea of how it's used or what it means.
> >
> > Cheers,
> >
> > --
> > Ignacio Machin,
> > ignacio.machin AT dot.state.fl.us
> > Florida Department Of Transportation
> >
> > "Sunny" <su******@icebe rgwireless.com> wrote in message
> > news:uO******** *****@tk2msftng p13.phx.gbl...
> > > Hi,
> > > I have an old problem which I couldn't solve so far. Now I have

found
a
> > post
> > > in that group that gave me an idea, but I can not fully
understand it.
> > > The problem is: I'm trying to use a Windows.Forms.U serControl in
a COM
> > > environment, i.e. I want to host that control in a COM host. So

far, so
> > > good, I can host it, but I can not reach the parent COM object from the
> > > control (Parent property is null :( ).
> > > I have stopped the control in the debugger and I found in the watch > window
> > > some properties, like ActiveXInstance
> > > {System.Windows .Forms.Control. ActiveXImpl}
> > > The problem is that they are private to the base class, so I can not > > access
> > > them.
> > >
> > > Now the question: is it possible somehow to access these base
properties
> > > programmaticall y. I have found a post which mentions something about > > > reflection (whatever that mean). Can I use a reflection to

access these
> > > properties?
> > >
> > > Any help will be highly appreciated.
> > >
> > > Thanks
> > > Sunny
> > >
> > >
> >
> >
>
>



Nov 15 '05 #8
Hi Sunny,

Thanks for the feedback.

Caption is a standard OLE control property. There are not many mentions of
it in the MSDN documentation, especially together with it's numeric value.
I'm pretty sure though it described in OLE 2.0 Programmer's Reference. Also
you can inspect olectl.h - a C header file that comes with VC - to find more
standard properties definitions, they start with DISPID_.

I actually have three problems: (a) Word doesn't persist _my_ properties - I
have a few properties, I can set them from Word programmaticall y but after
the document has been closed and loaded again the properties' values are
lost; (b) Word doesn't show my object in the drop-down box where the
document object and all other objects are (in the Properties window), I can
select my object and open the Properties window but the drop-down box is
empty (it should show the object's name and type) and; (c) Word doesn't show
my properties in it.

thanks,
v

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:#L******** ******@tk2msftn gp13.phx.gbl...
Hi Vladimir,
my problem was not so complicated, but what I learned so far is, that to
expose your .Net property, you have to implement/reimplement it in your
component, and most probably to set a corresponding DispID.
The container I targeted (Outlook PropertyPage) needed one Property (bool
Dirty) and 2 methods (void Apply() and void GetPageInfo(ref string HelpFile, ref int HelpContext)) so I had to implement them. And there was one
undocumented property string Caption for which I had to supply DispID to be recognized:

[DispId(-518)]
public string Caption
{
get
{return this.Name;}
}
So maybe you have to reimplement some of the properties you want to expose
with a corresponding DispID, expected by the host.

All this stuff is new for me, so I'm just guessing, but maybe it should
work. The COM host should use these DispIDs, else what for are they :)

I'm sure that if I remove the DispID part of the declaration of Caption
property, the host didn't find it. Also I just checked, that if you supply
the correct DispID (in my case -518, which I found somewhere that means
Caption) you can change the name of your property to whatever you want. I
have renamed that property to Capsss, and the host still founds it.

Maybe you have to find what DispID's host is expecting, and just to make a
new properties with that DispID, which supplies the necessary values.

Please, let me know what happened.

Sunny

"Vladimir Kouznetsov" <vl************ *****@REMOVETHI Sngrain.com> wrote in
message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
For a some reason my post didn't come through, so I repeat:

Hi Sunny,

I'm glad that was a help.
I was trying to solve a similar problem and the code was a part of the
solution. I don't think I can convert site to IOleClientSite because the
type is not accessible in compile time - it's defined in a private nested
class. Also for a some reason late binding didn't work for the object
(probably because it's a COM object). So I ComImport-ed IDispatch (couldn't
find anything predefined) and called Invoke() to get UserMode ambient
property. I found a (relatively) simpler way of detecting UserMode:

Dim strAssembly As String
strAssembly = Type.GetType("S ystem.Object"). Assembly.CodeBa se
strAssembly = strAssembly.Rep lace("mscorlib. dll", _
"System.Windows .Forms.dll")
strAssembly = strAssembly.Rep lace("file:///", String.Empty)
strAssembly =

Reflection.Asse mblyName.GetAss emblyName(strAs sembly).FullNam e
Dim qualifiedContro lTypeName As String = _
Reflection.Asse mbly.CreateQual ifiedName(strAs sembly,
"System.Windows .Forms.Control" )
Dim ct As Type = Type.GetType(qu alifiedControlT ypeName)
Dim bf As Reflection.Bind ingFlags = _
Reflection.Bind ingFlags.Ignore Case Or _
Reflection.Bind ingFlags.NonPub lic Or _
Reflection.Bind ingFlags.Public Or _
Reflection.Bind ingFlags.Static Or _
Reflection.Bind ingFlags.Instan ce
Dim pi() As Reflection.Prop ertyInfo = ct.GetPropertie s(bf)
Dim axipi As Reflection.Prop ertyInfo = getMemberByName (pi, _
"ActiveXInstanc e")
Dim axi As Object = axipi.GetValue( Me, Nothing)
Dim site As Object = axi.GetClientSi te()
If site Is Nothing Then Return -1

Dim qualifiedActive XImplTypeName As String = _
Reflection.Asse mbly.CreateQual ifiedName(strAs sembly,
"System.Windows .Forms.Control+ ActiveXImpl")
Dim axit As Type = Type.GetType(qu alifiedActiveXI mplTypeName)
pi = axit.GetPropert ies(bf)
Dim dmpi As Reflection.Prop ertyInfo = getMemberByName (pi, "DesignMode ")
Dim ret As Boolean = dmpi.GetValue(a xi, Nothing)
If ret Then Return 1
Return 0

getMemberByName () is function that goes through all array elements and

finds
the one with the given name. Note that I had to use "Control+Active XImpl" type name - GetNestedType() didn't work (any ideas why?). Note that late
binding (GetClientSite( )) works fine now. Note that DesignMode property
actually stores UserMode so it's false in design time.

For a some reason .Net control's properties don't persist in COM

containers.
I'm trying now to figure out why. If you have any thought about that I'd
appreciate any input.

thanks,
v

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:O0******** ******@TK2MSFTN GP10.phx.gbl...
Hi Vladimir,
IT WORKS IT WORKS. You are great. I have implemented this in C# and it

gave
me the reference I needed. I suppose, that I had to implement all of your code, but I stopped at the check for site is Nothing, because I can cast it
at the type I want. So, I do not know what the rest of the code have
to
do.
If you have a little time, pls, explain. Nevertheless so far, you are the only guy around who have succeeded to solve that problem. I have
posted it allover, with different ideas, but ... nothing.

Thank you again
Sunny

"Vladimir Kouznetsov" <vl************ *****@REMOVETHI Sngrain.com> wrote in message news:O9******** ******@TK2MSFTN GP09.phx.gbl...
> Here is a sample code (in VB but it shouldn't not be difficult to
translate
> it) I used to get UserMode property:
>
> Dim strAssembly As String
> strAssembly =
> Type.GetType("S ystem.Object"). Assembly.CodeBa se.Replace("msc orlib.dll", > "System.Windows .Forms.dll")
> strAssembly = strAssembly.Rep lace("file:///", String.Empty)
> strAssembly =
Reflection.Asse mblyName.GetAss emblyName(strAs sembly).FullNam e
> Dim unmt As Type = _
> Type.GetType(Re flection.Assemb ly.CreateQualif iedName(strAsse mbly,
> "System.Windows .Forms.UnsafeNa tiveMethods"))
> Dim ioot As Type = unmt.GetNestedT ype("IOleObject ")
> Dim mi As Reflection.Meth odInfo = ioot.GetMethod( "GetClientSite" )
> Dim site As Object = mi.Invoke(Me, Nothing)
> If site Is Nothing Then Return -1
>
> ' We are hosted by a COM container
>
> Dim dsite As IDispatch = site
>
> ' All the uninitialized arguments work fine in this case
> Dim id As Guid
> Dim params As DISPPARAMS
> Dim lcid As System.UInt32
> Dim wFlags As System.UInt16 = System.UInt16.P arse(2.ToString ())
> Dim result As Object
> dsite.Invoke(-709, id, lcid, wFlags, params, result, Nothing,
Nothing) >
> If result Then
> Return 1
> Else
> Return 0
> End If
>
> That should give you an idea how to do what you want. IIRC IOleClientSite
> has method GetContainer() which I think you need (not the parent COM
> object). BTW You can use ildasm on System.Windows. Forms.dll to make
yourself
> familiar with the internal classes and implementations .
>
> thanks,
> v
>
> "Sunny" <su******@icebe rgwireless.com> wrote in message
> news:ui******** ******@tk2msftn gp13.phx.gbl...
> > Hi, it seems that I have to guess what property to get, so I'll play with
> > all of them, but that happen always with combination

COM/.Net/Outlook
:)
> > The problem is, that I have read some of docs for reflection, and I still
> > have no idea where to start and how to access these private members :( > > So any example will be helpful.
> >
> > Sunny
> >
> > "Ignacio Machin" <ignacio.mach in AT dot.state.fl.us > wrote in message > > news:ul******** ********@TK2MSF TNGP12.phx.gbl. ..
> > > Hi Sunny,
> > >
> > >
> > > I think that yes, it's possible to access the private
properties
of
a
> > class
> > > using reflection, I haven't tested it but I also saw the post of
> Nicholas
> > > and until now all that he said is true ;) , the thing is ( also stated
> in
> > > the post ) what are you planning to do with it? it;s a private
property
> > and
> > > you have no idea of how it's used or what it means.
> > >
> > > Cheers,
> > >
> > > --
> > > Ignacio Machin,
> > > ignacio.machin AT dot.state.fl.us
> > > Florida Department Of Transportation
> > >
> > > "Sunny" <su******@icebe rgwireless.com> wrote in message
> > > news:uO******** *****@tk2msftng p13.phx.gbl...
> > > > Hi,
> > > > I have an old problem which I couldn't solve so far. Now I

have found
> a
> > > post
> > > > in that group that gave me an idea, but I can not fully

understand it.
> > > > The problem is: I'm trying to use a Windows.Forms.U serControl
in a COM
> > > > environment, i.e. I want to host that control in a COM host.
So far,
> so
> > > > good, I can host it, but I can not reach the parent COM object

from
> the
> > > > control (Parent property is null :( ).
> > > > I have stopped the control in the debugger and I found in the

watch
> > window
> > > > some properties, like ActiveXInstance
> > > > {System.Windows .Forms.Control. ActiveXImpl}
> > > > The problem is that they are private to the base class, so I
can not
> > > access
> > > > them.
> > > >
> > > > Now the question: is it possible somehow to access these base
> properties
> > > > programmaticall y. I have found a post which mentions something

about
> > > > reflection (whatever that mean). Can I use a reflection to

access > these
> > > > properties?
> > > >
> > > > Any help will be highly appreciated.
> > > >
> > > > Thanks
> > > > Sunny
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 15 '05 #9
Hi Vladimir,
If I understand correctly, you hooking an object and properties to a word
document. I just guess, but maybe there are something like user properties
(in Outlook there are). And after applying them, you gave to invoke Save
method to save them for next opening. Also, for the object, maybe you have
to capture the OpenDocument event (or similar) and there to hook the object
again. And maybe you have to post a new thread in
..office.develo per.com.add_ins , or if there is a specific newsgroup for word
addins. Maybe someone there will know more for the word object model.
Sorry that I can not help you more, but I haven't deal with word so far.

Sunny

"Vladimir Kouznetsov" <vl************ *****@REMOVETHI Sngrain.com> wrote in
message news:eK******** ******@tk2msftn gp13.phx.gbl...
Hi Sunny,

Thanks for the feedback.

Caption is a standard OLE control property. There are not many mentions of
it in the MSDN documentation, especially together with it's numeric value.
I'm pretty sure though it described in OLE 2.0 Programmer's Reference. Also you can inspect olectl.h - a C header file that comes with VC - to find more standard properties definitions, they start with DISPID_.

I actually have three problems: (a) Word doesn't persist _my_ properties - I have a few properties, I can set them from Word programmaticall y but after
the document has been closed and loaded again the properties' values are
lost; (b) Word doesn't show my object in the drop-down box where the
document object and all other objects are (in the Properties window), I can select my object and open the Properties window but the drop-down box is
empty (it should show the object's name and type) and; (c) Word doesn't show my properties in it.

thanks,
v

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:#L******** ******@tk2msftn gp13.phx.gbl...
Hi Vladimir,
my problem was not so complicated, but what I learned so far is, that to
expose your .Net property, you have to implement/reimplement it in your
component, and most probably to set a corresponding DispID.
The container I targeted (Outlook PropertyPage) needed one Property (bool
Dirty) and 2 methods (void Apply() and void GetPageInfo(ref string HelpFile,
ref int HelpContext)) so I had to implement them. And there was one
undocumented property string Caption for which I had to supply DispID to

be
recognized:

[DispId(-518)]
public string Caption
{
get
{return this.Name;}
}
So maybe you have to reimplement some of the properties you want to expose with a corresponding DispID, expected by the host.

All this stuff is new for me, so I'm just guessing, but maybe it should
work. The COM host should use these DispIDs, else what for are they :)

I'm sure that if I remove the DispID part of the declaration of Caption
property, the host didn't find it. Also I just checked, that if you supply the correct DispID (in my case -518, which I found somewhere that means
Caption) you can change the name of your property to whatever you want. I have renamed that property to Capsss, and the host still founds it.

Maybe you have to find what DispID's host is expecting, and just to make a new properties with that DispID, which supplies the necessary values.

Please, let me know what happened.

Sunny

"Vladimir Kouznetsov" <vl************ *****@REMOVETHI Sngrain.com> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
For a some reason my post didn't come through, so I repeat:

Hi Sunny,

I'm glad that was a help.
I was trying to solve a similar problem and the code was a part of the
solution. I don't think I can convert site to IOleClientSite because the type is not accessible in compile time - it's defined in a private nested class. Also for a some reason late binding didn't work for the object
(probably because it's a COM object). So I ComImport-ed IDispatch

(couldn't
find anything predefined) and called Invoke() to get UserMode ambient
property. I found a (relatively) simpler way of detecting UserMode:

Dim strAssembly As String
strAssembly = Type.GetType("S ystem.Object"). Assembly.CodeBa se
strAssembly = strAssembly.Rep lace("mscorlib. dll", _
"System.Windows .Forms.dll")
strAssembly = strAssembly.Rep lace("file:///", String.Empty)
strAssembly =

Reflection.Asse mblyName.GetAss emblyName(strAs sembly).FullNam e
Dim qualifiedContro lTypeName As String = _
Reflection.Asse mbly.CreateQual ifiedName(strAs sembly,
"System.Windows .Forms.Control" )
Dim ct As Type = Type.GetType(qu alifiedControlT ypeName)
Dim bf As Reflection.Bind ingFlags = _
Reflection.Bind ingFlags.Ignore Case Or _
Reflection.Bind ingFlags.NonPub lic Or _
Reflection.Bind ingFlags.Public Or _
Reflection.Bind ingFlags.Static Or _
Reflection.Bind ingFlags.Instan ce
Dim pi() As Reflection.Prop ertyInfo = ct.GetPropertie s(bf)
Dim axipi As Reflection.Prop ertyInfo = getMemberByName (pi, _
"ActiveXInstanc e")
Dim axi As Object = axipi.GetValue( Me, Nothing)
Dim site As Object = axi.GetClientSi te()
If site Is Nothing Then Return -1

Dim qualifiedActive XImplTypeName As String = _
Reflection.Asse mbly.CreateQual ifiedName(strAs sembly,
"System.Windows .Forms.Control+ ActiveXImpl")
Dim axit As Type = Type.GetType(qu alifiedActiveXI mplTypeName)
pi = axit.GetPropert ies(bf)
Dim dmpi As Reflection.Prop ertyInfo = getMemberByName (pi, "DesignMode ") Dim ret As Boolean = dmpi.GetValue(a xi, Nothing)
If ret Then Return 1
Return 0

getMemberByName () is function that goes through all array elements and

finds
the one with the given name. Note that I had to use "Control+Active XImpl" type name - GetNestedType() didn't work (any ideas why?). Note that late binding (GetClientSite( )) works fine now. Note that DesignMode property actually stores UserMode so it's false in design time.

For a some reason .Net control's properties don't persist in COM

containers.
I'm trying now to figure out why. If you have any thought about that I'd appreciate any input.

thanks,
v

"Sunny" <su******@icebe rgwireless.com> wrote in message
news:O0******** ******@TK2MSFTN GP10.phx.gbl...
> Hi Vladimir,
> IT WORKS IT WORKS. You are great. I have implemented this in C# and it gave
> me the reference I needed. I suppose, that I had to implement all of

your
> code, but I stopped at the check for site is Nothing, because I can cast it
> at the type I want. So, I do not know what the rest of the code have to do.
> If you have a little time, pls, explain. Nevertheless so far, you are the
> only guy around who have succeeded to solve that problem. I have posted
it
> allover, with different ideas, but ... nothing.
>
> Thank you again
> Sunny
>
> "Vladimir Kouznetsov" <vl************ *****@REMOVETHI Sngrain.com>
wrote in
> message news:O9******** ******@TK2MSFTN GP09.phx.gbl...
> > Here is a sample code (in VB but it shouldn't not be difficult to
> translate
> > it) I used to get UserMode property:
> >
> > Dim strAssembly As String
> > strAssembly =
> >

Type.GetType("S ystem.Object"). Assembly.CodeBa se.Replace("msc orlib.dll",
> > "System.Windows .Forms.dll")
> > strAssembly = strAssembly.Rep lace("file:///", String.Empty)
> > strAssembly =
> Reflection.Asse mblyName.GetAss emblyName(strAs sembly).FullNam e
> > Dim unmt As Type = _
> >

Type.GetType(Re flection.Assemb ly.CreateQualif iedName(strAsse mbly, > > "System.Windows .Forms.UnsafeNa tiveMethods"))
> > Dim ioot As Type = unmt.GetNestedT ype("IOleObject ")
> > Dim mi As Reflection.Meth odInfo = ioot.GetMethod( "GetClientSite" )
> > Dim site As Object = mi.Invoke(Me, Nothing)
> > If site Is Nothing Then Return -1
> >
> > ' We are hosted by a COM container
> >
> > Dim dsite As IDispatch = site
> >
> > ' All the uninitialized arguments work fine in this case
> > Dim id As Guid
> > Dim params As DISPPARAMS
> > Dim lcid As System.UInt32
> > Dim wFlags As System.UInt16 = System.UInt16.P arse(2.ToString ())
> > Dim result As Object
> > dsite.Invoke(-709, id, lcid, wFlags, params, result, Nothing,

Nothing) > >
> > If result Then
> > Return 1
> > Else
> > Return 0
> > End If
> >
> > That should give you an idea how to do what you want. IIRC
IOleClientSite
> > has method GetContainer() which I think you need (not the parent COM > > object). BTW You can use ildasm on System.Windows. Forms.dll to make > yourself
> > familiar with the internal classes and implementations .
> >
> > thanks,
> > v
> >
> > "Sunny" <su******@icebe rgwireless.com> wrote in message
> > news:ui******** ******@tk2msftn gp13.phx.gbl...
> > > Hi, it seems that I have to guess what property to get, so I'll play > with
> > > all of them, but that happen always with combination

COM/.Net/Outlook
:)
> > > The problem is, that I have read some of docs for reflection, and I
> still
> > > have no idea where to start and how to access these private members
:(
> > > So any example will be helpful.
> > >
> > > Sunny
> > >
> > > "Ignacio Machin" <ignacio.mach in AT dot.state.fl.us > wrote in message
> > > news:ul******** ********@TK2MSF TNGP12.phx.gbl. ..
> > > > Hi Sunny,
> > > >
> > > >
> > > > I think that yes, it's possible to access the private

properties
of
a
> > > class
> > > > using reflection, I haven't tested it but I also saw the post

of > > Nicholas
> > > > and until now all that he said is true ;) , the thing is ( also stated
> > in
> > > > the post ) what are you planning to do with it? it;s a private
> property
> > > and
> > > > you have no idea of how it's used or what it means.
> > > >
> > > > Cheers,
> > > >
> > > > --
> > > > Ignacio Machin,
> > > > ignacio.machin AT dot.state.fl.us
> > > > Florida Department Of Transportation
> > > >
> > > > "Sunny" <su******@icebe rgwireless.com> wrote in message
> > > > news:uO******** *****@tk2msftng p13.phx.gbl...
> > > > > Hi,
> > > > > I have an old problem which I couldn't solve so far. Now I

have > found
> > a
> > > > post
> > > > > in that group that gave me an idea, but I can not fully

understand
> it.
> > > > > The problem is: I'm trying to use a Windows.Forms.U serControl in
a
> COM
> > > > > environment, i.e. I want to host that control in a COM host. So far,
> > so
> > > > > good, I can host it, but I can not reach the parent COM
object from
> > the
> > > > > control (Parent property is null :( ).
> > > > > I have stopped the control in the debugger and I found in the watch
> > > window
> > > > > some properties, like ActiveXInstance
> > > > > {System.Windows .Forms.Control. ActiveXImpl}
> > > > > The problem is that they are private to the base class, so I

can not
> > > > access
> > > > > them.
> > > > >
> > > > > Now the question: is it possible somehow to access these base > > properties
> > > > > programmaticall y. I have found a post which mentions something about
> > > > > reflection (whatever that mean). Can I use a reflection to

access
> > these
> > > > > properties?
> > > > >
> > > > > Any help will be highly appreciated.
> > > > >
> > > > > Thanks
> > > > > Sunny
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3164
by: vijay | last post by:
Hello I wanted to understand a contradictory design of C++ class A {public: virtual void f(){ cout<<" base f"<<endl; } }; class B:public A {
6
1682
by: Alf P. Steinbach | last post by:
#include <iostream> struct Belcher { int x; void belch() { std::cout << x << std::endl; } Belcher( int anX ): x( anX ) {} }; struct Person: private Belcher { Person(): Belcher( 666 ) {} };
1
4237
by: Marc Scheuner [MVP ADSI] | last post by:
Folks, I've created a descendant of ListView, and I would like to be able to tell it to "hide" two of the base class's properties - how can I accomplish this? I know I can add a attribute to the properties to remove them from the object inspector window - that's not all, though - I'd like to make them unavailable from code, too.
12
1557
by: Chris | last post by:
Hi I am trying to create a base class with the Protected keyword Protected MustInherit Class MyBaseClas .. .. End Clas And I got an error saying something like the Protected keyword cannot be used
6
2498
by: Taran | last post by:
Hi All, I tried something with the C++ I know and some things just seem strange. consider: #include <iostream> using namespace std;
11
2872
by: Darren.Ratcliffe | last post by:
Hi guys Posted what was probably a rather confusing post about this the other day, so I am going to have another go and see if I can make more sense. This sis purely a I've got a base class called animal, and from within animal you can access lots more classes such as feline, canine, reptile and amphibian.....
0
1315
by: Tech quest | last post by:
Hi, I have a C# Class Libarary which is exposed to COM. The issue is base class members are not exposed to COM.As per msdn http://msdn2.microsoft.com/en-us/library/8877bdk6(VS.80).aspx Managed Clas hierarchies flatten out when exposed as COM objects. Please let me know how i can resove this issue. Thanks a lot in advance Here is the sample Application Code: The issue is base class member properties VehicleName ,Vehicle Type are not...
1
1975
by: Charles Law | last post by:
I have a base class MyBaseClass, and several classes that inherit from it: MyClass1, MyClass2, etc. The base class implements IEnumerable(Of IMyBaseClassRow). The base class has a DataTable object that contains different data depending on which of MyClass1, MyClass2 are instantiated. I want to be able to iterate through the rows of the data table using For Each on my derived classes retrieving a custom row with properties specific to...
6
2818
by: Charles Law | last post by:
I have a base class and derived classes that relate to a set of documents I process. e.g. DocBase, DocA, DocB, DocC. The processing of each document is handled in teh derived classes, as you might imagine, but the base class has properties and methods that are common to all documents. The processing of each docuemnt can result in a range of document specific errors, which I want to raise as events on the document object, but there are...
0
9215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9064
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8007
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.