473,769 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6820
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.bti nternet.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( ClassInterfaceT ype.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.bti nternet.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(st ring 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.btinte rnet.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
1963
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 easy language that is built into the system. It is supposed to be capable of extending itself by calling external DLLs. It is very picky about what DLLs it will see though Others have had success using C++ to write a DLL that will work with Easy...
20
3198
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: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmtps/html/writingmngsinks.asp). I set my project properties as 'Register as COM interop' to true, I can install it my project on my developement machine without a flaw. Great.
5
1852
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 ActiveX control isn't as straight-forward as a CWnd-derived object. It also means that I have to split my code into two projects. Going the other way (using MFC in WinForms) is only possible by exposing MFC objects as ActiveX controls, which...
22
4846
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 that I was suppose to run against my dll in order to generate a TLB file for the purposes of importing the COM object into other programming lanugages such as Delphi. However, when I try to import the type library into Delphi which I have done...
3
1263
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
1918
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 the data as either a int or a Guid depending on the structure of the database. If we simply used int to represent a primary key, rather than this PrimaryKey class then programmers could do things like performing mathematically operations on the...
1
3264
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 the Delphi program? If I try to return the XmlDocument object itself, I get an error like: This type has a ComVisible(false) parent in its hierarchy.
1
1578
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. [ClassInterface(ClassInterfaceType.None), ComSourceInterfaces(typeof(IAEvents)) public abstract class A : IA {
0
1160
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 unmanaged client (C++) will initialize the struct fields with some values and these struct values can be modified or reallocated by Managed COM Server. Struct look something like this on the managed side: public struct MyStruct ...
0
9422
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10038
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9857
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8867
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5294
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.