COM Interop - Cannot instantiate objects

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bobby C. Jones

    #1

    COM Interop - Cannot instantiate objects

    I'm trying to use some classes defined in a COM component that I did not
    create. I have successfully created the RCW via Tlbimp.exe and referenced
    it in my project. All is well until I run the project and it chokes with an
    "Invalid access to memory location." error when I try to instantiate an
    object like so:

    AecXSchedule30. AecAnchorTagToE ntClass anchor = new
    AecXSchedule30. AecAnchorTagToE ntClass();

    I'm not sure where the best place for me to start looking for the answer
    lies. I'm currently pouring over more COM Interop doc material than I ever
    even wanted to know existed. Am I missing something so basic? Anybody have
    a clue as to where I should start looking? Thanks.
    --
    Bobby C. Jones



  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: COM Interop - Cannot instantiate objects

    Bobby,

    The two things I can think of off the top of my head are a) is the
    object properly registered on the machine you are running this on and b)
    have you set the threading model of the current thread correctly?

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    "Bobby C. Jones" <bobbyj@acadx.c om> wrote in message
    news:Oo9glevdDH A.1944@TK2MSFTN GP12.phx.gbl...[color=blue]
    > I'm trying to use some classes defined in a COM component that I did not
    > create. I have successfully created the RCW via Tlbimp.exe and referenced
    > it in my project. All is well until I run the project and it chokes with[/color]
    an[color=blue]
    > "Invalid access to memory location." error when I try to instantiate an
    > object like so:
    >
    > AecXSchedule30. AecAnchorTagToE ntClass anchor = new
    > AecXSchedule30. AecAnchorTagToE ntClass();
    >
    > I'm not sure where the best place for me to start looking for the answer
    > lies. I'm currently pouring over more COM Interop doc material than I[/color]
    ever[color=blue]
    > even wanted to know existed. Am I missing something so basic? Anybody[/color]
    have[color=blue]
    > a clue as to where I should start looking? Thanks.
    > --
    > Bobby C. Jones
    > www.AcadX.com
    >
    >[/color]


    Comment

    • Bobby C. Jones

      #3
      Re: COM Interop - Cannot instantiate objects

      Nicholas,
      A) I have some VB6 code that consumes it with no problem, so I know that
      it's registered properly.

      B) I haven't set up any threads if that's what you mean.

      I'm still looking over COM Interop docs and finding nada.

      Thanks again!
      --
      Bobby C. Jones


      "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> wrote
      in message news:%23aDSSsvd DHA.3948@TK2MSF TNGP11.phx.gbl. ..[color=blue]
      > Bobby,
      >
      > The two things I can think of off the top of my head are a) is the
      > object properly registered on the machine you are running this on and b)
      > have you set the threading model of the current thread correctly?
      >
      > Hope this helps.
      >
      >
      > --
      > - Nicholas Paldino [.NET/C# MVP]
      > - nicholas.paldin o@exisconsultin g.com[/color]


      Comment

      • Guogang

        #4
        Re: COM Interop - Cannot instantiate objects

        Are you using Visual Studio? If yes, you can try to right click on your
        project in solution explore, and select "Add Reference". Select "COM" in the
        shown dialog. Pick your COM object, you will be able to use it like any
        class.

        This is most fool proof way to use COM object in C#. Nerver have any problem
        to me.


        "Bobby C. Jones" <bobbyj@acadx.c om> wrote in message
        news:Oo9glevdDH A.1944@TK2MSFTN GP12.phx.gbl...[color=blue]
        > I'm trying to use some classes defined in a COM component that I did not
        > create. I have successfully created the RCW via Tlbimp.exe and referenced
        > it in my project. All is well until I run the project and it chokes with[/color]
        an[color=blue]
        > "Invalid access to memory location." error when I try to instantiate an
        > object like so:
        >
        > AecXSchedule30. AecAnchorTagToE ntClass anchor = new
        > AecXSchedule30. AecAnchorTagToE ntClass();
        >
        > I'm not sure where the best place for me to start looking for the answer
        > lies. I'm currently pouring over more COM Interop doc material than I[/color]
        ever[color=blue]
        > even wanted to know existed. Am I missing something so basic? Anybody[/color]
        have[color=blue]
        > a clue as to where I should start looking? Thanks.
        > --
        > Bobby C. Jones
        > www.AcadX.com
        >
        >[/color]


        Comment

        • Bobby C. Jones

          #5
          Re: COM Interop - Cannot instantiate objects

          I found the problem and it had absolutely nothing at all to do with the RCW.
          It was my own mistake elsewhere, imagine that. Thanks for all your help.
          --
          Bobby C. Jones



          Comment

          Working...