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.UserControl 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
programmatically. 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 | | | | re: reflection, base class private properties, etc.
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" <sunnyask@icebergwireless.com> wrote in message
news:uOAH2n1ZDHA.656@tk2msftngp13.phx.gbl...[color=blue]
> Hi,
> I have an old problem which I couldn't solve so far. Now I have found a[/color]
post[color=blue]
> 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.UserControl 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[/color]
access[color=blue]
> them.
>
> Now the question: is it possible somehow to access these base properties
> programmatically. 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
>
>[/color] | | | | re: reflection, base class private properties, etc.
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.machin AT dot.state.fl.us> wrote in message
news:ul0DL$%23ZDHA.2284@TK2MSFTNGP12.phx.gbl...[color=blue]
> Hi Sunny,
>
>
> I think that yes, it's possible to access the private properties of a[/color]
class[color=blue]
> 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[/color]
and[color=blue]
> 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" <sunnyask@icebergwireless.com> wrote in message
> news:uOAH2n1ZDHA.656@tk2msftngp13.phx.gbl...[color=green]
> > Hi,
> > I have an old problem which I couldn't solve so far. Now I have found a[/color]
> post[color=green]
> > 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.UserControl 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[/color][/color]
window[color=blue][color=green]
> > some properties, like ActiveXInstance
> > {System.Windows.Forms.Control.ActiveXImpl}
> > The problem is that they are private to the base class, so I can not[/color]
> access[color=green]
> > them.
> >
> > Now the question: is it possible somehow to access these base properties
> > programmatically. 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
> >
> >[/color]
>
>[/color] | | | | re: reflection, base class private properties, etc.
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("System.Object").Assembly.CodeBase.Re place("mscorlib.dll",
"System.Windows.Forms.dll")
strAssembly = strAssembly.Replace("file:///", String.Empty)
strAssembly = Reflection.AssemblyName.GetAssemblyName(strAssembl y).FullName
Dim unmt As Type = _
Type.GetType(Reflection.Assembly.CreateQualifiedNa me(strAssembly,
"System.Windows.Forms.UnsafeNativeMethods"))
Dim ioot As Type = unmt.GetNestedType("IOleObject")
Dim mi As Reflection.MethodInfo = 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.Parse(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" <sunnyask@icebergwireless.com> wrote in message
news:uixm4aBaDHA.3248@tk2msftngp13.phx.gbl...[color=blue]
> 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.machin AT dot.state.fl.us> wrote in message
> news:ul0DL$%23ZDHA.2284@TK2MSFTNGP12.phx.gbl...[color=green]
> > Hi Sunny,
> >
> >
> > I think that yes, it's possible to access the private properties of a[/color]
> class[color=green]
> > using reflection, I haven't tested it but I also saw the post of[/color][/color]
Nicholas[color=blue][color=green]
> > and until now all that he said is true ;) , the thing is ( also stated[/color][/color]
in[color=blue][color=green]
> > the post ) what are you planning to do with it? it;s a private property[/color]
> and[color=green]
> > 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" <sunnyask@icebergwireless.com> wrote in message
> > news:uOAH2n1ZDHA.656@tk2msftngp13.phx.gbl...[color=darkred]
> > > Hi,
> > > I have an old problem which I couldn't solve so far. Now I have found[/color][/color][/color]
a[color=blue][color=green]
> > post[color=darkred]
> > > 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.UserControl in a COM
> > > environment, i.e. I want to host that control in a COM host. So far,[/color][/color][/color]
so[color=blue][color=green][color=darkred]
> > > good, I can host it, but I can not reach the parent COM object from[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > control (Parent property is null :( ).
> > > I have stopped the control in the debugger and I found in the watch[/color][/color]
> window[color=green][color=darkred]
> > > some properties, like ActiveXInstance
> > > {System.Windows.Forms.Control.ActiveXImpl}
> > > The problem is that they are private to the base class, so I can not[/color]
> > access[color=darkred]
> > > them.
> > >
> > > Now the question: is it possible somehow to access these base[/color][/color][/color]
properties[color=blue][color=green][color=darkred]
> > > programmatically. I have found a post which mentions something about
> > > reflection (whatever that mean). Can I use a reflection to access[/color][/color][/color]
these[color=blue][color=green][color=darkred]
> > > properties?
> > >
> > > Any help will be highly appreciated.
> > >
> > > Thanks
> > > Sunny
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: reflection, base class private properties, etc.
Thank you Vladimir, I'll see what will happen with this and let you know.
Sunny
"Vladimir Kouznetsov" <vladimir.kouznetsov@REMOVETHISngrain.com> wrote in
message news:O9HpW1BaDHA.2464@TK2MSFTNGP09.phx.gbl...[color=blue]
> Here is a sample code (in VB but it shouldn't not be difficult to[/color]
translate[color=blue]
> it) I used to get UserMode property:
>
> Dim strAssembly As String
> strAssembly =
> Type.GetType("System.Object").Assembly.CodeBase.Re place("mscorlib.dll",
> "System.Windows.Forms.dll")
> strAssembly = strAssembly.Replace("file:///", String.Empty)
> strAssembly =[/color]
Reflection.AssemblyName.GetAssemblyName(strAssembl y).FullName[color=blue]
> Dim unmt As Type = _
> Type.GetType(Reflection.Assembly.CreateQualifiedNa me(strAssembly,
> "System.Windows.Forms.UnsafeNativeMethods"))
> Dim ioot As Type = unmt.GetNestedType("IOleObject")
> Dim mi As Reflection.MethodInfo = 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.Parse(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[/color]
yourself[color=blue]
> familiar with the internal classes and implementations.
>
> thanks,
> v
>
> "Sunny" <sunnyask@icebergwireless.com> wrote in message
> news:uixm4aBaDHA.3248@tk2msftngp13.phx.gbl...[color=green]
> > Hi, it seems that I have to guess what property to get, so I'll play[/color][/color]
with[color=blue][color=green]
> > 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[/color][/color]
still[color=blue][color=green]
> > have no idea where to start and how to access these private members :(
> > So any example will be helpful.
> >
> > Sunny
> >
> > "Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
> > news:ul0DL$%23ZDHA.2284@TK2MSFTNGP12.phx.gbl...[color=darkred]
> > > Hi Sunny,
> > >
> > >
> > > I think that yes, it's possible to access the private properties of a[/color]
> > class[color=darkred]
> > > using reflection, I haven't tested it but I also saw the post of[/color][/color]
> Nicholas[color=green][color=darkred]
> > > and until now all that he said is true ;) , the thing is ( also stated[/color][/color]
> in[color=green][color=darkred]
> > > the post ) what are you planning to do with it? it;s a private[/color][/color][/color]
property[color=blue][color=green]
> > and[color=darkred]
> > > 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" <sunnyask@icebergwireless.com> wrote in message
> > > news:uOAH2n1ZDHA.656@tk2msftngp13.phx.gbl...
> > > > Hi,
> > > > I have an old problem which I couldn't solve so far. Now I have[/color][/color][/color]
found[color=blue]
> a[color=green][color=darkred]
> > > post
> > > > in that group that gave me an idea, but I can not fully understand[/color][/color][/color]
it.[color=blue][color=green][color=darkred]
> > > > The problem is: I'm trying to use a Windows.Forms.UserControl in a[/color][/color][/color]
COM[color=blue][color=green][color=darkred]
> > > > environment, i.e. I want to host that control in a COM host. So far,[/color][/color]
> so[color=green][color=darkred]
> > > > good, I can host it, but I can not reach the parent COM object from[/color][/color]
> the[color=green][color=darkred]
> > > > control (Parent property is null :( ).
> > > > I have stopped the control in the debugger and I found in the watch[/color]
> > window[color=darkred]
> > > > 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[/color][/color]
> properties[color=green][color=darkred]
> > > > programmatically. I have found a post which mentions something about
> > > > reflection (whatever that mean). Can I use a reflection to access[/color][/color]
> these[color=green][color=darkred]
> > > > properties?
> > > >
> > > > Any help will be highly appreciated.
> > > >
> > > > Thanks
> > > > Sunny
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: reflection, base class private properties, etc.
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" <vladimir.kouznetsov@REMOVETHISngrain.com> wrote in
message news:O9HpW1BaDHA.2464@TK2MSFTNGP09.phx.gbl...[color=blue]
> Here is a sample code (in VB but it shouldn't not be difficult to[/color]
translate[color=blue]
> it) I used to get UserMode property:
>
> Dim strAssembly As String
> strAssembly =
> Type.GetType("System.Object").Assembly.CodeBase.Re place("mscorlib.dll",
> "System.Windows.Forms.dll")
> strAssembly = strAssembly.Replace("file:///", String.Empty)
> strAssembly =[/color]
Reflection.AssemblyName.GetAssemblyName(strAssembl y).FullName[color=blue]
> Dim unmt As Type = _
> Type.GetType(Reflection.Assembly.CreateQualifiedNa me(strAssembly,
> "System.Windows.Forms.UnsafeNativeMethods"))
> Dim ioot As Type = unmt.GetNestedType("IOleObject")
> Dim mi As Reflection.MethodInfo = 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.Parse(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[/color]
yourself[color=blue]
> familiar with the internal classes and implementations.
>
> thanks,
> v
>
> "Sunny" <sunnyask@icebergwireless.com> wrote in message
> news:uixm4aBaDHA.3248@tk2msftngp13.phx.gbl...[color=green]
> > Hi, it seems that I have to guess what property to get, so I'll play[/color][/color]
with[color=blue][color=green]
> > 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[/color][/color]
still[color=blue][color=green]
> > have no idea where to start and how to access these private members :(
> > So any example will be helpful.
> >
> > Sunny
> >
> > "Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
> > news:ul0DL$%23ZDHA.2284@TK2MSFTNGP12.phx.gbl...[color=darkred]
> > > Hi Sunny,
> > >
> > >
> > > I think that yes, it's possible to access the private properties of a[/color]
> > class[color=darkred]
> > > using reflection, I haven't tested it but I also saw the post of[/color][/color]
> Nicholas[color=green][color=darkred]
> > > and until now all that he said is true ;) , the thing is ( also stated[/color][/color]
> in[color=green][color=darkred]
> > > the post ) what are you planning to do with it? it;s a private[/color][/color][/color]
property[color=blue][color=green]
> > and[color=darkred]
> > > 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" <sunnyask@icebergwireless.com> wrote in message
> > > news:uOAH2n1ZDHA.656@tk2msftngp13.phx.gbl...
> > > > Hi,
> > > > I have an old problem which I couldn't solve so far. Now I have[/color][/color][/color]
found[color=blue]
> a[color=green][color=darkred]
> > > post
> > > > in that group that gave me an idea, but I can not fully understand[/color][/color][/color]
it.[color=blue][color=green][color=darkred]
> > > > The problem is: I'm trying to use a Windows.Forms.UserControl in a[/color][/color][/color]
COM[color=blue][color=green][color=darkred]
> > > > environment, i.e. I want to host that control in a COM host. So far,[/color][/color]
> so[color=green][color=darkred]
> > > > good, I can host it, but I can not reach the parent COM object from[/color][/color]
> the[color=green][color=darkred]
> > > > control (Parent property is null :( ).
> > > > I have stopped the control in the debugger and I found in the watch[/color]
> > window[color=darkred]
> > > > 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[/color][/color]
> properties[color=green][color=darkred]
> > > > programmatically. I have found a post which mentions something about
> > > > reflection (whatever that mean). Can I use a reflection to access[/color][/color]
> these[color=green][color=darkred]
> > > > properties?
> > > >
> > > > Any help will be highly appreciated.
> > > >
> > > > Thanks
> > > > Sunny
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: reflection, base class private properties, etc.
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("System.Object").Assembly.CodeBase
strAssembly = strAssembly.Replace("mscorlib.dll", _
"System.Windows.Forms.dll")
strAssembly = strAssembly.Replace("file:///", String.Empty)
strAssembly = Reflection.AssemblyName.GetAssemblyName(strAssembl y).FullName
Dim qualifiedControlTypeName As String = _
Reflection.Assembly.CreateQualifiedName(strAssembl y,
"System.Windows.Forms.Control")
Dim ct As Type = Type.GetType(qualifiedControlTypeName)
Dim bf As Reflection.BindingFlags = _
Reflection.BindingFlags.IgnoreCase Or _
Reflection.BindingFlags.NonPublic Or _
Reflection.BindingFlags.Public Or _
Reflection.BindingFlags.Static Or _
Reflection.BindingFlags.Instance
Dim pi() As Reflection.PropertyInfo = ct.GetProperties(bf)
Dim axipi As Reflection.PropertyInfo = getMemberByName(pi, _
"ActiveXInstance")
Dim axi As Object = axipi.GetValue(Me, Nothing)
Dim site As Object = axi.GetClientSite()
If site Is Nothing Then Return -1
Dim qualifiedActiveXImplTypeName As String = _
Reflection.Assembly.CreateQualifiedName(strAssembl y,
"System.Windows.Forms.Control+ActiveXImpl")
Dim axit As Type = Type.GetType(qualifiedActiveXImplTypeName)
pi = axit.GetProperties(bf)
Dim dmpi As Reflection.PropertyInfo = getMemberByName(pi, "DesignMode")
Dim ret As Boolean = dmpi.GetValue(axi, 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+ActiveXImpl"
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" <sunnyask@icebergwireless.com> wrote in message
news:O0NdRG0aDHA.2016@TK2MSFTNGP10.phx.gbl...[color=blue]
> Hi Vladimir,
> IT WORKS IT WORKS. You are great. I have implemented this in C# and it[/color]
gave[color=blue]
> 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[/color]
it[color=blue]
> at the type I want. So, I do not know what the rest of the code have to[/color]
do.[color=blue]
> 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" <vladimir.kouznetsov@REMOVETHISngrain.com> wrote in
> message news:O9HpW1BaDHA.2464@TK2MSFTNGP09.phx.gbl...[color=green]
> > Here is a sample code (in VB but it shouldn't not be difficult to[/color]
> translate[color=green]
> > it) I used to get UserMode property:
> >
> > Dim strAssembly As String
> > strAssembly =
> > Type.GetType("System.Object").Assembly.CodeBase.Re place("mscorlib.dll",
> > "System.Windows.Forms.dll")
> > strAssembly = strAssembly.Replace("file:///", String.Empty)
> > strAssembly =[/color]
> Reflection.AssemblyName.GetAssemblyName(strAssembl y).FullName[color=green]
> > Dim unmt As Type = _
> > Type.GetType(Reflection.Assembly.CreateQualifiedNa me(strAssembly,
> > "System.Windows.Forms.UnsafeNativeMethods"))
> > Dim ioot As Type = unmt.GetNestedType("IOleObject")
> > Dim mi As Reflection.MethodInfo = 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.Parse(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[/color][/color]
IOleClientSite[color=blue][color=green]
> > 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[/color]
> yourself[color=green]
> > familiar with the internal classes and implementations.
> >
> > thanks,
> > v
> >
> > "Sunny" <sunnyask@icebergwireless.com> wrote in message
> > news:uixm4aBaDHA.3248@tk2msftngp13.phx.gbl...[color=darkred]
> > > Hi, it seems that I have to guess what property to get, so I'll play[/color][/color]
> with[color=green][color=darkred]
> > > all of them, but that happen always with combination COM/.Net/Outlook[/color][/color][/color]
:)[color=blue][color=green][color=darkred]
> > > The problem is, that I have read some of docs for reflection, and I[/color][/color]
> still[color=green][color=darkred]
> > > have no idea where to start and how to access these private members :(
> > > So any example will be helpful.
> > >
> > > Sunny
> > >
> > > "Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
> > > news:ul0DL$%23ZDHA.2284@TK2MSFTNGP12.phx.gbl...
> > > > Hi Sunny,
> > > >
> > > >
> > > > I think that yes, it's possible to access the private properties of[/color][/color][/color]
a[color=blue][color=green][color=darkred]
> > > class
> > > > using reflection, I haven't tested it but I also saw the post of[/color]
> > Nicholas[color=darkred]
> > > > and until now all that he said is true ;) , the thing is ( also[/color][/color][/color]
stated[color=blue][color=green]
> > in[color=darkred]
> > > > the post ) what are you planning to do with it? it;s a private[/color][/color]
> property[color=green][color=darkred]
> > > 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" <sunnyask@icebergwireless.com> wrote in message
> > > > news:uOAH2n1ZDHA.656@tk2msftngp13.phx.gbl...
> > > > > Hi,
> > > > > I have an old problem which I couldn't solve so far. Now I have[/color][/color]
> found[color=green]
> > a[color=darkred]
> > > > post
> > > > > in that group that gave me an idea, but I can not fully understand[/color][/color]
> it.[color=green][color=darkred]
> > > > > The problem is: I'm trying to use a Windows.Forms.UserControl in a[/color][/color]
> COM[color=green][color=darkred]
> > > > > environment, i.e. I want to host that control in a COM host. So[/color][/color][/color]
far,[color=blue][color=green]
> > so[color=darkred]
> > > > > good, I can host it, but I can not reach the parent COM object[/color][/color][/color]
from[color=blue][color=green]
> > the[color=darkred]
> > > > > control (Parent property is null :( ).
> > > > > I have stopped the control in the debugger and I found in the[/color][/color][/color]
watch[color=blue][color=green][color=darkred]
> > > window
> > > > > some properties, like ActiveXInstance
> > > > > {System.Windows.Forms.Control.ActiveXImpl}
> > > > > The problem is that they are private to the base class, so I can[/color][/color][/color]
not[color=blue][color=green][color=darkred]
> > > > access
> > > > > them.
> > > > >
> > > > > Now the question: is it possible somehow to access these base[/color]
> > properties[color=darkred]
> > > > > programmatically. I have found a post which mentions something[/color][/color][/color]
about[color=blue][color=green][color=darkred]
> > > > > reflection (whatever that mean). Can I use a reflection to access[/color]
> > these[color=darkred]
> > > > > properties?
> > > > >
> > > > > Any help will be highly appreciated.
> > > > >
> > > > > Thanks
> > > > > Sunny
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: reflection, base class private properties, etc.
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" <vladimir.kouznetsov@REMOVETHISngrain.com> wrote in
message news:%23opLGfNbDHA.2344@TK2MSFTNGP12.phx.gbl...
[color=blue]
> 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[/color]
(couldn't[color=blue]
> 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("System.Object").Assembly.CodeBase
> strAssembly = strAssembly.Replace("mscorlib.dll", _
> "System.Windows.Forms.dll")
> strAssembly = strAssembly.Replace("file:///", String.Empty)
> strAssembly =[/color]
Reflection.AssemblyName.GetAssemblyName(strAssembl y).FullName[color=blue]
> Dim qualifiedControlTypeName As String = _
> Reflection.Assembly.CreateQualifiedName(strAssembl y,
> "System.Windows.Forms.Control")
> Dim ct As Type = Type.GetType(qualifiedControlTypeName)
> Dim bf As Reflection.BindingFlags = _
> Reflection.BindingFlags.IgnoreCase Or _
> Reflection.BindingFlags.NonPublic Or _
> Reflection.BindingFlags.Public Or _
> Reflection.BindingFlags.Static Or _
> Reflection.BindingFlags.Instance
> Dim pi() As Reflection.PropertyInfo = ct.GetProperties(bf)
> Dim axipi As Reflection.PropertyInfo = getMemberByName(pi, _
> "ActiveXInstance")
> Dim axi As Object = axipi.GetValue(Me, Nothing)
> Dim site As Object = axi.GetClientSite()
> If site Is Nothing Then Return -1
>
> Dim qualifiedActiveXImplTypeName As String = _
> Reflection.Assembly.CreateQualifiedName(strAssembl y,
> "System.Windows.Forms.Control+ActiveXImpl")
> Dim axit As Type = Type.GetType(qualifiedActiveXImplTypeName)
> pi = axit.GetProperties(bf)
> Dim dmpi As Reflection.PropertyInfo = getMemberByName(pi, "DesignMode")
> Dim ret As Boolean = dmpi.GetValue(axi, Nothing)
> If ret Then Return 1
> Return 0
>
> getMemberByName() is function that goes through all array elements and[/color]
finds[color=blue]
> the one with the given name. Note that I had to use "Control+ActiveXImpl"
> 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[/color]
containers.[color=blue]
> I'm trying now to figure out why. If you have any thought about that I'd
> appreciate any input.
>
> thanks,
> v
>
> "Sunny" <sunnyask@icebergwireless.com> wrote in message
> news:O0NdRG0aDHA.2016@TK2MSFTNGP10.phx.gbl...[color=green]
> > Hi Vladimir,
> > IT WORKS IT WORKS. You are great. I have implemented this in C# and it[/color]
> gave[color=green]
> > me the reference I needed. I suppose, that I had to implement all of[/color][/color]
your[color=blue][color=green]
> > code, but I stopped at the check for site is Nothing, because I can cast[/color]
> it[color=green]
> > at the type I want. So, I do not know what the rest of the code have to[/color]
> do.[color=green]
> > If you have a little time, pls, explain. Nevertheless so far, you are[/color][/color]
the[color=blue][color=green]
> > only guy around who have succeeded to solve that problem. I have posted[/color][/color]
it[color=blue][color=green]
> > allover, with different ideas, but ... nothing.
> >
> > Thank you again
> > Sunny
> >
> > "Vladimir Kouznetsov" <vladimir.kouznetsov@REMOVETHISngrain.com> wrote[/color][/color]
in[color=blue][color=green]
> > message news:O9HpW1BaDHA.2464@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > Here is a sample code (in VB but it shouldn't not be difficult to[/color]
> > translate[color=darkred]
> > > it) I used to get UserMode property:
> > >
> > > Dim strAssembly As String
> > > strAssembly =
> > >[/color][/color][/color]
Type.GetType("System.Object").Assembly.CodeBase.Re place("mscorlib.dll",[color=blue][color=green][color=darkred]
> > > "System.Windows.Forms.dll")
> > > strAssembly = strAssembly.Replace("file:///", String.Empty)
> > > strAssembly =[/color]
> > Reflection.AssemblyName.GetAssemblyName(strAssembl y).FullName[color=darkred]
> > > Dim unmt As Type = _
> > > Type.GetType(Reflection.Assembly.CreateQualifiedNa me(strAssembly,
> > > "System.Windows.Forms.UnsafeNativeMethods"))
> > > Dim ioot As Type = unmt.GetNestedType("IOleObject")
> > > Dim mi As Reflection.MethodInfo = 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.Parse(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[/color][/color]
> IOleClientSite[color=green][color=darkred]
> > > 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[/color]
> > yourself[color=darkred]
> > > familiar with the internal classes and implementations.
> > >
> > > thanks,
> > > v
> > >
> > > "Sunny" <sunnyask@icebergwireless.com> wrote in message
> > > news:uixm4aBaDHA.3248@tk2msftngp13.phx.gbl...
> > > > Hi, it seems that I have to guess what property to get, so I'll play[/color]
> > with[color=darkred]
> > > > all of them, but that happen always with combination[/color][/color][/color]
COM/.Net/Outlook[color=blue]
> :)[color=green][color=darkred]
> > > > The problem is, that I have read some of docs for reflection, and I[/color]
> > still[color=darkred]
> > > > have no idea where to start and how to access these private members[/color][/color][/color]
:([color=blue][color=green][color=darkred]
> > > > So any example will be helpful.
> > > >
> > > > Sunny
> > > >
> > > > "Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in[/color][/color][/color]
message[color=blue][color=green][color=darkred]
> > > > news:ul0DL$%23ZDHA.2284@TK2MSFTNGP12.phx.gbl...
> > > > > Hi Sunny,
> > > > >
> > > > >
> > > > > I think that yes, it's possible to access the private properties[/color][/color][/color]
of[color=blue]
> a[color=green][color=darkred]
> > > > 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[/color][/color]
> stated[color=green][color=darkred]
> > > in
> > > > > the post ) what are you planning to do with it? it;s a private[/color]
> > property[color=darkred]
> > > > 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" <sunnyask@icebergwireless.com> wrote in message
> > > > > news:uOAH2n1ZDHA.656@tk2msftngp13.phx.gbl...
> > > > > > Hi,
> > > > > > I have an old problem which I couldn't solve so far. Now I have[/color]
> > found[color=darkred]
> > > a
> > > > > post
> > > > > > in that group that gave me an idea, but I can not fully[/color][/color][/color]
understand[color=blue][color=green]
> > it.[color=darkred]
> > > > > > The problem is: I'm trying to use a Windows.Forms.UserControl in[/color][/color][/color]
a[color=blue][color=green]
> > COM[color=darkred]
> > > > > > environment, i.e. I want to host that control in a COM host. So[/color][/color]
> far,[color=green][color=darkred]
> > > so
> > > > > > good, I can host it, but I can not reach the parent COM object[/color][/color]
> from[color=green][color=darkred]
> > > the
> > > > > > control (Parent property is null :( ).
> > > > > > I have stopped the control in the debugger and I found in the[/color][/color]
> watch[color=green][color=darkred]
> > > > window
> > > > > > some properties, like ActiveXInstance
> > > > > > {System.Windows.Forms.Control.ActiveXImpl}
> > > > > > The problem is that they are private to the base class, so I can[/color][/color]
> not[color=green][color=darkred]
> > > > > access
> > > > > > them.
> > > > > >
> > > > > > Now the question: is it possible somehow to access these base
> > > properties
> > > > > > programmatically. I have found a post which mentions something[/color][/color]
> about[color=green][color=darkred]
> > > > > > reflection (whatever that mean). Can I use a reflection to[/color][/color][/color]
access[color=blue][color=green][color=darkred]
> > > these
> > > > > > properties?
> > > > > >
> > > > > > Any help will be highly appreciated.
> > > > > >
> > > > > > Thanks
> > > > > > Sunny
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: reflection, base class private properties, etc.
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 programmatically 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" <sunnyask@icebergwireless.com> wrote in message
news:#LpVi$NbDHA.3768@tk2msftngp13.phx.gbl...[color=blue]
> 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[/color]
HelpFile,[color=blue]
> 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[/color]
be[color=blue]
> 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" <vladimir.kouznetsov@REMOVETHISngrain.com> wrote in
> message news:%23opLGfNbDHA.2344@TK2MSFTNGP12.phx.gbl...
>[color=green]
> > 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[/color][/color]
nested[color=blue][color=green]
> > 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[/color]
> (couldn't[color=green]
> > 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("System.Object").Assembly.CodeBase
> > strAssembly = strAssembly.Replace("mscorlib.dll", _
> > "System.Windows.Forms.dll")
> > strAssembly = strAssembly.Replace("file:///", String.Empty)
> > strAssembly =[/color]
> Reflection.AssemblyName.GetAssemblyName(strAssembl y).FullName[color=green]
> > Dim qualifiedControlTypeName As String = _
> > Reflection.Assembly.CreateQualifiedName(strAssembl y,
> > "System.Windows.Forms.Control")
> > Dim ct As Type = Type.GetType(qualifiedControlTypeName)
> > Dim bf As Reflection.BindingFlags = _
> > Reflection.BindingFlags.IgnoreCase Or _
> > Reflection.BindingFlags.NonPublic Or _
> > Reflection.BindingFlags.Public Or _
> > Reflection.BindingFlags.Static Or _
> > Reflection.BindingFlags.Instance
> > Dim pi() As Reflection.PropertyInfo = ct.GetProperties(bf)
> > Dim axipi As Reflection.PropertyInfo = getMemberByName(pi, _
> > "ActiveXInstance")
> > Dim axi As Object = axipi.GetValue(Me, Nothing)
> > Dim site As Object = axi.GetClientSite()
> > If site Is Nothing Then Return -1
> >
> > Dim qualifiedActiveXImplTypeName As String = _
> > Reflection.Assembly.CreateQualifiedName(strAssembl y,
> > "System.Windows.Forms.Control+ActiveXImpl")
> > Dim axit As Type = Type.GetType(qualifiedActiveXImplTypeName)
> > pi = axit.GetProperties(bf)
> > Dim dmpi As Reflection.PropertyInfo = getMemberByName(pi, "DesignMode")
> > Dim ret As Boolean = dmpi.GetValue(axi, Nothing)
> > If ret Then Return 1
> > Return 0
> >
> > getMemberByName() is function that goes through all array elements and[/color]
> finds[color=green]
> > the one with the given name. Note that I had to use[/color][/color]
"Control+ActiveXImpl"[color=blue][color=green]
> > 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[/color]
> containers.[color=green]
> > I'm trying now to figure out why. If you have any thought about that I'd
> > appreciate any input.
> >
> > thanks,
> > v
> >
> > "Sunny" <sunnyask@icebergwireless.com> wrote in message
> > news:O0NdRG0aDHA.2016@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > Hi Vladimir,
> > > IT WORKS IT WORKS. You are great. I have implemented this in C# and it[/color]
> > gave[color=darkred]
> > > me the reference I needed. I suppose, that I had to implement all of[/color][/color]
> your[color=green][color=darkred]
> > > code, but I stopped at the check for site is Nothing, because I can[/color][/color][/color]
cast[color=blue][color=green]
> > it[color=darkred]
> > > at the type I want. So, I do not know what the rest of the code have[/color][/color][/color]
to[color=blue][color=green]
> > do.[color=darkred]
> > > If you have a little time, pls, explain. Nevertheless so far, you are[/color][/color]
> the[color=green][color=darkred]
> > > only guy around who have succeeded to solve that problem. I have[/color][/color][/color]
posted[color=blue]
> it[color=green][color=darkred]
> > > allover, with different ideas, but ... nothing.
> > >
> > > Thank you again
> > > Sunny
> > >
> > > "Vladimir Kouznetsov" <vladimir.kouznetsov@REMOVETHISngrain.com> wrote[/color][/color]
> in[color=green][color=darkred]
> > > message news:O9HpW1BaDHA.2464@TK2MSFTNGP09.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 =
> > > >[/color][/color]
> Type.GetType("System.Object").Assembly.CodeBase.Re place("mscorlib.dll",[color=green][color=darkred]
> > > > "System.Windows.Forms.dll")
> > > > strAssembly = strAssembly.Replace("file:///", String.Empty)
> > > > strAssembly =
> > > Reflection.AssemblyName.GetAssemblyName(strAssembl y).FullName
> > > > Dim unmt As Type = _
> > > > Type.GetType(Reflection.Assembly.CreateQualifiedNa me(strAssembly,
> > > > "System.Windows.Forms.UnsafeNativeMethods"))
> > > > Dim ioot As Type = unmt.GetNestedType("IOleObject")
> > > > Dim mi As Reflection.MethodInfo = 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.Parse(2.ToString())
> > > > Dim result As Object
> > > > dsite.Invoke(-709, id, lcid, wFlags, params, result, Nothing,[/color][/color][/color]
Nothing)[color=blue][color=green][color=darkred]
> > > >
> > > > If result Then
> > > > Return 1
> > > > Else
> > > > Return 0
> > > > End If
> > > >
> > > > That should give you an idea how to do what you want. IIRC[/color]
> > IOleClientSite[color=darkred]
> > > > 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" <sunnyask@icebergwireless.com> wrote in message
> > > > news:uixm4aBaDHA.3248@tk2msftngp13.phx.gbl...
> > > > > Hi, it seems that I have to guess what property to get, so I'll[/color][/color][/color]
play[color=blue][color=green][color=darkred]
> > > with
> > > > > all of them, but that happen always with combination[/color][/color]
> COM/.Net/Outlook[color=green]
> > :)[color=darkred]
> > > > > The problem is, that I have read some of docs for reflection, and[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> > > still
> > > > > have no idea where to start and how to access these private[/color][/color][/color]
members[color=blue]
> :([color=green][color=darkred]
> > > > > So any example will be helpful.
> > > > >
> > > > > Sunny
> > > > >
> > > > > "Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in[/color][/color]
> message[color=green][color=darkred]
> > > > > news:ul0DL$%23ZDHA.2284@TK2MSFTNGP12.phx.gbl...
> > > > > > Hi Sunny,
> > > > > >
> > > > > >
> > > > > > I think that yes, it's possible to access the private[/color][/color][/color]
properties[color=blue]
> of[color=green]
> > a[color=darkred]
> > > > > 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[/color]
> > stated[color=darkred]
> > > > 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" <sunnyask@icebergwireless.com> wrote in message
> > > > > > news:uOAH2n1ZDHA.656@tk2msftngp13.phx.gbl...
> > > > > > > Hi,
> > > > > > > I have an old problem which I couldn't solve so far. Now I[/color][/color][/color]
have[color=blue][color=green][color=darkred]
> > > found
> > > > a
> > > > > > post
> > > > > > > in that group that gave me an idea, but I can not fully[/color][/color]
> understand[color=green][color=darkred]
> > > it.
> > > > > > > The problem is: I'm trying to use a Windows.Forms.UserControl[/color][/color][/color]
in[color=blue]
> a[color=green][color=darkred]
> > > COM
> > > > > > > environment, i.e. I want to host that control in a COM host.[/color][/color][/color]
So[color=blue][color=green]
> > far,[color=darkred]
> > > > so
> > > > > > > good, I can host it, but I can not reach the parent COM object[/color]
> > from[color=darkred]
> > > > the
> > > > > > > control (Parent property is null :( ).
> > > > > > > I have stopped the control in the debugger and I found in the[/color]
> > watch[color=darkred]
> > > > > window
> > > > > > > some properties, like ActiveXInstance
> > > > > > > {System.Windows.Forms.Control.ActiveXImpl}
> > > > > > > The problem is that they are private to the base class, so I[/color][/color][/color]
can[color=blue][color=green]
> > not[color=darkred]
> > > > > > access
> > > > > > > them.
> > > > > > >
> > > > > > > Now the question: is it possible somehow to access these base
> > > > properties
> > > > > > > programmatically. I have found a post which mentions something[/color]
> > about[color=darkred]
> > > > > > > reflection (whatever that mean). Can I use a reflection to[/color][/color]
> access[color=green][color=darkred]
> > > > these
> > > > > > > properties?
> > > > > > >
> > > > > > > Any help will be highly appreciated.
> > > > > > >
> > > > > > > Thanks
> > > > > > > Sunny
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: reflection, base class private properties, etc.
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.developer.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" <vladimir.kouznetsov@REMOVETHISngrain.com> wrote in
message news:eKbShrabDHA.2672@tk2msftngp13.phx.gbl...[color=blue]
> 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.[/color]
Also[color=blue]
> you can inspect olectl.h - a C header file that comes with VC - to find[/color]
more[color=blue]
> standard properties definitions, they start with DISPID_.
>
> I actually have three problems: (a) Word doesn't persist _my_ properties -[/color]
I[color=blue]
> have a few properties, I can set them from Word programmatically 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[/color]
can[color=blue]
> 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[/color]
show[color=blue]
> my properties in it.
>
> thanks,
> v
>
> "Sunny" <sunnyask@icebergwireless.com> wrote in message
> news:#LpVi$NbDHA.3768@tk2msftngp13.phx.gbl...[color=green]
> > 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[/color][/color]
(bool[color=blue][color=green]
> > Dirty) and 2 methods (void Apply() and void GetPageInfo(ref string[/color]
> HelpFile,[color=green]
> > 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[/color]
> be[color=green]
> > recognized:
> >
> > [DispId(-518)]
> > public string Caption
> > {
> > get
> > {return this.Name;}
> > }
> > So maybe you have to reimplement some of the properties you want to[/color][/color]
expose[color=blue][color=green]
> > 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[/color][/color]
supply[color=blue][color=green]
> > 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.[/color][/color]
I[color=blue][color=green]
> > 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[/color][/color]
a[color=blue][color=green]
> > new properties with that DispID, which supplies the necessary values.
> >
> > Please, let me know what happened.
> >
> > Sunny
> >
> >
> >
> > "Vladimir Kouznetsov" <vladimir.kouznetsov@REMOVETHISngrain.com> wrote[/color][/color]
in[color=blue][color=green]
> > message news:%23opLGfNbDHA.2344@TK2MSFTNGP12.phx.gbl...
> >[color=darkred]
> > > 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[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > type is not accessible in compile time - it's defined in a private[/color][/color]
> nested[color=green][color=darkred]
> > > 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[/color]
> > (couldn't[color=darkred]
> > > 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("System.Object").Assembly.CodeBase
> > > strAssembly = strAssembly.Replace("mscorlib.dll", _
> > > "System.Windows.Forms.dll")
> > > strAssembly = strAssembly.Replace("file:///", String.Empty)
> > > strAssembly =[/color]
> > Reflection.AssemblyName.GetAssemblyName(strAssembl y).FullName[color=darkred]
> > > Dim qualifiedControlTypeName As String = _
> > > Reflection.Assembly.CreateQualifiedName(strAssembl y,
> > > "System.Windows.Forms.Control")
> > > Dim ct As Type = Type.GetType(qualifiedControlTypeName)
> > > Dim bf As Reflection.BindingFlags = _
> > > Reflection.BindingFlags.IgnoreCase Or _
> > > Reflection.BindingFlags.NonPublic Or _
> > > Reflection.BindingFlags.Public Or _
> > > Reflection.BindingFlags.Static Or _
> > > Reflection.BindingFlags.Instance
> > > Dim pi() As Reflection.PropertyInfo = ct.GetProperties(bf)
> > > Dim axipi As Reflection.PropertyInfo = getMemberByName(pi, _
> > > "ActiveXInstance")
> > > Dim axi As Object = axipi.GetValue(Me, Nothing)
> > > Dim site As Object = axi.GetClientSite()
> > > If site Is Nothing Then Return -1
> > >
> > > Dim qualifiedActiveXImplTypeName As String = _
> > > Reflection.Assembly.CreateQualifiedName(strAssembl y,
> > > "System.Windows.Forms.Control+ActiveXImpl")
> > > Dim axit As Type = Type.GetType(qualifiedActiveXImplTypeName)
> > > pi = axit.GetProperties(bf)
> > > Dim dmpi As Reflection.PropertyInfo = getMemberByName(pi,[/color][/color][/color]
"DesignMode")[color=blue][color=green][color=darkred]
> > > Dim ret As Boolean = dmpi.GetValue(axi, Nothing)
> > > If ret Then Return 1
> > > Return 0
> > >
> > > getMemberByName() is function that goes through all array elements and[/color]
> > finds[color=darkred]
> > > the one with the given name. Note that I had to use[/color][/color]
> "Control+ActiveXImpl"[color=green][color=darkred]
> > > type name - GetNestedType() didn't work (any ideas why?). Note that[/color][/color][/color]
late[color=blue][color=green][color=darkred]
> > > binding (GetClientSite()) works fine now. Note that DesignMode[/color][/color][/color]
property[color=blue][color=green][color=darkred]
> > > actually stores UserMode so it's false in design time.
> > >
> > > For a some reason .Net control's properties don't persist in COM[/color]
> > containers.[color=darkred]
> > > I'm trying now to figure out why. If you have any thought about that[/color][/color][/color]
I'd[color=blue][color=green][color=darkred]
> > > appreciate any input.
> > >
> > > thanks,
> > > v
> > >
> > > "Sunny" <sunnyask@icebergwireless.com> wrote in message
> > > news:O0NdRG0aDHA.2016@TK2MSFTNGP10.phx.gbl...
> > > > Hi Vladimir,
> > > > IT WORKS IT WORKS. You are great. I have implemented this in C# and[/color][/color][/color]
it[color=blue][color=green][color=darkred]
> > > gave
> > > > me the reference I needed. I suppose, that I had to implement all of[/color]
> > your[color=darkred]
> > > > code, but I stopped at the check for site is Nothing, because I can[/color][/color]
> cast[color=green][color=darkred]
> > > it
> > > > at the type I want. So, I do not know what the rest of the code have[/color][/color]
> to[color=green][color=darkred]
> > > do.
> > > > If you have a little time, pls, explain. Nevertheless so far, you[/color][/color][/color]
are[color=blue][color=green]
> > the[color=darkred]
> > > > only guy around who have succeeded to solve that problem. I have[/color][/color]
> posted[color=green]
> > it[color=darkred]
> > > > allover, with different ideas, but ... nothing.
> > > >
> > > > Thank you again
> > > > Sunny
> > > >
> > > > "Vladimir Kouznetsov" <vladimir.kouznetsov@REMOVETHISngrain.com>[/color][/color][/color]
wrote[color=blue][color=green]
> > in[color=darkred]
> > > > message news:O9HpW1BaDHA.2464@TK2MSFTNGP09.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 =
> > > > >[/color]
> > Type.GetType("System.Object").Assembly.CodeBase.Re place("mscorlib.dll",[color=darkred]
> > > > > "System.Windows.Forms.dll")
> > > > > strAssembly = strAssembly.Replace("file:///", String.Empty)
> > > > > strAssembly =
> > > > Reflection.AssemblyName.GetAssemblyName(strAssembl y).FullName
> > > > > Dim unmt As Type = _
> > > > >[/color][/color][/color]
Type.GetType(Reflection.Assembly.CreateQualifiedNa me(strAssembly,[color=blue][color=green][color=darkred]
> > > > > "System.Windows.Forms.UnsafeNativeMethods"))
> > > > > Dim ioot As Type = unmt.GetNestedType("IOleObject")
> > > > > Dim mi As Reflection.MethodInfo = 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.Parse(2.ToString())
> > > > > Dim result As Object
> > > > > dsite.Invoke(-709, id, lcid, wFlags, params, result, Nothing,[/color][/color]
> Nothing)[color=green][color=darkred]
> > > > >
> > > > > 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[/color][/color][/color]
COM[color=blue][color=green][color=darkred]
> > > > > object). BTW You can use ildasm on System.Windows.Forms.dll to[/color][/color][/color]
make[color=blue][color=green][color=darkred]
> > > > yourself
> > > > > familiar with the internal classes and implementations.
> > > > >
> > > > > thanks,
> > > > > v
> > > > >
> > > > > "Sunny" <sunnyask@icebergwireless.com> wrote in message
> > > > > news:uixm4aBaDHA.3248@tk2msftngp13.phx.gbl...
> > > > > > Hi, it seems that I have to guess what property to get, so I'll[/color][/color]
> play[color=green][color=darkred]
> > > > with
> > > > > > all of them, but that happen always with combination[/color]
> > COM/.Net/Outlook[color=darkred]
> > > :)
> > > > > > The problem is, that I have read some of docs for reflection,[/color][/color][/color]
and[color=blue]
> I[color=green][color=darkred]
> > > > still
> > > > > > have no idea where to start and how to access these private[/color][/color]
> members[color=green]
> > :([color=darkred]
> > > > > > So any example will be helpful.
> > > > > >
> > > > > > Sunny
> > > > > >
> > > > > > "Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in[/color]
> > message[color=darkred]
> > > > > > news:ul0DL$%23ZDHA.2284@TK2MSFTNGP12.phx.gbl...
> > > > > > > Hi Sunny,
> > > > > > >
> > > > > > >
> > > > > > > I think that yes, it's possible to access the private[/color][/color]
> properties[color=green]
> > of[color=darkred]
> > > a
> > > > > > class
> > > > > > > using reflection, I haven't tested it but I also saw the post[/color][/color][/color]
of[color=blue][color=green][color=darkred]
> > > > > Nicholas
> > > > > > > and until now all that he said is true ;) , the thing is ([/color][/color][/color]
also[color=blue][color=green][color=darkred]
> > > 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" <sunnyask@icebergwireless.com> wrote in message
> > > > > > > news:uOAH2n1ZDHA.656@tk2msftngp13.phx.gbl...
> > > > > > > > Hi,
> > > > > > > > I have an old problem which I couldn't solve so far. Now I[/color][/color]
> have[color=green][color=darkred]
> > > > found
> > > > > a
> > > > > > > post
> > > > > > > > in that group that gave me an idea, but I can not fully[/color]
> > understand[color=darkred]
> > > > it.
> > > > > > > > The problem is: I'm trying to use a[/color][/color][/color]
Windows.Forms.UserControl[color=blue]
> in[color=green]
> > a[color=darkred]
> > > > COM
> > > > > > > > environment, i.e. I want to host that control in a COM host.[/color][/color]
> So[color=green][color=darkred]
> > > far,
> > > > > so
> > > > > > > > good, I can host it, but I can not reach the parent COM[/color][/color][/color]
object[color=blue][color=green][color=darkred]
> > > from
> > > > > the
> > > > > > > > control (Parent property is null :( ).
> > > > > > > > I have stopped the control in the debugger and I found in[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > watch
> > > > > > window
> > > > > > > > some properties, like ActiveXInstance
> > > > > > > > {System.Windows.Forms.Control.ActiveXImpl}
> > > > > > > > The problem is that they are private to the base class, so I[/color][/color]
> can[color=green][color=darkred]
> > > not
> > > > > > > access
> > > > > > > > them.
> > > > > > > >
> > > > > > > > Now the question: is it possible somehow to access these[/color][/color][/color]
base[color=blue][color=green][color=darkred]
> > > > > properties
> > > > > > > > programmatically. I have found a post which mentions[/color][/color][/color]
something[color=blue][color=green][color=darkred]
> > > about
> > > > > > > > reflection (whatever that mean). Can I use a reflection to[/color]
> > access[color=darkred]
> > > > > these
> > > > > > > > properties?
> > > > > > > >
> > > > > > > > Any help will be highly appreciated.
> > > > > > > >
> > > > > > > > Thanks
> > > > > > > > Sunny
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: reflection, base class private properties, etc.
Your code has been really helpful to me, as I encountered exactly the
same problem as Sunny (i.e. adding property pages to Outlook), except
that I'm using VB.NET. I thought that anyone trying to achieve this
may be interested to know that the code can be simplified to the
following:-
Public ReadOnly Property PageSite() As PropertyPageSite
Get
Dim typeUnsafeNativeMethods As Type = GetType
_(Windows.Forms.Control).Assembly.GetType
_("System.Windows.Forms.UnsafeNativeMethods")
Dim typeOleObject As Type =
typeUnsafeNativeMethods.GetNestedType _("IOleObject")
Dim methodGetClientSite As Reflection.MethodInfo = _
typeOleObject.GetMethod("GetClientSite")
Dim site As Object = methodGetClientSite.Invoke(Me,
Nothing)
Try
Return CType(site, PropertyPageSite)
Catch ex As InvalidCastException
'Handle the exception
End Try
End Get
End Property
The above PageSite property is added to your class that implements the
Outlook.PropertyPage interface.
One further necessity though, will probably be to set the caption of
the property page (the tab heading). In order to do this, I found that
I had to define my own interface as follows (substitute a GUID where
the x's are):-
<GuidAttribute("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"),
InterfaceTypeAttribute _ (ComInterfaceType.InterfaceIsIDispatch)> _
Public Interface IMyProperties
Inherits PropertyPage
<DispId(-518)> ReadOnly Property Caption() As String
End Interface
Instead of implementing Outlook.PropertyPage, your class would then
implement IMyProperties.
"Sunny" <sunnyask@icebergwireless.com> wrote in message news:<O0NdRG0aDHA.2016@TK2MSFTNGP10.phx.gbl>...[color=blue]
> 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" <vladimir.kouznetsov@REMOVETHISngrain.com> wrote in
> message news:O9HpW1BaDHA.2464@TK2MSFTNGP09.phx.gbl...[color=green]
> > Here is a sample code (in VB but it shouldn't not be difficult to[/color]
> translate[color=green]
> > it) I used to get UserMode property:
> >
> > Dim strAssembly As String
> > strAssembly =
> > Type.GetType("System.Object").Assembly.CodeBase.Re place("mscorlib.dll",
> > "System.Windows.Forms.dll")
> > strAssembly = strAssembly.Replace("file:///", String.Empty)
> > strAssembly =[/color]
> Reflection.AssemblyName.GetAssemblyName(strAssembl y).FullName[color=green]
> > Dim unmt As Type = _
> > Type.GetType(Reflection.Assembly.CreateQualifiedNa me(strAssembly,
> > "System.Windows.Forms.UnsafeNativeMethods"))
> > Dim ioot As Type = unmt.GetNestedType("IOleObject")
> > Dim mi As Reflection.MethodInfo = 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.Parse(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[/color]
> yourself[color=green]
> > familiar with the internal classes and implementations.
> >
> > thanks,
> > v
> >
> > "Sunny" <sunnyask@icebergwireless.com> wrote in message
> > news:uixm4aBaDHA.3248@tk2msftngp13.phx.gbl...[color=darkred]
> > > Hi, it seems that I have to guess what property to get, so I'll play[/color][/color]
> with[color=green][color=darkred]
> > > 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[/color][/color]
> still[color=green][color=darkred]
> > > have no idea where to start and how to access these private members :(
> > > So any example will be helpful.
> > >
> > > Sunny
> > >
> > > "Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
> > > news:ul0DL$%23ZDHA.2284@TK2MSFTNGP12.phx.gbl...
> > > > Hi Sunny,
> > > >
> > > >
> > > > I think that yes, it's possible to access the private properties of a[/color][/color]
> class[color=green][color=darkred]
> > > > using reflection, I haven't tested it but I also saw the post of[/color][/color]
> Nicholas[color=green][color=darkred]
> > > > and until now all that he said is true ;) , the thing is ( also stated[/color][/color]
> in[color=green][color=darkred]
> > > > the post ) what are you planning to do with it? it;s a private[/color][/color]
> property
> and[color=green][color=darkred]
> > > > 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" <sunnyask@icebergwireless.com> wrote in message
> > > > news:uOAH2n1ZDHA.656@tk2msftngp13.phx.gbl...
> > > > > Hi,
> > > > > I have an old problem which I couldn't solve so far. Now I have[/color][/color]
> found
> a
> post[color=green][color=darkred]
> > > > > in that group that gave me an idea, but I can not fully understand[/color][/color]
> it.[color=green][color=darkred]
> > > > > The problem is: I'm trying to use a Windows.Forms.UserControl in a[/color][/color]
> COM[color=green][color=darkred]
> > > > > environment, i.e. I want to host that control in a COM host. So far,[/color][/color]
> so[color=green][color=darkred]
> > > > > good, I can host it, but I can not reach the parent COM object from[/color][/color]
> the[color=green][color=darkred]
> > > > > control (Parent property is null :( ).
> > > > > I have stopped the control in the debugger and I found in the watch[/color][/color]
> window[color=green][color=darkred]
> > > > > some properties, like ActiveXInstance
> > > > > {System.Windows.Forms.Control.ActiveXImpl}
> > > > > The problem is that they are private to the base class, so I can not[/color][/color]
> access[color=green][color=darkred]
> > > > > them.
> > > > >
> > > > > Now the question: is it possible somehow to access these base[/color][/color]
> properties[color=green][color=darkred]
> > > > > programmatically. I have found a post which mentions something about
> > > > > reflection (whatever that mean). Can I use a reflection to access[/color][/color]
> these[color=green][color=darkred]
> > > > > properties?
> > > > >
> > > > > Any help will be highly appreciated.
> > > > >
> > > > > Thanks
> > > > > Sunny
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color][/color] |  | Similar C# / C Sharp bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,510 network members.
|