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

Interface Casting for plug-in system

Forgive my ignorance on this subject; I'm just starting to use .NET. I have
a plug-in manager written in managed c++ with the following code:

namespace MySDK{
public __gc __interface IPlugIn{
void RunCommand();
};
};

/// Manager class
void Manager::LoadPlugIn(const char* name){
try{
Assembly *a = Assembly::LoadFrom(name);
Type *t = a->GetType("VBPlugIn.PlugIn");
Object* o = Activator::CreateInstance(t);
Type* t1 = t->GetInterface("MySDK.IPlugIn",true);
bool isInt = t1->IsInstanceOfType(o);
MySDK::IPlugIn* pPlugIn = __try_cast<MySDK::IPlugIn*>(o);
} catch(System::InvalidCastException*) {
app.Print("Cast exception\n");
} catch(System::Exception* e) {
app.Print("Problem with my activator\n");
}
}

I wrote a VB.NET dll with a class that implements the MySDK.IPlugIn
interface. I am able to load and create an instance of the VB plugin in my
LoadPlugIn function. An exception is thrown when I attempt to cast the
object to an IPlugIn interface.
What am I doing wrong? -or- Is this even possible?

Thanks in advance,
-steve
Nov 17 '05 #1
0 1056

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

Similar topics

11
by: Maxim Kasimov | last post by:
Hi. Are there widely used and recommended Python libraries that will let me makes a portable text user interface? -- Best regards, Maxim
20
by: Simon Harvey | last post by:
Festive greetings fellow programmers! I've been programming now for about 4, maybe 5 years now. 4 of those years were at university so and I havent had much work experience of making real world...
3
by: anon | last post by:
How can I do the following.... interface iface { int someMethod(); } class c1 : iface { int someMethod() {return 10;}
7
by: yufufi | last post by:
lets say we have a 'shape' class which doesn't implement IComparable interface.. compiler doesn't give you error for the lines below.. shape b= new shape(); IComparable h; h=(IComparable)b;...
4
by: Shane | last post by:
I am having a problem where I create an instance of a class from an assembly and I try to cast it to an interface that it inherits from and it says that the cast is invalid. Here is the code: ...
3
by: Glenn Thimmes | last post by:
Hello, I am trying to understand the proper way to test an object to find out if it supports a specific interface. Right now, the only way I know to accomplish this is to attempt casting it to...
15
by: jon | last post by:
How can I call a base interface method? class ThirdPartyClass :IDisposable { //I can not modify this class void IDisposable.Dispose() { Console.WriteLine( "ThirdPartyClass Dispose" ); } } ...
1
by: Rene | last post by:
Supposed that a class "MyTestClass" implement interface "IMyInterface" (not explicitly). Now suppose that I make an instantiate of "MyTestClass" and then use this instance to pass it to a...
2
by: Paul | last post by:
Hi all, I am trying to cast my page to an Interface at design time with no joy. sControl = ((IStatusPage)Page). Despite this page 100% being inheriting this interface it will not work. I...
8
by: Lamefif | last post by:
// C3DRect supports IDraw and IShapeEdit. class C3DRect : public IDraw, public IShapeEdit { public: C3DRect(); virtual ~C3DRect(); // IDraw virtual void Draw(); // IShapeEdit virtual void...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.