How to interact with other programs with OLE Automation in C #?

I am creating a C # application that can read item data from SQL Server and push it to a scale system called "SLP-V Ishida Retail Scales". They have a “SLP-V Automation Interface" that allows user programs to interact with their systems. This is a note from the help page in SLP-V:

The automation interface (also known as the "COM interface (common object model)") provides program users with access to SLP-V functions. The most common application for this is using VB Script to automate SLP-V operations, such as importing host files. However, the automation interface can be used from any programming environment that supports automation (COM), and this is the preferred method for incorporating SLP-V functions into end-user applications.

This section provides a reference to the methods and properties of the SLP-V automation object and includes some sample programs.

Automation Object SLP-V

The SLP-V automation object name is "Ishida.Slp.Scripting.CommonApi" and the type library file is "SlpScripting.tlb".

My question is, does C # allow you to interact with other programs using OLE Automation? And if so, how do I interact with my program? I mean calling their method. Because I can not add SlpScripting.tlbas a link. It says:

Link to SLP Scripting Interface cannot be added. An ActiveX type library "SlpScripting.tlb" has been exported from the .NET assembly and cannot be added as a link. Add a reference to the .NET assembly instead

And I searched Google about it, but I did not find the answer.


Finally found a solution. I don't need to add a link in C #, and not just use:

System.Type objType = System.Type.GetTypeFromProgID("The name of progID that you want to call"); 
dynamic comObject = System.Activator.CreateInstance(objType);
  • Example ProgID = "Ishida.Slp.Scripting.CommonApi".

And then just call the function / method existing in this object, for example:

comObject.LoginToHost("localhost", 8085, username, pass);

+1
1

OLE - , COM. ,.NET COM ( .NET 1.0).

:

1

"" COM . SLP, , . , COM-DLL regsvr32 XXX.DLL. 32/64 ( 32- COM-DLL 64- Windows, C:\Windows\SysWOW64\regsvr32.exe).

COM- Visual Studio,

== > COM

" SlpScripting 1.0" .

" SLPxxxx" (Intellisense ).

COM-.

"# COM interop", .

2

Visual Studio :

tlbimp SlpScripting.tlb 

DLL, .

+2

Source: https://habr.com/ru/post/1683951/


All Articles