473,466 Members | 1,313 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Writing COM components in .NET

balabaster
797 Recognized Expert Contributor
I've written a COM component in .NET which works just fine, but I have a couple of overloaded methods, both of which I need to be able to access via COM. When I compile my code it automatically appends _2, _3 etc to the end of the method name. Is there any way to expose the methods using a friendlier name of my choosing? i.e.

ConnectEx instead of Connect_2?

Cheers
Apr 8 '08 #1
2 1449
Plater
7,872 Recognized Expert Expert
Instead of overloads, can you just name them differently?
Apr 8 '08 #2
balabaster
797 Recognized Expert Contributor
Instead of overloads, can you just name them differently?
Well, I could, but I would like to keep my code consistent for my other .NET applications. I'm really just extending my classes to be available to COM and I would rather not add a whole bunch of functions that call my methods as one of my colleagues suggested...

i.e.
Expand|Select|Wrap|Line Numbers
  1. <ComVisible(True)> _
  2. Public Function Connect() As Boolean
  3.   '....blah
  4. End Function
  5.  
  6. <ComVisible(True)> _
  7. Public Function ConnectEx(ByVal Address As String) As Boolean
  8.   Return Connect(Address)
  9. End Function
  10.  
  11. <ComVisible(False)> _
  12. Public Function Connect(ByVal Address As String) As Boolean
  13.   '....blah
  14. End Function
Because then when I call my class from .NET code, now I've got a whole bunch of irrelevant classes showing up. It's just ugly and I was looking for something more elegant.

It would be much nicer if I could just keep my regular overloaded functions in some manner but decorate them with some attribute described by:
Expand|Select|Wrap|Line Numbers
  1. <ComVisible(True), ExposeAs("Connect")> _
  2. Public Function Connect() As boolean
  3.   '....do stuff
  4. End Function
  5.  
  6. <ComVisible(True), ExposeAs("ConnectEx")> _
  7. Public Function Connect(ByVal Address As String) As Boolean
  8.   '....do other stuff
  9. End Function
I obviously know that ExposeAs isn't a valid attribute...but is there not some attribute that explicitly defines the name by which a method is exposed to COM thus overriding the regular .NET method name?
Apr 8 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access...
7
by: Ollie | last post by:
okay sorry for cross posting but want to see if any one can explain the solution to this problem for me: I have a .Net ASP.Net app written in C# that use COM+ components to do some business...
3
by: Marius Rus | last post by:
I have a project in C# that do the followings: From an csv text file it is taking datas and inserted into an paradox database. My problem it is that when writing into the paradox database it is...
4
by: JP | last post by:
Okay - I have incorporated some of the advise I got on the first post and have gone ahead and setup a simple test project to demonstrate the trouble I am having. Any help is GREATLY appreciated: ...
5
by: Helen | last post by:
Is there a generic way to deal with html form elements in ASP.NET? A couple of the components I've written only really need to know that they're dealing with an element that has a value and can do...
16
by: iwdu15 | last post by:
how can i open a file i saved and place the info into different text boxes?
10
by: cj | last post by:
I'm having a problem writing an insert command to work with a datatable. I've looked at what the sqldataadapter creates and created my insert command to look the same. I have:...
3
by: Zeke Zinzul | last post by:
Hi Guys & Geeks, What's the most elegant way of dealing with binary data and structures? Say I have this (which I actually do, a woo-hoo): struct Struct_IconHeader { byte width; byte...
3
by: =?Utf-8?B?TWljaGFlbA==?= | last post by:
Does anyone know how I can write a binary file? Basically I want to read in a file that is an exe and write it back out bit by bit so I can add some header info. Thanks, Michael
1
by: =?Utf-8?B?ZmhpbGxpcG8=?= | last post by:
We have a code snippet that downloads data to Excel. it is writing row by row. This causes a performance issue. Any ideas on how to speed this up will be appreciated. Please find below an...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
0
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...
0
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,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...

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.