Hello,
I'm creating a small plugin interface for my future .NET DLL's. This
interface is written in C# primarily for C# dlls. However, in one
particular instance, I have to plugin a C++ dll. How do I use the following
interface that is written in C# in C++ (I have limited experience with VC++
and am just learning .net)?
Thanks in advance!
Chris
using System;
namespace PlugIn
{
public interface IPlugin
{
Int32 Add(Int32 a, Int32 b);
string Name{get;set;}
IPluginHost Host{get;set;}
}
/// <summary>
/// The host
/// </summary>
public interface IPluginHost
{
bool Register(IPlugi n ipi);
}
}
In the .h file of the C++ project, do I just add the ": public IPlugin"
clause to the class definition? What else is necessary?
// test.h
#pragma once
using namespace System;
namespace test
{
public __gc class Class1 : public IPlugin
{
// TODO: Add your methods for this class here.
};
} 2 7452
Chris,
The only way to access this in C++ is to either use Managed Extensions
in C++, in which case you have access to all unmanaged types, or you will
have to export the interface as a COM interface, and have your C++ code
create a COM component that implements the interface.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com
"Chris" <c w a n @ n o s p a m - v i g i l . c o m> wrote in message
news:eQ******** ******@tk2msftn gp13.phx.gbl... Hello,
I'm creating a small plugin interface for my future .NET DLL's. This interface is written in C# primarily for C# dlls. However, in one particular instance, I have to plugin a C++ dll. How do I use the
following interface that is written in C# in C++ (I have limited experience with
VC++ and am just learning .net)?
Thanks in advance!
Chris
using System; namespace PlugIn
{ public interface IPlugin
{
Int32 Add(Int32 a, Int32 b);
string Name{get;set;}
IPluginHost Host{get;set;}
}
/// <summary>
/// The host
/// </summary>
public interface IPluginHost
{
bool Register(IPlugi n ipi);
}
}
In the .h file of the C++ project, do I just add the ": public IPlugin" clause to the class definition? What else is necessary?
// test.h #pragma once
using namespace System;
namespace test
{
public __gc class Class1 : public IPlugin
{
// TODO: Add your methods for this class here.
};
}
Thanks Nicholas, I'll give it a try.
"Nicholas Paldino [.NET/C# MVP]" <ni************ **@exisconsulti ng.com> wrote
in message news:eW******** ******@TK2MSFTN GP10.phx.gbl... Chris,
The only way to access this in C++ is to either use Managed Extensions in C++, in which case you have access to all unmanaged types, or you will have to export the interface as a COM interface, and have your C++ code create a COM component that implements the interface.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - ni************* *@exisconsultin g.com
"Chris" <c w a n @ n o s p a m - v i g i l . c o m> wrote in message news:eQ******** ******@tk2msftn gp13.phx.gbl... Hello,
I'm creating a small plugin interface for my future .NET DLL's. This interface is written in C# primarily for C# dlls. However, in one particular instance, I have to plugin a C++ dll. How do I use the following interface that is written in C# in C++ (I have limited experience with VC++ and am just learning .net)?
Thanks in advance!
Chris
using System; namespace PlugIn
{ public interface IPlugin
{
Int32 Add(Int32 a, Int32 b);
string Name{get;set;}
IPluginHost Host{get;set;}
}
/// <summary>
/// The host
/// </summary>
public interface IPluginHost
{
bool Register(IPlugi n ipi);
}
}
In the .h file of the C++ project, do I just add the ": public IPlugin" clause to the class definition? What else is necessary?
// test.h #pragma once
using namespace System;
namespace test
{
public __gc class Class1 : public IPlugin
{
// TODO: Add your methods for this class here.
};
}
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: baylor |
last post by:
In C#, an interface cannot mark any method as static. i'm told the ILASM
supports it but i've never tested that
Two questions. First, why? OK, i've heard the reason about interfaces being
allocated on the stack but that's not a real reason. Which is OK because this
isn't a real question, it's just a complaint dressed up to look like a reason
Second question. If a language doesn't support a fairly obvious feature, one
has to wonder if...
|
by: Frank Rizzo |
last post by:
We are having one of those religious debates at work: Interfaces vs
Classes. My take is that Classes give you more flexibility. You can
enforce a contract on the descendant classes by marking methods abstract
(which is all that an interface does). In addition, the classes allow
you to be flexible by adding functionality that child classes inherit.
Or by providing optional functionality via virtual methods.
Now, I understand that...
|
by: John |
last post by:
What is the purpose / benefit of using an interface statement?
It doesn't seem like anything more than a different way to make a class...
(except you can't define any procedures in an interface like you can do in a
class).
I'm obviously missing something...
John
|
by: Sean Kirkpatrick |
last post by:
To my eye, there doesn't seem to be a whole lot of difference between
the two of them from a functional point of view. Can someone give me a
good explanation of why one vs the other?
Sean
|
by: _dee |
last post by:
Question about best use of interfaces:
Say there's a 'Master' class that needs to implement a few
interfaces:
class Master : I1, I2, I3
{
}
The actual code already exists in smaller classes that each
| |
by: RSH |
last post by:
Hi,
I have been reading on interfaces working on samples I've run across on the
web. For the life of me I cannot seem to grasp them.
It appears to me that interfaces are simply blueprints to a class, that when
implemented, they require the implementing calss to make sure that each of
the properties, functions etc. are handled by the class. (????)
What I am really having a problem with is how they overcome the limitation
|
by: Tony |
last post by:
class Interface
{
public:
virtual void DoItNow()=0;
};
class A: public Interface
{
public:
void DoItNow(); // satisfies interface explicitly
|
by: =?Utf-8?B?UmljaA==?= |
last post by:
Greetings,
I am actually a VB.Net guy, but I have worked somewhat with C++ and C#. I
just want to ask about the relationship between Abstract Classes and
Interfaces.
My first question is if C# even has Iinterfaces. I took some Java
programming classes and Interfaces are a main staple of Java. And in VB.Net
I use interfaces for setting up definitions of classes. I am guessing that
Abstract classes in C# do the same thing as...
|
by: hyperboreean |
last post by:
Hi,
Probably it has been asked before, but I'll still ask.
Why doesn't python provide interfaces trough its standard library? Or it
was ever proposed to be included in the language?
Zope's implementation seems pretty flexible and straightforward.
Thanks.
|
by: A.Gallus |
last post by:
If I declare a function pure virtual:
class A
{
virtual void myfunc() = 0;
}
and I derive a class from A:
class B : public A
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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();...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |