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. Converting Between Types

Converting Between Types

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestion
8 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
    AndrewVos
    wrote on last edited by
    #1

    I'm having a problem with a program I'm working on, which uses plugins. -The plugin is declared on one Assembly, as a class. -Other plugin assemblies have classes that inherit from this plugin. -The main application loads all assemblies in the root dir, and loads classes with the BaseType name of the plugins name. Now when I try to load the plugins, they can't be converted to the plugin type! It seems that the base type and the plugin type are different, but I know they aren't. I even checked to see if the GUID is the same. Anyone know what I'm doing wrong here? I'm pretty stuck, and can't go on with this project if I can't find a way out :(


    All your source are belong to us!

    T 1 Reply Last reply
    0
    • A AndrewVos

      I'm having a problem with a program I'm working on, which uses plugins. -The plugin is declared on one Assembly, as a class. -Other plugin assemblies have classes that inherit from this plugin. -The main application loads all assemblies in the root dir, and loads classes with the BaseType name of the plugins name. Now when I try to load the plugins, they can't be converted to the plugin type! It seems that the base type and the plugin type are different, but I know they aren't. I even checked to see if the GUID is the same. Anyone know what I'm doing wrong here? I'm pretty stuck, and can't go on with this project if I can't find a way out :(


      All your source are belong to us!

      T Offline
      T Offline
      Tim McCurdy
      wrote on last edited by
      #2

      Instead of using a BaseType Class that they must inherit from, have you tried specifying an Interface that they must implement?

      A 1 Reply Last reply
      0
      • T Tim McCurdy

        Instead of using a BaseType Class that they must inherit from, have you tried specifying an Interface that they must implement?

        A Offline
        A Offline
        AndrewVos
        wrote on last edited by
        #3

        The problem has been resolved. By the way, I couldn't use an interface, like all the normal examples on the net, because my plugin object has to inherit from another object and it has to have custom code in order for the plugins to work properly. This is why I could not use an interface.


        All your source are belong to us!

        R 1 Reply Last reply
        0
        • A AndrewVos

          The problem has been resolved. By the way, I couldn't use an interface, like all the normal examples on the net, because my plugin object has to inherit from another object and it has to have custom code in order for the plugins to work properly. This is why I could not use an interface.


          All your source are belong to us!

          R Offline
          R Offline
          Robert Rohde
          wrote on last edited by
          #4

          Well you can inherit from some class and still implement another interface.

          A 2 Replies Last reply
          0
          • R Robert Rohde

            Well you can inherit from some class and still implement another interface.

            A Offline
            A Offline
            AndrewVos
            wrote on last edited by
            #5

            Or just get it working how I want it to work. Much less code, much better.


            All your source are belong to us!

            1 Reply Last reply
            0
            • R Robert Rohde

              Well you can inherit from some class and still implement another interface.

              A Offline
              A Offline
              AndrewVos
              wrote on last edited by
              #6

              Let me make myself a bit more clear: I have 38 plugins already built, which implement this class. I worked a long time on them, and they are all working perfectly, so a complete redesign would make me have to strangle myself. Turns out the problem was that I had two copies of the library containing the Plugin class being built. Although they were exactly the same, code-wise; maybe the version could of been different or something, resulting in the most irritating "Cannot convert from Plugin to Plugin" (I forget the proper syntax). As a quick workaround I just popped the plugins libraries into the same directory as the exe, so they both reference the exact same Plugin library.


              All your source are belong to us!

              R 1 Reply Last reply
              0
              • A AndrewVos

                Let me make myself a bit more clear: I have 38 plugins already built, which implement this class. I worked a long time on them, and they are all working perfectly, so a complete redesign would make me have to strangle myself. Turns out the problem was that I had two copies of the library containing the Plugin class being built. Although they were exactly the same, code-wise; maybe the version could of been different or something, resulting in the most irritating "Cannot convert from Plugin to Plugin" (I forget the proper syntax). As a quick workaround I just popped the plugins libraries into the same directory as the exe, so they both reference the exact same Plugin library.


                All your source are belong to us!

                R Offline
                R Offline
                Robert Rohde
                wrote on last edited by
                #7

                AndrewVos wrote:

                Although they were exactly the same, code-wise; maybe the version could of been different or something, resulting in the most irritating "Cannot convert from Plugin to Plugin" (I forget the proper syntax).

                I know this one. In daily work it helps a lot to remove all '*' from the version in the 'AssemblyInfo.cs'.

                A 1 Reply Last reply
                0
                • R Robert Rohde

                  AndrewVos wrote:

                  Although they were exactly the same, code-wise; maybe the version could of been different or something, resulting in the most irritating "Cannot convert from Plugin to Plugin" (I forget the proper syntax).

                  I know this one. In daily work it helps a lot to remove all '*' from the version in the 'AssemblyInfo.cs'.

                  A Offline
                  A Offline
                  AndrewVos
                  wrote on last edited by
                  #8

                  hehe. Bad hey? The worst for me is when the registry data changes between debugs, and you think "why is it not working!???!".


                  All your source are belong to us!

                  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