TypeResolve & GetType()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ayende@gmail.com

    TypeResolve & GetType()

    I've a piece of code which does Type.GetType("f ull.type, name") on a
    type that is located in an assembly that is currently not loaded.
    I don't have control over the code that call this and I don't have any
    control on the string that get passed.
    I wanted to use TypeResolve to handle this, but it doesn't get call for
    static assemblies.

    Any ideas how I can handle this?

  • Vadym Stetsyak

    #2
    Re: TypeResolve & GetType()

    This event is not called if the runtime knows that requested type cannot be
    retieved from an assembly. Does the type you're requesting exists in the
    assembly?
    --
    Vadym Stetsyak aka Vadmyst
    <ayende@gmail.c om> wrote in message
    news:1123611346 .691491.265580@ g14g2000cwa.goo glegroups.com.. .[color=blue]
    > I've a piece of code which does Type.GetType("f ull.type, name") on a
    > type that is located in an assembly that is currently not loaded.
    > I don't have control over the code that call this and I don't have any
    > control on the string that get passed.
    > I wanted to use TypeResolve to handle this, but it doesn't get call for
    > static assemblies.
    >
    > Any ideas how I can handle this?
    >[/color]


    Comment

    • ayende@gmail.com

      #3
      Re: TypeResolve &amp; GetType()

      It exists, but the assembly is not loaded, that is the problem.

      Comment

      • Vadym Stetsyak

        #4
        Re: TypeResolve &amp; GetType()

        If the type exists in the assembly then it seems to me that assembly is not
        loaded.

        Can you try to load that assembly manually and call Assembly.GetTyp e(...)?

        Also you can subscribe to AppDomain.Assem blyResolve to get notified if
        something bad is happening with assembly load.

        --
        Vadym Stetsyak aka Vadmyst

        <ayende@gmail.c om> wrote in message
        news:1123679478 .733744.45090@g 47g2000cwa.goog legroups.com...[color=blue]
        > It exists, but the assembly is not loaded, that is the problem.
        >[/color]


        Comment

        • Red Forks

          #5
          Re: TypeResolve &amp; GetType()

          ayende@gmail.co m wrote:
          [color=blue]
          > I've a piece of code which does Type.GetType("f ull.type, name") on a
          > type that is located in an assembly that is currently not loaded.
          > I don't have control over the code that call this and I don't have any
          > control on the string that get passed.
          > I wanted to use TypeResolve to handle this, but it doesn't get call for
          > static assemblies.
          >
          > Any ideas how I can handle this?[/color]
          use AssemblyName class to parse the ClassName, & load the assembly if
          needed.

          Comment

          • Red Forks

            #6
            Re: TypeResolve &amp; GetType()

            ayende@gmail.co m wrote:
            [color=blue]
            > I've a piece of code which does Type.GetType("f ull.type, name") on a
            > type that is located in an assembly that is currently not loaded.
            > I don't have control over the code that call this and I don't have any
            > control on the string that get passed.
            > I wanted to use TypeResolve to handle this, but it doesn't get call for
            > static assemblies.
            >
            > Any ideas how I can handle this?[/color]
            use AssemblyName class to parse the ClassName, & load the assembly if
            needed.

            Comment

            • ayende@gmail.com

              #7
              Re: TypeResolve &amp; GetType()

              I'm already subscribing to AssemblyResolve , but it's not getting
              called, and I don't know why.

              Comment

              Working...