[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Win32 COM interaction with C#

Posted on 2013-06-19
10
Medium Priority
?
1,077 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:Meir Rivkin
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

834 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