473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

COM Interop - exposing properties

My ActiveX Container requires certain properties to be exposed by
components - properties that appear under the properties section in the
IDL/type library file.

C# properties are exposed as methods and the interfaces that my c# class
implements cannot contain fields in order to expose these as properties.

Can anyone tell me how to expose c# code as COM (IDL) properties.

Thanks

Nov 15 '05 #1
4 6801
Look there:

http://msdn.microsoft.com/library/de...tnetserver.asp
José
"Luke Briner" <lu***********@cheerful.com> a écrit dans le message de
news:bj**********@hercules.btinternet.com...
My ActiveX Container requires certain properties to be exposed by
components - properties that appear under the properties section in the
IDL/type library file.

C# properties are exposed as methods and the interfaces that my c# class
implements cannot contain fields in order to expose these as properties.

Can anyone tell me how to expose c# code as COM (IDL) properties.

Thanks

Nov 15 '05 #2
I was just going working through this issue on a different thread in this
news group... This is what I finally came up with:

using System;
using System.Runtime.InteropServices;

namespace Squarei
{
//DEFINE THE PUBLIC INTERFACE FOR THE COM OBJECT
public interface IComInteropTest
{
void SetHTML(string strHtml);
string GetHTML();
}
//IMPLEMENT THE CLASS BELOW USING THE PUBLIC INTERFACE DEFINED ABOVE
[ClassInterface(ClassInterfaceType.None)]
public class ComInteropTest : IComInteropTest
{

public string strUrl = string.Empty;
public string strHtml = string.Empty;

public void SetHTML(string strHtml)
{
this.strHtml = strHtml;
}

public string GetHTML()
{
return strHtml;
}
}
}

--
Jay Douglas
Fort Collins, CO

"Luke Briner" <lu***********@cheerful.com> wrote in message
news:bj**********@hercules.btinternet.com...
My ActiveX Container requires certain properties to be exposed by
components - properties that appear under the properties section in the
IDL/type library file.

C# properties are exposed as methods and the interfaces that my c# class
implements cannot contain fields in order to expose these as properties.

Can anyone tell me how to expose c# code as COM (IDL) properties.

Thanks

Nov 15 '05 #3
Thanks for the help but the MS website does not have any details and
Jay's example still uses methods. I need to expose "idl properties" from
C#. I don't mind how I write the C# code but my container must see the
properties under the "properties" section in the idl file.

Nov 15 '05 #4
Sorry for providing the incorrect information ....

I'm having issues obtaining the same goals as you. Here's the work around I
came up with (I'm not satisfied with my solution, and it still uses methods)

Say I have a property/field

public string FirstName

I then created the methods

public void setFirstName(string s) {
FirstName = s;
}
public string getFirstName() {
return FirstName;
}

Then I exposed the methods in the interface.

I would love to hear a better way to expose the properties.

--
Jay Douglas
Fort Collins, CO

"Luke Briner" <lu***********@cheerful.com> wrote in message
news:bj**********@titan.btinternet.com...
Thanks for the help but the MS website does not have any details and
Jay's example still uses methods. I need to expose "idl properties" from
C#. I don't mind how I write the C# code but my container must see the
properties under the "properties" section in the idl file.

Nov 15 '05 #5

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

Similar topics

1
by: Doug | last post by:
I need to make the VB.NET object callable from a program called Trade Station. It is a stock analysis and trading tool that is very importiant to my company. They have a scripting languge called...
20
by: Razzie | last post by:
Hey all, I'm really going through a small hell right now - I've completely lost it :) I made a project, using two interop libraries from exchange (created them as in this msdn article:...
5
by: Dan Smith | last post by:
Right now the only way to use a WinForms control in MFC is to enable COM Interop for the control and use it in MFC as you would any ActiveX control. While this works, COM Interop is a pain, and an...
22
by: glenn | last post by:
I have a COM Server that I've written based on information from the book ..NET and COM / the complete Interop Guide. I have gotten the project to compile and I've located the regasm.exe program...
3
by: FredC | last post by:
How do you make a program's properties and methods availale so that other programs can "connect" to them at design time and then use them at run time?
8
by: Dave A | last post by:
I have a class called 'PrimaryKey' that represents the primary key of a table. PrimaryKeys can only be created and the class only implements .ToString(). The PrimaryKey class internally stores...
1
by: Bart Roozendaal | last post by:
Hi, I have setup a (my first) C# assembly. I am using the COM Interop services to use the assembly from a Delphi program. Is there a way to return a XmlDomDocument object from the assembly to...
1
by: Adam Clauss | last post by:
First, I have ComVisible set to true for the entire assembly. I have (abstract) base class A. There are interfaces IA and IAEvents for accessing properties of this object and exposing events. ...
0
by: user2008 | last post by:
Hi everybody, I'm working on exposing a .Net (C#) COM Server. Manage Code is exposting an interface with two methods. These methods take an IN/OUT Struct as parameter. Requirement is that the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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...

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.