473,795 Members | 2,452 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

implement unmanaged interface

Hi,

Can somebody suggest me, how can I implement a vc++ interface in C#.net.
This interface has method CallMe( ) which is used as a CallBack from my main
application.

Thanks,
Baji.
Nov 14 '07 #1
4 4242
Baji,

You can't. It has to be a COM interface, or a managed interface written
in C++/CLI. Otherwise, you have to implement it in C++ and then call into
managed code.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Baji." <Ba**@discussio ns.microsoft.co mwrote in message
news:1F******** *************** ***********@mic rosoft.com...
Hi,

Can somebody suggest me, how can I implement a vc++ interface in C#.net.
This interface has method CallMe( ) which is used as a CallBack from my
main
application.

Thanks,
Baji.

Nov 14 '07 #2
Yes,

It is a COM interface. & has a method CallMe( ). I need to implement this
interface in C# application. And, this method will be called by unmanaged
application.

can you suggest me something here?

"Nicholas Paldino [.NET/C# MVP]" wrote:
Baji,

You can't. It has to be a COM interface, or a managed interface written
in C++/CLI. Otherwise, you have to implement it in C++ and then call into
managed code.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Baji." <Ba**@discussio ns.microsoft.co mwrote in message
news:1F******** *************** ***********@mic rosoft.com...
Hi,

Can somebody suggest me, how can I implement a vc++ interface in C#.net.
This interface has method CallMe( ) which is used as a CallBack from my
main
application.

Thanks,
Baji.


Nov 14 '07 #3
Baji,

If it is a COM interface, you should be able to add a reference (on the
COM tab) to that dll (or the type library that stores the interfaces) and
VS.NET will generate managed representations of the interface for you.

Or, if you want to do this by hand, you can use the TLBIMP utility that
comes with the framework.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Baji." <Ba**@discussio ns.microsoft.co mwrote in message
news:EE******** *************** ***********@mic rosoft.com...
Yes,

It is a COM interface. & has a method CallMe( ). I need to implement this
interface in C# application. And, this method will be called by unmanaged
application.

can you suggest me something here?

"Nicholas Paldino [.NET/C# MVP]" wrote:
>Baji,

You can't. It has to be a COM interface, or a managed interface
written
in C++/CLI. Otherwise, you have to implement it in C++ and then call
into
managed code.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Baji." <Ba**@discussio ns.microsoft.co mwrote in message
news:1F******* *************** ************@mi crosoft.com...
Hi,

Can somebody suggest me, how can I implement a vc++ interface in
C#.net.
This interface has method CallMe( ) which is used as a CallBack from my
main
application.

Thanks,
Baji.



Nov 14 '07 #4
Nicolas,

I am able to add the dll as a reference & also I have derived my class from
the interface. & the DEV env has also added the interface structure etc., to
my code. Now the interface method :CallMe() need to be called by my unmanaged
application. So, how can I achieve this ?

I am usinng VS 2008. After compilation am putting the dll into GAC & also
registering the tlb

I never get a break on the interface method. I think I am not doing in the
right way, can you suggest me ?

Thanks,
Baji.
"Nicholas Paldino [.NET/C# MVP]" wrote:
Baji,

If it is a COM interface, you should be able to add a reference (on the
COM tab) to that dll (or the type library that stores the interfaces) and
VS.NET will generate managed representations of the interface for you.

Or, if you want to do this by hand, you can use the TLBIMP utility that
comes with the framework.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Baji." <Ba**@discussio ns.microsoft.co mwrote in message
news:EE******** *************** ***********@mic rosoft.com...
Yes,

It is a COM interface. & has a method CallMe( ). I need to implement this
interface in C# application. And, this method will be called by unmanaged
application.

can you suggest me something here?

"Nicholas Paldino [.NET/C# MVP]" wrote:
Baji,

You can't. It has to be a COM interface, or a managed interface
written
in C++/CLI. Otherwise, you have to implement it in C++ and then call
into
managed code.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Baji." <Ba**@discussio ns.microsoft.co mwrote in message
news:1F******** *************** ***********@mic rosoft.com...
Hi,

Can somebody suggest me, how can I implement a vc++ interface in
C#.net.
This interface has method CallMe( ) which is used as a CallBack from my
main
application.

Thanks,
Baji.


Nov 15 '07 #5

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

Similar topics

2
4827
by: Billy Porter | last post by:
Greetings, I got a class that wraps the System.Data.SqlClient.SqlConnection class (no COM interaction). I'm not sure if I'm supposed to implement the IDisposable pattern for this wrapper or not. Since one of it's members (SqlConnection) implements this interface, I'm thinking maybe I ought to. But on the other hand, those unmanaged resources has already been wrapped in the SqlConnection class... If so, how would my Dispose method look...
7
1861
by: Lev | last post by:
Hi, I have an unmanaged pointer to a class that I want to hold in a managed class. I pass the pointer (from unmanaged code) in the constructor of the managed class, and at that point it has value. It is stored in a member variable in my managed class declared as MyObj __nogc* pMyObj. When I try to retrieve it later, using a function declared as MyObj __nogc* GetObj, the pointer has been corrupted and shows up as <undefined value> when...
1
1667
by: Manny Silva | last post by:
Hi, I used ATL to create a COM library that does a lot of work via IStreams that are passed in. I had hoped to test this library using managed C++. I added my COM library as a reference and vc brought it in and created an interop dll for me. The problem is that it also wrapped the IStream interface as a managed interface. I need to use API's such as SHCreateStreamOnFile in order to get the IStream. This API will not accept the...
3
1958
by: Tommy Svensson \(InfoGrafix\) | last post by:
I've been instructed to work againt a huge unmanaged C++ API from a C# application. Now, the only way, as I've understood it, is to go the Managed Extensions for C++ way. This means I have to write a wrapper between unmanaged API and my managed app. Now on to the question: If there's an unmanaged API class called X with a defined method
1
1471
by: anders | last post by:
I call from managed C++ a DCOM server interface method that takes a callback interface as parameter. I cannot figure out how to implement such a callback object in managed C++. The callback interface (e.gr. ICallback) is defined by the server type library. I have figured out that the following code seems to implement a COM object in managed C++ but how do I implement the callback interface ICallback: #import "dcom_server.exe" // Import...
1
1982
by: MLM450 | last post by:
I have created a .NET component in C# that has 2 interfaces. One is an incoming interface with methods being exposed to COM-aware clients. The other is an outgoing event interface that the unmanaged C++ sink implements. Here is the C# code: using System; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Reflection; using System.Diagnostics;
0
1116
by: krzys | last post by:
After hours of browsing I can't find any hints on how to implement a COM component using a managed C++ class. In C# this is trivial, you import the interface like below and just implement it. In C++ neither inheriting such unmanaged interfaces nor adding the IMPLEMENTS_INTERFACE sections appears to work. The documentation doesn't provide any clue.
2
12361
by: Jon Slaughter | last post by:
How difficult is it for one to integrate unmanaged C++ into C#? I know for functions one can use DLLimport but how does one go about doing it for classes? Do I have to completely reimplement the classes in managed C++ as a wrapper to the unmanaged C++ classes or is there an easier way? Essentially what I have done is written a C++ kernel mode driver and I want to use it from my C# program. Because it requires some setup outside the...
4
9702
by: cgarcia0117 | last post by:
For any class I write in C# that has a member variable that implements IDisposable my class implements the IDisposable pattern. I do this to guarantee the reference to the member is explicitly released and the object is eligible for garbage collection when my class is disposed or its' finalizer is called by GC. My question is whether using this approach is even necessary? My feeling is yes because it ensures the member is explicitly...
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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,...
1
10164
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
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
9042
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
7538
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
6780
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3723
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.