TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Njn Bat
NA
9
8.3k
Reflection to call method in class implementing interface
Nov 27 2014 10:40 AM
I have 2 dll's . One Dll has interface "InterfaceStart" . Second dll has a class "
AbServicesStart"
which implements the interface.
I must create the instance of the class and call the implemented start method .
I have tried below code how ever i get an exception saying
A first chance exception of type 'System.Reflection.TargetException' occurred in mscorlib.dll
Additional information: Object does not match target type
.
Can u help me figure out the issue.
string assemblyPath = "D:\\APP\\
AbInterface
.dll";
string assemblyClassPath = "D:\\APP\\
ABServe
.dll";
Assembly assembly = Assembly.LoadFrom(assemblyPath);
Assembly assemblyClass = Assembly.LoadFrom(assemblyClassPath);
Type AbserveStart = assembly.GetType("AB.
ABServe
.InterfaceStart");
Type classstart = assemblyClass.GetType("AB.
AbInterface
.
AbServicesStart
");
MethodInfo startMethod = AbserveStart.GetMethod("Start");
object interfaceObject = Activator.CreateInstance(classstart);
startMethod.Invoke(interfaceObject, null);
Reply
Answers (
3
)
Web browser control to download file in folder
What is the relationship between linklist and graph?