Addon framework
-
I'm working on an "add-on enabled" application where assemblies are deployed (copied / uploaded) to a server (and a reference added to a database) making the add-on available to the user. To set the standards of the add-on I've created a separate library with the interface definitions that I can even send to 3rd party vendors. Problem comes when I try to instantiate the uploaded assembly and cast the instance back to my interface definition. My test add-on is 2 dll's, one for the add-on and one for the interface definition which I put together in the same folder, the instance is created correctly and I can get the public attributes with reflection but the instance type is
object
and cannot be cast to my interface type. Any ideas? I have played around with different ways to load the assembly file but it does not seem to make a difference... If I check if the Interface is implemented on the Type it is (assemb.GetTypes().Where(t => t.GetInterface("MyInterface") != null).FirstOrDefault()
), but I suspect that the problem is that its checking by name...____________________________________________________________ Be brave little warrior, be VERY brave
-
I'm working on an "add-on enabled" application where assemblies are deployed (copied / uploaded) to a server (and a reference added to a database) making the add-on available to the user. To set the standards of the add-on I've created a separate library with the interface definitions that I can even send to 3rd party vendors. Problem comes when I try to instantiate the uploaded assembly and cast the instance back to my interface definition. My test add-on is 2 dll's, one for the add-on and one for the interface definition which I put together in the same folder, the instance is created correctly and I can get the public attributes with reflection but the instance type is
object
and cannot be cast to my interface type. Any ideas? I have played around with different ways to load the assembly file but it does not seem to make a difference... If I check if the Interface is implemented on the Type it is (assemb.GetTypes().Where(t => t.GetInterface("MyInterface") != null).FirstOrDefault()
), but I suspect that the problem is that its checking by name...____________________________________________________________ Be brave little warrior, be VERY brave
This is something similar, perhaps it will give you some ideas. Application Suite Template[^]
I know the language. I've read a book. - _Madmatt
-
This is something similar, perhaps it will give you some ideas. Application Suite Template[^]
I know the language. I've read a book. - _Madmatt
Hi Mark, Thanks for the post. I cannot get the code to run (only have VS 2010 B2) installed, but the architecture is quite different to what I'm using. I'm using an interface that I share between 2 different projects, 1 being the application and 1 being the addon. What you are doing with
Activator.CreateInstance
I have also tried and I experienced to problems described... I can quite easily get an instance of a class in an assembly, and the instance class will be based on my interface that I shared, yet I cannot cast my instance to the interface...____________________________________________________________ Be brave little warrior, be VERY brave
-
I'm working on an "add-on enabled" application where assemblies are deployed (copied / uploaded) to a server (and a reference added to a database) making the add-on available to the user. To set the standards of the add-on I've created a separate library with the interface definitions that I can even send to 3rd party vendors. Problem comes when I try to instantiate the uploaded assembly and cast the instance back to my interface definition. My test add-on is 2 dll's, one for the add-on and one for the interface definition which I put together in the same folder, the instance is created correctly and I can get the public attributes with reflection but the instance type is
object
and cannot be cast to my interface type. Any ideas? I have played around with different ways to load the assembly file but it does not seem to make a difference... If I check if the Interface is implemented on the Type it is (assemb.GetTypes().Where(t => t.GetInterface("MyInterface") != null).FirstOrDefault()
), but I suspect that the problem is that its checking by name...____________________________________________________________ Be brave little warrior, be VERY brave
-
Hi Mark, Thanks for the post. I cannot get the code to run (only have VS 2010 B2) installed, but the architecture is quite different to what I'm using. I'm using an interface that I share between 2 different projects, 1 being the application and 1 being the addon. What you are doing with
Activator.CreateInstance
I have also tried and I experienced to problems described... I can quite easily get an instance of a class in an assembly, and the instance class will be based on my interface that I shared, yet I cannot cast my instance to the interface...____________________________________________________________ Be brave little warrior, be VERY brave
have you looked here, http://msdn.microsoft.com/en-us/library/bb384200.aspx[^]
I know the language. I've read a book. - _Madmatt
-
I looked at MEF and I just couldn't understand the mecahnism. Another chap at my work looked at it and couldn't figure it out either... I'm confused at a high and a low technical level, but all the examples I get shows you how easy it is, and over the years I have grown petrified of things that looks way easy in an example... :) Apart from the link above (which I'll have another look at), do you have some advanced samples that shows the workings?
____________________________________________________________ Be brave little warrior, be VERY brave
-
I looked at MEF and I just couldn't understand the mecahnism. Another chap at my work looked at it and couldn't figure it out either... I'm confused at a high and a low technical level, but all the examples I get shows you how easy it is, and over the years I have grown petrified of things that looks way easy in an example... :) Apart from the link above (which I'll have another look at), do you have some advanced samples that shows the workings?
____________________________________________________________ Be brave little warrior, be VERY brave