Answer the question
In order to leave comments, you need to log in
Using COM Objects in Windows Service C#?
Using OleWoo, I get the uuid of the COM object and the DispID of its properties and methods from a tlb file. Created a wrapper (dll-library).
public class Broker : IDisposable
{
#region Переменные класса
/// <summary>
/// Тип приложения
/// </summary>
private Type _sapBrokerType;
/// <summary>
/// Объект приложения
/// </summary>
private object _sapBrokerObj;
/// <summary>
/// Освобождены ли используеммые ресурсы
/// </summary>
private bool _disposed = false;
public Broker()
{
_sapBrokerType = Type.GetTypeFromCLSID(new Guid("{b9df38f7-5340-4512-bae6-4ef7465a3c17}"));
_sapBrokerObj = _sapBrokerType.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null);
}
var broker = new Broker();
Answer the question
In order to leave comments, you need to log in
Most likely, the user under which the service is running does not have rights to create an object.
If it is DCOM, then the rights can be set in the "Component Services" applet, "Administration" section of the Toolbar.
It may happen that the com object being created requires a GUI. For example, it uses a message queue, displays dialogs. In this case, a service that is not running as a system user with the "Allow desktop interaction" checkbox checked will most likely not work as a normal application does.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question