Solved

Win32 COM interaction with C#

Posted on 2013-06-19
10
953 Views
Last Modified: 2013-07-06
Hi,

I have a software called Winfiol. Basically it a telnet/SSH command line tool being used by telecom engineers to interact with cellular site and the network.

Right now I'm kinda stuck on how to make the DLL work with my C# program. I already imported the tlb file using tlbimp.exe and successfully added it as reference in VS 2010. I can even see it in the object browswer.

Here is the thing, I have no clue how to initiate this. I have not tried using win32 DLL before in C#. Also the library inside the DLL has interface which I dont know how to use.

Any help will be well appreciated. Thanks.
0
Comment
Question by:CastleBuilder8
  • 5
  • 4
10 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 39261944
we can't help without checking the dll.
either post a reference where we can download the dll or post the source code.
0
 
LVL 25

Expert Comment

by:apeter
ID: 39262273
Hope you tried below.

tlbimp would have created a wrapper class for you. Use that class to create instance and call its properties.
0
 

Author Comment

by:CastleBuilder8
ID: 39262845
Hi Sedgwick,

I attached some snapshot as they wont accept tlb or dll files as attachment.

By the way the name of the dll is WINFIOLLib.dll.


Below is the code that i got.

        
private void button1_Click(object sender, EventArgs e)
        {
            var app = new WinFIOL_ApplicationClass();
            var channel = (IWFChannel) app;
            var main = (IWFMain)app;
            var events = (IWFEvent)app;

            main.GetCurrentChannel();
        }

Open in new window


I'm have the following errors:

*** Error      1      The type 'WINFIOLLib.WinFIOL_ApplicationClass' has no constructors defined      D:\Programming - Tools\dotNET\MasterSolutionForATTGA\MasterSolutionForATTGA\Winfiol\Form1.cs      25      23      Winfiol

*** Error      2      Interop type 'WINFIOLLib.WinFIOL_ApplicationClass' cannot be embedded. Use the applicable interface instead.      D:\Programming - Tools\dotNET\MasterSolutionForATTGA\MasterSolutionForATTGA\Winfiol\Form1.cs      25      27      Winfiol

*** Retrieving the COM class factory for component with CLSID {417DAD90-DCFA-11D2-836D-0008C7826433} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
Object-Browser-IWFMain.jpg
error-snapshot.jpg
0
 

Author Comment

by:CastleBuilder8
ID: 39263011
Hi Apeter,

This the steps that i did wit tlbimp.exe
1) created dll from the tlb file.
2) the dll was added as reference on VS2010. after the dll was added as reference i can verify it in the object browswer in VS2010.

Did i miss something? I'm not really sure what a class wrapper is or how it was generated as i can only see the one dll file created.
0
 
LVL 25

Expert Comment

by:apeter
ID: 39268620
Ignore about the wrapper class. Is it that the DLL which you imported refers to other Dlls ? Use the exe  Ildasm.exe to find...
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:CastleBuilder8
ID: 39269956
Apeter,

Looks like it the dll does not refer to another dll. I check the dll via ildasm and there was no reference that i could think. I tried the exe file though but ildasm cannot read it and shows an error "has no valid CLR header and cannot be disassembled". I think ildasm can't disassemble native dll's.

I attached the tree dump of the WINFIOLLib.dll tree view.

Regards,
Adrian
Tree-View.txt
0
 
LVL 25

Expert Comment

by:apeter
ID: 39280523
Try registering the Com DLL with "regsvr32" and try again.
0
 

Accepted Solution

by:
CastleBuilder8 earned 0 total points
ID: 39284635
I finally got it it working by registering the type library "wfoleaut.tlb:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\regtlibv12.exe" "C:\Program Files\Ericsson\Element Management\WinFIOL\wfoleaut.tlb"
0
 
LVL 25

Expert Comment

by:apeter
ID: 39293110
Glad you found the way.
0
 

Author Closing Comment

by:CastleBuilder8
ID: 39303676
This made my code working.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now