0

I am loading an assembly at runtime on my code and all the references to that assembly are broken at the run time as I have mentioned on this thread:

How to keep dynamically loaded assemblies form breaking code at compile time?

BUT now I tried to solve this issue using the technique that the gentleman here in this thread suggested:

http://www.codeproject.com/Articles/187788/Dynamically-Loading-NET-Assemblies-using-Interface

the only problem here that the the class that I am activating from the dynamic assembly uses the native types to that assembly which I can not define in my Interface. and that's where I am stuck.

I also tried replacing those foreign assembly's native type with object/dynamic but my casting is failing at that point.

Any suggestion on how to solve this issue?

Community
  • 1
  • 1
Lost
  • 12,007
  • 32
  • 121
  • 193
  • You can simply bite the bullet and refactor your code to not use classes/methods from that "other" assembly and instead use your own interface(s). There is really not much can be done short of careful refactoring if your libraries tied together with plenty of static method calls and other hidden dependencies... – Alexei Levenkov Aug 22 '13 at 02:12
  • There is no reason why `dynamic` should fail - can you post a sample? – RobSiklos Aug 22 '13 at 02:36
  • So basically I am posting you a small snippet. The code of the source assembly looked something like this: `string TriggerSetting { get; set; } Channel VoltageChannel { get; set; } bool CaptureMainCurrent { get; set; }` But now that I have my interface which does not have knowledge of the types like "Channel" which is the native type to this plugin, I have to replace it with something and I did this with it ` string TriggerSetting { get; set; } dynamic VoltageChannel { get; set; } bool CaptureMainCurrent { get; set; }` – Lost Aug 22 '13 at 17:38

0 Answers0