Click here to Skip to main content
15,921,212 members
Home / Discussions / C#
   

C#

 
GeneralRe: porting this code to c# Pin
Paolo Ponzano9-Apr-04 20:11
Paolo Ponzano9-Apr-04 20:11 
GeneralRe: porting this code to c# Pin
Mike Dimmick10-Apr-04 3:59
Mike Dimmick10-Apr-04 3:59 
GeneralRe: porting this code to c# Pin
Paolo Ponzano10-Apr-04 5:07
Paolo Ponzano10-Apr-04 5:07 
QuestionWhat should I do? Pin
lajiyo9-Apr-04 19:39
lajiyo9-Apr-04 19:39 
AnswerRe: What should I do? Pin
Mikko Puonti9-Apr-04 23:26
Mikko Puonti9-Apr-04 23:26 
GeneralRe: What should I do? Pin
lajiyo11-Apr-04 15:16
lajiyo11-Apr-04 15:16 
GeneralRe: What should I do? Pin
Mikko Puonti12-Apr-04 5:58
Mikko Puonti12-Apr-04 5:58 
GeneralProblems Creating C# Plugin Support for my App Pin
Defiant009-Apr-04 18:57
Defiant009-Apr-04 18:57 
I've got an application that I'm writing that I want to use plugins with. I've looked through the plugin examples, and to the best of my knowledge have done the same (although in a slightly different fashion) as the examples.

Oh, and sorry about the lack of tabs...I can't seem to get the forum to display them...

My plugin interface:

// The terrain modifier plugin interface.

public interface ITerrainPlugin {
string Name{get;}

void ShowInterface();

void CalculateHeight(float[,] heights);
}


The test plugin (no actual meaningful code...):

// project created on 4/1/2004 at 12:58 PM
using System;

public class TerrainNoisePlugin : ITerrainPlugin {

public string Name {
get {
return "Deffie's Terrain Noise Plugin";
}
}

public void ShowInterface() {
System.Windows.Forms.MessageBox.Show("Interface? Ha! Not yet, bud Smile | :) ");
}

public void CalculateHeight(float[,] heights) {

}
}


And here's the code to load the plugins (each is located in App.StartupPath + "\\Plugins\\Terrain\\" and args contains the class name, which is the same as the dll file name minus the .dll):

try {
Type plugType = null;
Assembly asm = null;
asm = Assembly.LoadFrom(Application.StartupPath + "\\Plugins\\Terrain\\" + args + ".dll");
if (asm != null) {
plugType = asm.GetType(args);
} else {
MessageBox.Show("Assembly is null");
}
if (plugType != null) {
object instance = Activator.CreateInstance(plugType);
if (instance != null) {
MessageBox.Show("Instance isn't null...type is: " + instance.GetType());
} else {
MessageBox.Show("instance is null");
}
ITerrainPlugin plugin = (ITerrainPlugin)instance;
if (plugin == null) {
MessageBox.Show("plugin instance is null");
} else {
plugin.ShowInterface();
}
} else
MessageBox.Show("Type is null");
} catch (Exception eX) {
MessageBox.Show("Error: " + eX.Message, "Error");
}


It complains at this line:
ITerrainPlugin plugin = (ITerrainPlugin)instance;
With the complaint that this is not a valid cast.

Any ideas?

Aaron
GeneralRe: Problems Creating C# Plugin Support for my App Pin
leppie9-Apr-04 21:09
leppie9-Apr-04 21:09 
GeneralRe: Problems Creating C# Plugin Support for my App Pin
Defiant0010-Apr-04 8:12
Defiant0010-Apr-04 8:12 
GeneralRe: Problems Creating C# Plugin Support for my App Pin
Mikko Puonti9-Apr-04 23:37
Mikko Puonti9-Apr-04 23:37 
GeneralRe: Problems Creating C# Plugin Support for my App Pin
Defiant0010-Apr-04 8:20
Defiant0010-Apr-04 8:20 
GeneralRe: Problems Creating C# Plugin Support for my App Pin
SethGeco20-Nov-08 5:47
SethGeco20-Nov-08 5:47 
GeneralDouble Click Interval Pin
Tom Clement9-Apr-04 15:43
professionalTom Clement9-Apr-04 15:43 
GeneralRe: Double Click Interval Pin
Tom Clement9-Apr-04 15:50
professionalTom Clement9-Apr-04 15:50 
GeneralRe: Double Click Interval Pin
Tom Clement9-Apr-04 15:53
professionalTom Clement9-Apr-04 15:53 
GeneralRe: Double Click Interval Pin
Nick Parker9-Apr-04 17:40
protectorNick Parker9-Apr-04 17:40 
GeneralRe: Double Click Interval Pin
leppie9-Apr-04 21:05
leppie9-Apr-04 21:05 
GeneralRe: Double Click Interval Pin
Tom Clement10-Apr-04 6:29
professionalTom Clement10-Apr-04 6:29 
GeneralImport to SqlServer Pin
quocbao9-Apr-04 14:29
quocbao9-Apr-04 14:29 
GeneralRe: Import to SqlServer Pin
dabuskol10-Apr-04 20:37
dabuskol10-Apr-04 20:37 
GeneralHelp can't figure this one out with OleDbDataAdapter and acesss Pin
MeterMan9-Apr-04 13:52
MeterMan9-Apr-04 13:52 
GeneralRe: Help can't figure this one out with OleDbDataAdapter and acesss Pin
leppie9-Apr-04 21:14
leppie9-Apr-04 21:14 
GeneralRe: Help can't figure this one out with OleDbDataAdapter and acesss Pin
MeterMan9-Apr-04 21:21
MeterMan9-Apr-04 21:21 
GeneralText box scrolling Pin
Andy Brummer9-Apr-04 10:03
sitebuilderAndy Brummer9-Apr-04 10:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.