.NET Framework - ActiveX Control hidden property in VS.NET

Asked By HairlipDo
26-Dec-07 06:54 PM
I'm working on an MFC ActiveX Control that implements some hidden properties.
The properties are hidden by adding the [hidden] attribute in the the ODL
file. Some properties are hidden because they have been replaced by newer
properties. By marking the obsolete properties hidden, new developers don't
see them but older apps can still access them programmatically.

This works fine for VB6, the properties do not show up in the properties
grid or object browser.

However, in VS.NET 2005, the hidden properties still show up in the
properties grid and object browser.

I've also tried the nonbrowsable attribute and the props still show up in
the props grid.

Any ideas?
System.ComponentModel.BrowsableAttribute
(1)
Visual Studio 2005
(1)
DesignerSerializationVisibility.Hidden
(1)
Visual Studio
(1)
DesignerSerializationVisibility
(1)
CHiddenPropTestCtrl
(1)
BrowsableAttribute
(1)
VB
(1)
  wawan replied...
27-Dec-07 04:10 AM
Hi,

Which version of Visual Studio that you are using to create the MFC ActiveX
Control?

I haven't tested an ActiveX Control created in MFC but I have some VB6
ActiveX Controls which have hidden properties and they seem to work
correctly in Visual Studio 2005, both in an unmanaged MFC dialog
application and in a WinForm application.

Would you please post or send me your MFC ActiveX Control source code so
that I can reproduce the issue on my side? Thanks.


Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

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

This posting is provided "AS IS" with no warranties, and confers no rights.
  HairlipDo replied...
27-Dec-07 11:41 AM
Hi Walter,

Control is authored in VC++ 6.0 with latest service packs applied.

Source code was just sent to you by email.
  Brian Muth replied...
27-Dec-07 11:56 PM
The hidden attribute is mainly a hint to user-oriented object browsers. I suspect that historically it was driven by VB6 designers,
since as you discovered, VB6 honours that hint, but most other browser tools (including Visual Studio) ignores it.

Brian
  wawan replied...
28-Dec-07 03:24 AM
Thanks.

I've done some research and I think I have found the root cause of this
issue.

There are two approaches to define a property in IDL/ODL, one is to use the
approach in your sample code:

[ uuid(5F9B1CFB-CBD0-4290-A74A-62080CDF50C1),
helpstring("Dispatch interface for HiddenPropTest Control"), hidden ]
dispinterface _DHiddenPropTest
{
properties:
// NOTE - ClassWizard will maintain property information here.
//    Use extreme caution when editing this section.
//{{AFX_ODL_PROP(CHiddenPropTestCtrl)
[id(1), hidden] boolean Hidden;
[id(2), nonbrowsable] boolean NonBrowsable;
[id(3)] boolean Normal;
//}}AFX_ODL_PROP

methods:
// NOTE - ClassWizard will maintain method information here.
//    Use extreme caution when editing this section.
//{{AFX_ODL_METHOD(CHiddenPropTestCtrl)
//}}AFX_ODL_METHOD
};


Another one is to use the approach what VB6 is doing using propget/propput:


[id(7), propget] BSTR P1();
[id(8), propput] void P1([in] BSTR rhs);
[id(9), propget, hidden] BSTR P2();
[id(10), propput, hidden] void P2([in] BSTR rhs);
};


Apparently the type library importer of .NET Framework can only deal with
the second approach. Following are the applied attributes to the member
from the generated interop assembly:

[DispId(1),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual bool Hidden
{
..


[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
Browsable(false), DispId(0x68030000)]
public virtual string P2
{
..



Note the second one has an attribute Browsable set to false, which is the
key to make it hidden in property grid.

To workaround this, I think we could use two different aproaches.

1) Change the IDL in MFC project to use propget/propput.

2) If you are distributing the interop assembly (see concept Primary
Interop Assembly, aka. PIA), you can first use ildasm.exe to get the IL
source code of your interop assembly, after modification, use ilasm.exe to
compile the IL source into assembly again.

http://msdn2.microsoft.com/en-us/library/7112ksf7.aspx

http://msdn2.microsoft.com/en-us/library/8zbc969t.aspx


Hope this helps.
  HairlipDo replied...
28-Dec-07 12:15 PM
Hi Walter,

Thanks for the reply.

Seems like a bug in the .NET type library importer that should be addressed
by MS.

This is an established control. If I use approach 1, I think binary
compatibility would be broken by changing prop declarations from MFC
ClassWizard style to VB propput/propget style. Thoughts?

I'll have a closer look at approach 2, but still seems like unnecessary work
since all information is already available in ODL.

My guess is that there is a significant base of MFC-based ActiveX Controls
that have the same requirement, so seamless .NET support would be expected.
  wawan replied...
02-Jan-08 02:13 AM
Hi Mark,

I'm sorry that my previously reply isn't complete, the approach I mentioned
is using a general COM component as an example. Actually in this case we
are dealing with an ActiveX Control and we can use a more simpler approach.

We can use AxImp.exe and its /source switch to generate a source file for
the Winform control wrapper and it's this file that we need to tweak with
and compile again. Please refer to following KB for detailed steps:

http://support.microsoft.com/kb/320780

In the RESOLUTION steps, before the last step to compile the wrapper, apply
the System.ComponentModel.BrowsableAttribute(false) to the properties that
you need to hide from the property grid.

When distributing your control, you need to distribute three files: the ocx
file itself, the interop assembly, the winform control wrapper. Your users
can add the winform control wrapper to toolbox and use it from there.

Again, we're sorry for the inconvenience caused by this issue. I will
forward it to product team. For now, please test above workaround and let
me know if there's anything else I can help.



Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

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

This posting is provided "AS IS" with no warranties, and confers no rights.
Create New Account
help
that is not what I need. I have tried re-installing Service Pack 1 for Visual Studio 2008. I am really hoping that I will not have to to a un-install of Visual Studio. I am running Windows XP Version 5.1.2600 Service Pack 3 Build 2600 Just in-case it is helpful, I am pasting the info from my Visual Studio about window below * ** ** **ABOUT INFO* ** ** * Microsoft Visual Studio 2008 Version 9.0.30729.1 SP Microsoft .NET Framework Version 3.5 SP1 Installed
Services Discussions NOVAS.NCOMPARE.V5.2.R12.for.LINUX (1) NASSDA.CRITIC.v5.0.01.2005.WINDOWS (1) GREEN.HILLS.Integrity.v5.0.6.RTOS.for.Blackfin (1) NASSDA.HANEX.v5.0.01.2005.WINDOWS (1) OPTIS.OPTISWORKS.STUDIO.v2008 (1) NASSDA.HSIM.v5.0.01 2005.WINDOWS (1) 2012 crack software5 download. Please press Ctrl+F to find your cracked software v12.52 Sonnet.Suite.Pro.v12.52.Linux Sono.Scope.v2.8. Sony.Acid.Music.Studio.v7.0a. Sony.Sound.Forge.10.0a. sony.vegas.7.0c sound.soap.1.1 v1.4.371b SourcePublisher.for.C.Plus.Plus.v1.4.371b Space.Management.for.CADVance.2005 SPACE-4.0.rar. SpaceCAD.v3.1.0.320.WinALL SpaceClaim.v2009.Plus.SP2.x64 StructureShape.Arch.v1.02 structureshape.frameshape.v1.09 Struds.v2010. StruSoft.FEM-Design.v8.0 Studio.V5.LogoMaker.v2.0. Sucosoft.S40.Ver5.04 Sulcol.v1.0.35. Sulpak.v3.0 Sulsim.6 SULTRAY.SULCOL.C5.2. Sum3D.v7.1 Summit.Design.Visual.Elite.v2006.1.1 Summit.System.Architect.v2006.08.17.Linux Summit.System.Architect.v2006
www.kahnsoft.de / error.jpg Danke für Hinweise im Vorraus, grüße Karsten Schulz (VersionsHistoryDump :) Microsoft Visual Studio 2008 Version 9.0.30428.1 SP1Beta1 Microsoft .NET Framework Version 3.5 SP1 Installed Edition: Enterprise Microsoft Visual Basic 2008 91899-270-0320045-60060 Microsoft Visual Basic 2008 Microsoft Visual C# 2008 91899-270-0320045-60060 Microsoft Visual C# 2008 Microsoft Visual C++ 2008 91899-270-0320045-60060 Microsoft Visual C++ 2008 Microsoft Visual Studio 2008 Tools for Office 91899-270-0320045-60060 Microsoft Visual
SP1 :: Cannot display project properties any more .NET Framework Hi, i have a problem with Visual Studio 2008 SP1. I cannot display the Neither c# projects, nor VB.NET Projects. I tried and New dnstall. Does anyone had this problem too? Greetings Gordian ~~~~~~~~~~~~~ I have the following Visual Studio Products installed: Microsoft Visual Studio 2008 Version 9.0.30729.1 SP Microsoft .NET Framework Version 3.5 SP1 Installed Edition: Professional Microsoft Visual Basic 2008 91605-270-0034223-60570 Microsoft Visual Basic 2008 Microsoft Visual C# 2008 91605-270-0034223-60570 Microsoft Visual C# 2008 Microsoft
a definition for 'IsReference' It appears the System.Runtime.Serialization is not properly updated by Visual Studio 2008 SP1, or at least not on Windows Server 2008 (my desktop OS). Will try to go through and create exact repro steps. History: 1. Installed Visual Studio SP1 Did not install .NET Framework 3.5 SP1 first, as assumed this would be NET Discussions System.Runtime.Serialization.DataContractAttribute (1) SQL Server 2008 (1) Windows Server 2008 (1) Visual Studio 2008 (1) Entity Framework (1) Silverlight (1) Office (1) ADO.NET (1) The solution is software, I am now under the assumption I must have had one of them installed. Visual Studio is now working great, or at least great in the features I currently need. :-) - - Gregory