ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hiding Methods in Automation Add-In (https://www.excelbanter.com/excel-programming/365145-hiding-methods-automation-add.html)

Matthew Wieder[_3_]

Hiding Methods in Automation Add-In
 
In VS 2005 and Excel 2003. I am writing an Automation Add-In in C# and don't
want to expose the Object methods (GetHashCode, GetType etc.) to end users to
put in their cell formulas. A post here
http://groups.google.com/group/micro...6a59ead000e62?

suggests marking the class as ClassInterfaceType.None and implementing a
public interface with just the desired methods but this does not work (maybe
it worked in .NET 1.1). Help?

Dmytro Lapshyn [MVP]

Hiding Methods in Automation Add-In
 
Hi Matthew,

Check that the public interface is marked as
ComInterfaceType.InterfaceIsDual or at least
ComInterfaceType.InterfaceIsDispatch (with the [InterfaceType] attribute).

--
Regards,
Dmytro Lapshyn [MVP]
http://blogs.vbcity.com/DmytroL

"Matthew Wieder" wrote in message
...
In VS 2005 and Excel 2003. I am writing an Automation Add-In in C# and
don't
want to expose the Object methods (GetHashCode, GetType etc.) to end users
to
put in their cell formulas. A post he
http://groups.google.com/group/micro...6a59ead000e62?

suggests marking the class as ClassInterfaceType.None and implementing a
public interface with just the desired methods but this does not work
(maybe
it worked in .NET 1.1). Help?



Matthew Wieder[_3_]

Hiding Methods in Automation Add-In
 
The interface is set to dual - the functions still do not show up in the
Insert Function dialog in Excel. Does anyone have this working in .NET 2.0?

Dmytro Lapshyn [MVP] wrote:
Hi Matthew,

Check that the public interface is marked as
ComInterfaceType.InterfaceIsDual or at least
ComInterfaceType.InterfaceIsDispatch (with the [InterfaceType] attribute).


Matthew Wieder[_3_]

Hiding Methods in Automation Add-In
 
Solved it - Based on web examples, I had been implementing my class as:

public class myClass : Object, MyInterface, Extensibility.IDTExtensibility2

which makes the primary interface the object type and that was causing
the problems. Changed to:
public class myClass : MyInterface, Extensibility.IDTExtensibility2

and only the desired methods are showing in Excel now.

thanks.

Matthew Wieder wrote:

The interface is set to dual - the functions still do not show up in the
Insert Function dialog in Excel. Does anyone have this working in .NET
2.0?

Dmytro Lapshyn [MVP] wrote:

Hi Matthew,

Check that the public interface is marked as
ComInterfaceType.InterfaceIsDual or at least
ComInterfaceType.InterfaceIsDispatch (with the [InterfaceType]
attribute).



All times are GMT +1. The time now is 01:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com