473,385 Members | 1,673 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,385 software developers and data experts.

How to use COM with C# and Delphi

We are trying to make a C# program as A COM object and acces it from a
unmanaged Delphi program and this gives us some problems.

In the program below we have declared two public members Command1()
and Command2()that we want to access from Delphi, and this works fine.
We also declared two Delegates OnDol and OnDol2, which is a function
pointer to two function in our Delphi program. As sune as our C#
program reach one of thise delegates we get the error message: "Not
inplemented". The delegates are not null, but obvious not set to point
to the function in the Delphi program. Is the any errors in the C#
code below? Does any have expirence with how to do this "connection in
"Delphi"

using System.Runtime.CompilerServices;
using System.Reflection;
using System.Diagnostics;
namespace DotNetAsCom
{
/// <summary>
/// Summary description for Dolphin.
/// </summary>

public delegate void OnDol2Delegate(int X);

[InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIDispatch)]
public interface IDolphinEvents
{
void OnDol(object sender, System.EventArgs e);
void OnDol2(int X);
}
[InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIDispatch)]
public interface IDolphin
{
void Command1();
void Command2();
}

[ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces("DotNetAsCom.IDolphinEvents")]
public class Dolphin : IDolphin
{
public Dolphin()
{
}

public event System.EventHandler OnDol;
public event OnDol2Delegate OnDol2;

protected void DoDol()
{
MessageBox.Show ("DoDol called", "DotNetAsCom",
MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
if (OnDol != null)
{
MessageBox.Show ("DoDol code body entered", "DotNetAsCom",
MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
OnDol(this, new System.EventArgs());
}
}

protected void DoDol2()
{
MessageBox.Show ("DoDol2 called", "DotNetAsCom",
MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
if (OnDol2 != null)
{
MessageBox.Show ("DoDol2 code body entered", "DotNetAsCom",
MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
OnDol2(5);
}
}

public void Command1()
{
MessageBox.Show ("Command1 called", "DotNetAsCom",
MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
DoDol();
}

public void Command2()
{
MessageBox.Show ("Command2 called", "DotNetAsCom",
MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
DoDol2();
}
}
}
Regards
Henrik
Nov 15 '05 #1
0 1062

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

Similar topics

6
by: Erva | last post by:
Hi, Is there someone who has moved from Delphi to VS.NET? I'am using Delphi currently but seriously considering to moving VS.NET. I would like to hear if someone has already done that, is it...
10
by: Arda Han | last post by:
I am migrating my some applications from Delphi to C#. But... Yes But I don't know C# professionally. I am using DLL in delphi like this : ..... const RFID_103_485IO = 'Cihaz.dll'; ...
9
by: Gclinton | last post by:
I'm looking for a comparsion of C# to Delphi .net. My company is about to begin the process of reengineering a Delphi tightly coupled win32 app and a Older Java webclient that uses JSP over to an...
16
by: glenn | last post by:
I've gotten a COM server written in C# and I can call it from a VBScript just fine and it works perfectly. However, I import it into Delphi 6 or Delphi 2005 and I can not get access to any of the...
3
by: lukeharpin | last post by:
Currently I have been developing applications in Delphi 7. Recently I meet up with a friend of mine who previously developed in Delphi, from version 1 - 7. When Delphi 8 .net was release he found...
7
by: Sanjay Kedare | last post by:
Hi, I am evaluating various alternatives of converting Delphi (Ver 4.0) screens to C# screens. Are there any tools available for such conversion? if yes how much conversion do they achieve? The...
13
by: lukeharpin | last post by:
Hi World, We have been developing Engineering software in Delphi 3,4,5,6,7 for a few years now. This morning we had a discussion about OOP and re-programming the software to which the question...
1
by: Thomas Due | last post by:
Hi, I manage an rather old application in which we have some fairly complex (ugly) Delphi code. This is Delphi 6 we're talking about. Among all this Delphi code there is method for formating a...
4
by: =?Utf-8?B?ZGF2ZWJ5dGhlc2Vh?= | last post by:
Dear List, We have a large application written in Delphi. I am writing a mobile app written in .NET (C#) which reads and writes into the Delphi applications Oracle database via a .NET Web...
11
by: gnuist006 | last post by:
Is there a Delphi equivalent in the C world or Scheme/LISP world ? Recently, Delphi is in resurgence. In Russia people are using like crazy. For example, Bolega has written a free image...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.