Solved

Win32 COM interaction with C#

Posted on 2013-06-19
10
1,001 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

707 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