same type in 2 different assemblies - issues?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • n_o_s_p_a__m

    #1

    same type in 2 different assemblies - issues?

    Ok, I have source code shared between 2 projects using links in VSS,
    so we are compiling the same type information (classes, interfaces,
    enums) into more than one assembly. This was done only by special
    request of our client.

    I am wondering if this is ok to do:

    In AssemblyA: class1's methods returns myclass objects defined in
    myclass.cs comiled into AssemblyX and referenced by project A.

    (AssemblyA-->references-->AssemblyX-->contains-->myclass ; class1
    methods-->returns-->myclass)

    In AssemblyB: class2 declares objects of type myclass as return values
    from calls to class1, except that in this case, class library B
    references a different assembly (AssemblyY) which also has myclass.cs
    compiled into it.

    (AssemblyB-->references-->AssemblyY (and AssemblyA)-->AssemblyY also
    contains-->myclass ; class2 calls class1-->returns-->myclass)


    This seems to be causing some security issues.

    Anyone know why and if this should/should not work?

    -KJ
  • Mickey Williams

    #2
    Re: same type in 2 different assemblies - issues?

    "n_o_s_p_a_ _m" <n_o_s_p_a__m@m ail.com> wrote in message
    news:1faa8782.0 311140705.2ec8c a17@posting.goo gle.com...[color=blue]
    > Ok, I have source code shared between 2 projects using links in VSS,
    > so we are compiling the same type information (classes, interfaces,
    > enums) into more than one assembly. This was done only by special
    > request of our client.[/color]

    And if your client asked you to jump off a bridge, would you do that too?
    Sorry, I started channeling my Mom for some reason ;)

    From the runtime's point of view, the true name of a type includes the name
    of the assembly that contains it. If you're using C#, and create two classes
    that have the same source-level name identity (including the namespaces),
    you're going to have issues. The runtime believes that type F.O.G in
    assembly A is not the same type as F.O.G in assembly B. Unfortunately, (or
    fortunately depending on your POV) there's no way to express that difference
    in C#. The custom of my people is to factor the common types into a common
    assembly.

    --
    Mickey Williams
    Author, "Microsoft Visual C# .NET Core Reference", MS Press



    Comment

    • Eric Newton

      #3
      Re: same type in 2 different assemblies - issues?

      quote: "The custom of my people..."

      LOL

      It takes a village to raise a programmer ;-)

      --
      Eric Newton
      C#/ASP Application Developer
      eric@cc.ensoft-software.com [remove the first "CC."]

      "Mickey Williams" <my first name at servergeek.com> wrote in message
      news:%23VQF12sq DHA.3180@TK2MSF TNGP11.phx.gbl. ..[color=blue]
      > "n_o_s_p_a_ _m" <n_o_s_p_a__m@m ail.com> wrote in message
      > news:1faa8782.0 311140705.2ec8c a17@posting.goo gle.com...[color=green]
      > > Ok, I have source code shared between 2 projects using links in VSS,
      > > so we are compiling the same type information (classes, interfaces,
      > > enums) into more than one assembly. This was done only by special
      > > request of our client.[/color]
      >
      > And if your client asked you to jump off a bridge, would you do that too?
      > Sorry, I started channeling my Mom for some reason ;)
      >
      > From the runtime's point of view, the true name of a type includes the[/color]
      name[color=blue]
      > of the assembly that contains it. If you're using C#, and create two[/color]
      classes[color=blue]
      > that have the same source-level name identity (including the namespaces),
      > you're going to have issues. The runtime believes that type F.O.G in
      > assembly A is not the same type as F.O.G in assembly B. Unfortunately, (or
      > fortunately depending on your POV) there's no way to express that[/color]
      difference[color=blue]
      > in C#. The custom of my people is to factor the common types into a common
      > assembly.
      >
      > --
      > Mickey Williams
      > Author, "Microsoft Visual C# .NET Core Reference", MS Press
      > www.servergeek.com
      >
      >[/color]


      Comment

      Working...