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. C#
  4. Using the same class belonging to the same namespaces in two different assembly for a project

Using the same class belonging to the same namespaces in two different assembly for a project

Scheduled Pinned Locked Moved C#
question
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.
  • G Offline
    G Offline
    gokselm
    wrote on last edited by
    #1

    Hi, I am trying to use a class from two different assemblies. This class is contained in the same namespace in the assemblies. These assemblies are referenced in the same project and I want to be able to use both classes. Ex: MyClass is under MyNamespace namespace in Assembly1.dll MyClass is under MyNamespace namespace in Assembly2.dll Assembly1.dll and Assembly2.dll are referenced in MyProject project. How can I use MyClass class from both assemblies. Best Regards

    E L 2 Replies Last reply
    0
    • G gokselm

      Hi, I am trying to use a class from two different assemblies. This class is contained in the same namespace in the assemblies. These assemblies are referenced in the same project and I want to be able to use both classes. Ex: MyClass is under MyNamespace namespace in Assembly1.dll MyClass is under MyNamespace namespace in Assembly2.dll Assembly1.dll and Assembly2.dll are referenced in MyProject project. How can I use MyClass class from both assemblies. Best Regards

      E Offline
      E Offline
      exhaulted
      wrote on last edited by
      #2

      Try the following Assembly1.MyClass class1 = new Assembly1.MyClass(); Assembly2.MyClass class2 = new Assembly2.MyClass(); If you fully qualify your references to the namespaces you should be fine. Kev Pearman MCP

      L 1 Reply Last reply
      0
      • G gokselm

        Hi, I am trying to use a class from two different assemblies. This class is contained in the same namespace in the assemblies. These assemblies are referenced in the same project and I want to be able to use both classes. Ex: MyClass is under MyNamespace namespace in Assembly1.dll MyClass is under MyNamespace namespace in Assembly2.dll Assembly1.dll and Assembly2.dll are referenced in MyProject project. How can I use MyClass class from both assemblies. Best Regards

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        Do you want to use them as the same class? Then you are out of luck! Do you want to just reference them? Then redesign your classes and let them at least half decent/different names. If you really wanna use them like that, they way you explain, you will have to resort to reflection as the C# compiler cannot handle such ambiguities. top secret xacc-ide 0.0.1

        G 1 Reply Last reply
        0
        • E exhaulted

          Try the following Assembly1.MyClass class1 = new Assembly1.MyClass(); Assembly2.MyClass class2 = new Assembly2.MyClass(); If you fully qualify your references to the namespaces you should be fine. Kev Pearman MCP

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Lol those are the assembly names, not the namespaces. He mentions both reside in the same namespace, called MyNamespace. top secret xacc-ide 0.0.1

          E 1 Reply Last reply
          0
          • L leppie

            Lol those are the assembly names, not the namespaces. He mentions both reside in the same namespace, called MyNamespace. top secret xacc-ide 0.0.1

            E Offline
            E Offline
            exhaulted
            wrote on last edited by
            #5

            :-ODoh! Now i feel stupid!:-O Kev Pearman MCP

            L 1 Reply Last reply
            0
            • E exhaulted

              :-ODoh! Now i feel stupid!:-O Kev Pearman MCP

              L Offline
              L Offline
              leppie
              wrote on last edited by
              #6

              Its monday, you are forgiven! ;P PS: Stop beating me to the posts now! :laugh: top secret xacc-ide 0.0.1

              E 1 Reply Last reply
              0
              • L leppie

                Its monday, you are forgiven! ;P PS: Stop beating me to the posts now! :laugh: top secret xacc-ide 0.0.1

                E Offline
                E Offline
                exhaulted
                wrote on last edited by
                #7

                The posts are all yours now, dinner times over so i gotta get back to it :(( Kev Pearman MCP

                1 Reply Last reply
                0
                • L leppie

                  Do you want to use them as the same class? Then you are out of luck! Do you want to just reference them? Then redesign your classes and let them at least half decent/different names. If you really wanna use them like that, they way you explain, you will have to resort to reflection as the C# compiler cannot handle such ambiguities. top secret xacc-ide 0.0.1

                  G Offline
                  G Offline
                  gokselm
                  wrote on last edited by
                  #8

                  I just wanted to try if there is a way to do that. But you are right. In my case I just can't change the classes at all. It seems that I will have to write a small application to use the other version. Thanks again.

                  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