Solved

Win32 COM interaction with C#

Posted on 2013-06-19
10
970 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
How our DevOps Teams Maximize Uptime

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

 

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
 

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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