Results 1 to 4 of 4

Thread: Unable to use Interop. Probably being stupid

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2006
    Posts
    746

    Unable to use Interop. Probably being stupid

    I am trying to use a 3rd-party Interop assembly called SmartWIM.

    I have added it as a reference and added an Import statement

    Imports SmartWIMLib

    I then initilalise it with

    Dim objSmartWim As New SmartWIM

    All pretty standard stuff, I've done this countless times with Interops. However, whenever I try and use any methods I get the following error

    Unhandled Exception: System.TypeInitializationException: The type initializer for 'VSSImage.Module1' threw an exception. ---> System.Runtime.Inte
    ropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {2AA14EBC-F945-44F3-80CA-EE916BE02111} failed due to the following error: 80040154.
    at VSSImage.Module1..cctor() in D:\data\willimw\Visual Studio 2010\Projects\VSSImage\VSSImage\Module1.vb:line 7
    --- End of inner exception stack trace ---
    at VSSImage.Module1.Main()
    Last edited by Ginolard; Jul 13th, 2011 at 10:37 AM.
    ManagePC - the all-in-one PC management and inventory tool

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2006
    Posts
    746

    Re: Unable to use Interop. Probably being stupid

    Ah. Now I think I know why. The associated DLL has to be registered on the target machine too. Damn, that's annoying. Now I need to find out how to have my application register a certain DLL whilst the app is running and then unregister it at the end.
    ManagePC - the all-in-one PC management and inventory tool

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Unable to use Interop. Probably being stupid

    Yes, the Interop DLL is simply a bridge that allows your app to INTEROPerate with a COM component. That can't happen if there's no COM component to interoperate with.

    You use Regsvr32.exe to register and unregister COM components. You can run it using Process.Start, just like any other program. I've never tried doing it on the fly though.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2006
    Posts
    746

    Re: Unable to use Interop. Probably being stupid

    Yes, I think that's what I'll have to do. It seems a little clunky but I guess I don't have much choice.
    ManagePC - the all-in-one PC management and inventory tool

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width