Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
Question.NET dll late binding Pin
Blubbo31-Jan-12 8:11
Blubbo31-Jan-12 8:11 
AnswerRe: .NET dll late binding Pin
Blubbo31-Jan-12 8:48
Blubbo31-Jan-12 8:48 
AnswerRe: .NET dll late binding Pin
Luc Pattyn31-Jan-12 9:43
sitebuilderLuc Pattyn31-Jan-12 9:43 
GeneralRe: .NET dll late binding Pin
Shameel31-Jan-12 18:56
professionalShameel31-Jan-12 18:56 
GeneralRe: .NET dll late binding Pin
BobJanova2-Feb-12 4:57
BobJanova2-Feb-12 4:57 
GeneralRe: .NET dll late binding Pin
Blubbo1-Feb-12 7:01
Blubbo1-Feb-12 7:01 
AnswerRe: .NET dll late binding Pin
Abhinav S31-Jan-12 19:42
Abhinav S31-Jan-12 19:42 
AnswerRe: .NET dll late binding Pin
BobJanova2-Feb-12 5:02
BobJanova2-Feb-12 5:02 
I agree with Luc, you are better off doing the following:

class Executable {
 // ...
 public int ReadChip()
        {
             byte[] data = new byte[32];
             
             Assembly a = Assembly.LoadFrom("Reader.dll");
             Type mm = a.GetType("ChipReader.Reader");
             IReader reader = (IReader)Activator.CreateInstance(mm);
             int status = reader.ReadChip(data);
        }
}


Somewhere both the reader DLL and the main app can reference*:
interface IReader {
 int ReadChip(byte[] data);
}


DLL:
namespace ChipReader {
 class Reader : IReader {
  public int ReadChip(byte[] data){
   // etc
  }
 }
}


This allows you to call methods on the reader directly without messing about with reflection code, apart from looking up and instantiating the original type. You can then pass the IReader instance around in the executable like any normal object.

*: If the reader DLLs are specific to this application, the interface can just be in the application, and the reader assembly would need to be compiled with a reference to the executable. This is typically a good approach for plugins, where they are plugging in to a known application. Otherwise, it needs to be in a separate interface assembly which both the app and the reader DLL should reference.
GeneralRe: .NET dll late binding Pin
Blubbo2-Feb-12 5:07
Blubbo2-Feb-12 5:07 
Questionmedia player library Pin
idiot prince31-Jan-12 5:20
idiot prince31-Jan-12 5:20 
AnswerRe: media player library Pin
Abhinav S31-Jan-12 6:48
Abhinav S31-Jan-12 6:48 
GeneralRe: media player library Pin
idiot prince31-Jan-12 7:30
idiot prince31-Jan-12 7:30 
AnswerRe: media player library Pin
Dean Oliver31-Jan-12 7:59
Dean Oliver31-Jan-12 7:59 
QuestionDeployment issue in Win7 Pin
siddisagar31-Jan-12 5:09
siddisagar31-Jan-12 5:09 
AnswerRe: Deployment issue in Win7 - Repost Pin
Richard MacCutchan31-Jan-12 6:09
mveRichard MacCutchan31-Jan-12 6:09 
QuestionCreating tolerance-lines for a given array using two delta-values Pin
T.Mann1131-Jan-12 3:42
T.Mann1131-Jan-12 3:42 
AnswerRe: Creating tolerance-lines for a given array using two delta-values Pin
Luc Pattyn31-Jan-12 3:59
sitebuilderLuc Pattyn31-Jan-12 3:59 
QuestionConvertion from .XLS to .XML through c# code Pin
Member 824179730-Jan-12 23:23
Member 824179730-Jan-12 23:23 
AnswerRe: Convertion from .XLS to .XML through c# code Pin
Richard MacCutchan30-Jan-12 23:43
mveRichard MacCutchan30-Jan-12 23:43 
AnswerRe: Convertion from .XLS to .XML through c# code Pin
Abhinav S31-Jan-12 0:41
Abhinav S31-Jan-12 0:41 
QuestionCalling .dll from a C# application (problem when outside VS2010) Pin
Kaare Tragethon30-Jan-12 22:51
Kaare Tragethon30-Jan-12 22:51 
AnswerRe: Calling .dll from a C# application (problem when outside VS2010) Pin
Abhinav S31-Jan-12 0:42
Abhinav S31-Jan-12 0:42 
GeneralRe: Calling .dll from a C# application (problem when outside VS2010) Pin
Kaare Tragethon31-Jan-12 1:14
Kaare Tragethon31-Jan-12 1:14 
GeneralRe: Calling .dll from a C# application (problem when outside VS2010) Pin
Dave Kreskowiak31-Jan-12 2:12
mveDave Kreskowiak31-Jan-12 2:12 
GeneralRe: Calling .dll from a C# application (problem when outside VS2010) Pin
Pete O'Hanlon31-Jan-12 2:34
mvePete O'Hanlon31-Jan-12 2:34 

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.