Solved

Win32 COM interaction with C#

Posted on 2013-06-19
10
940 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

13 Experts available now in Live!

Get 1:1 Help Now