Great, thanks! I was accidentally copying the host assembly into the addin directory along with the addin assembly. Works well now. This exception is understandable but it could be a little more specific.
On Tue, Oct 13, 2009 at 2:50 AM, Lluis Sanchez <[email protected]> wrote: > > The most probable cause of the error is that you have several copies of > the host assembly in different locations. .NET considers that types > coming from different assembly locations are different. > > El dg 11 de 10 de 2009 a les 11:19 -0700, en/na Andy Selvig va escriure: > > Hi- > > > > I have an application using Mono.Addins but I'm having trouble > > creating instances of the extension points. The addin itself is being > > detected and loading fine, but when I try to create an instance from > > an extension node, I get an exception stating that I can't perform the > > conversion. I've pasted the relevant code below. > > > > >From host addin file: > > > > <ExtensionPoint path = "/Stems/Petals"> > > <ExtensionNode name="Petal" type="Mono.Addins.TypeExtensionNode"/> > > </ExtensionPoint> > > > > from extension addin file: > > > > <Extension path = "/Stems/Petals"> > > <Petal id="RichContent" > > type="Swivel.Stems.Controllers.RichContentController" /> > > </Extension> > > > > from the host dll: > > > > namespace Swivel.Stems.Controllers > > { > > > > /// <summary> > > /// Interface for petals. > > /// </summary> > > public interface IPetal > > { > > ... > > } > > } > > > > from the addin dll: > > > > namespace Swivel.Stems.Controllers > > { > > public class RichContentController : Controller, IPetal > > { > > } > > } > > > > and from the code that loads the extensions in the host dll: > > > > foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/ > > Stems/Petals")) > > { > > IPetal petal = (IPetal)node.CreateInstance(); > > } > > > > It throws an exception on the CreateInstance call: > > > > Unable to cast object of type > > 'Swivel.Stems.Controllers.RichContentController' to type > > 'Swivel.Stems.Controllers.IPetal'. > > > > It seems like this cast is perfectly reasonable. I don't understand > > what's going wrong. In the examples on the site, the extensions only > > implement the interface, and don't subclass anything else. Is this not > > something that's supported? > > > > Thanks. > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Mono.Addins" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/mono-addins?hl=en -~----------~----~----~----~------~----~------~--~---
