473,471 Members | 4,687 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Plugin Interface and Invalid Cast Exceptions

1 New Member
I develop an application that uses a plugin interface, that the hosting application as well as the plugins implement. Each plugin is loaded via:

newPlugin.Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.G etType(pluginType.ToString()));

All Plugins are inside a sub directory called "plugins" of the main application.

Now I developed one plugin that should implement a network interface, using external dll's from a framework i wrote some time ago. This framework binary serializes objects, compresses them and sends them over the net.

When I receive such an Object in the Plugin, i can deserialize it without any problem and it is showed correctly while debugging as "object" type (resulting from the deserialization). Now, when I try to cast this object to a structure (that is described in an external dll - an object library - which is the same at the sending an receiving side) i get a "Cast Exception" in the plugin.

By the way, the object and it's type look correctly while debugging and, i can send such objects from this application to the remote one, that also can cast them, using exact the same dll (the object library).

I searched around a lot, but found no real answer...
Maybe the problem is that "Activator.CreateInstance" loads the plugin assembly into a wrong appDomain, because the remote application does not use plugins and refers to the object library - dll directly.

The source code is a bit complex, so i hope that someone might be able to help me just with this description of the problem.

Thx in advance,

Gerd
Sep 4 '07 #1
0 1361

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Zheng Da | last post by:
I don't know where should I ask the question, so send the email to this group. I choose this group, because I want to write the program with c++ :) I want to write a program which support...
2
by: Rudolf | last post by:
Dear NG, I want to create a Plugin System in C# (WinForms). Has anybody experience about this, tips, tricks, or any links. Thank you very much The DotNetJunkie
3
by: Roger Boesch | last post by:
Im currently working on a plugin architectur for a software product written in c# and have found the following problem: Project a) Application, Application with all classes used in this app ...
4
by: Jer | last post by:
Hi all, I am trying to get plugins working in my application. I am using the approach of writing an interface and then implementing that interface in each plugin. I would like to be able to...
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;...
2
by: Matt | last post by:
I'm hoping someone can steer me in the right direction to try to do the following: I am developing an application where we receive files from customers. Right now we receive a variety of...
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: ...
1
by: Olie | last post by:
I was quite surprised to find virtually nothing about this but I may have been searching for the wrong thing. I want to know the best way to provide a programming interface to a plugin. I...
7
by: WTH | last post by:
I am now aware (I am primarily a C++ developer) that in C# if you reference the same interface from the same file in two different projects the types are actually incompatible. I found this out...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
jinu1996
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
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...
0
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...

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.