Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Addon framework

Addon framework

Scheduled Pinned Locked Moved .NET (Core and Framework)
databasesysadminhelpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adriaan Davel
    wrote on last edited by
    #1

    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

    N P 2 Replies Last reply
    0
    • A Adriaan Davel

      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

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      This is something similar, perhaps it will give you some ideas. Application Suite Template[^]


      I know the language. I've read a book. - _Madmatt

      A 1 Reply Last reply
      0
      • N Not Active

        This is something similar, perhaps it will give you some ideas. Application Suite Template[^]


        I know the language. I've read a book. - _Madmatt

        A Offline
        A Offline
        Adriaan Davel
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • A Adriaan Davel

          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

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          Why not take a look into the Managed Extensebility Framework (MEF)? It's very powerful (clickety[^]).

          "WPF has many lovers. It's a veritable porn star!" - Josh Smith

          As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

          My blog | My articles | MoXAML PowerToys | Onyx

          A 1 Reply Last reply
          0
          • A Adriaan Davel

            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

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            have you looked here, http://msdn.microsoft.com/en-us/library/bb384200.aspx[^]


            I know the language. I've read a book. - _Madmatt

            1 Reply Last reply
            0
            • P Pete OHanlon

              Why not take a look into the Managed Extensebility Framework (MEF)? It's very powerful (clickety[^]).

              "WPF has many lovers. It's a veritable porn star!" - Josh Smith

              As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

              My blog | My articles | MoXAML PowerToys | Onyx

              A Offline
              A Offline
              Adriaan Davel
              wrote on last edited by
              #6

              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

              P 1 Reply Last reply
              0
              • A Adriaan Davel

                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

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #7

                Sacha Barber has an excellent sample here[^].

                "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                My blog | My articles | MoXAML PowerToys | Onyx

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups