Find COM server for an application - com-interop

I have some applications which call the same COM server (over the same interop dll). If I have to terminate one of these applications because it hangs or something else the belonging COM server continues.
Is there a way to decide which COM Server belongs to a specific application? I've searched for a way using process id or handle but didn't find a solution.
Thanks for any help.

Related

Why must Windows Services be Installed?

As far as I understand, the main entry point for a service application calls StartServiceCtrlDispatcher with an array of entries containing (among other things) the entry points for services to be run.
Nothing about that setup specifically requires any kind of installation: So why must a windows service be installed anyway?
I'm assuming it's an access management/security thing, but I can't find anything on the net.
Services are not connected to a specific user and a major selling point of a service is the ability to run when there are no users logged in. If there is no user around to start a service, how would Windows know what to start if there was no central list it could consult?
The list of services is stored in the registry and this is where the service manager gets the list of installed services and their configuration.
Most 3rd-party services only contain one service per .exe and the array passed to StartServiceCtrlDispatcher only contains one service. The famous svchost.exe can have more than one service in a single process and in this design each service is implemented in a .dll that is loaded by svchost.exe.
The svchost.exe design is used by Microsoft to reduce the total number of processes on a system. There will still be multiple svchost processes on a system, one for each configuration type (network access vs local only etc.).
Other configuration details the service manger needs to know about each service includes what action it should take if a service dies and if it should be delay-started etc. These settings are not hardcoded in the service itself so that administrators can change the configuration.

Receiving the list of contacts from Outlook

Microsoft.Office.Interop.Outlook.Application outlookObj;
outlookObj = new Microsoft.Office.Interop.Outlook.Application();
At start of the program gives out a mistake
{ "It wasn't succeeded to receive factory of the class COM for a component with CLSID {0006F03A-0000-0000-C000-000000000046} because of the following mistake: 80080005 Mistake at implementation of the appendix server (An exception of HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))." }
In what the mistake consists?
CO_E_SERVER_EXEC_FAILURE usually means that your code and Outlook are running in different security contexts. Is either app running with elevated privileges (run as administrator)? Is your app running as a service?
In case if you run the code on the server-side or from any non-interactive client:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
You can read more about that in the Considerations for server-side Automation of Office article.

how to reference dll in GAC in a remote machine in 3 tier structure

I have a 3 tier structure in my office and my dll (in GAC) in business tier is already installed in my business component server .
Method 1: Remote GAC
I'm trying to build a light-weight application and the application will reference the dll in the remote business tier server, but I don't know how.
Method 2: old way DCOM or COM+
But I do find an old way by using DCOM (no more GAC).
http://www.kepware.com/Support_Center/SupportDocuments/DCOM_Secure_by_default.pdf
It seems relatively achievable, but after i follow the steps, I always get some security alert, such as no access.
Method 3: Web Service, too slow!
I do not want to use web service because I need fast access within LAN. web service is just too slow as it has to go through IIS.
Method 4: .NET remoting using TCP
This method seems to be faster than web service, but it seems to have a lot of overhead.
I don't mind use old technology as long as it works.
GAC make my dll more secure as it cannot be copied and used by other unauthorized people, so it is preferred.
Please advise.
I research quite some articles and it seems in order to have most of the benefit included(version control, security, convenience, pooling etc.), then
the best way is to GAC the dll in remote machine and then use Regsvcs to register the dll as COM+ service.
some people don't want so much trouble as convenience is their top priority (fast deploy, security, version control are not that essential) then they suggest I can just XCopy the dll to remote server and then just Regsvcs it.

Execute windows program from SQL

Do you know how can I execute a Windows application from SQL server? I have written a Windows application (actually it is a EXE file), when it runs by double clicks, it can call to Skype (I am working on Skype API). But when I try to execute it from inside SQL, it will never call to Skype.
I have used xp_cmdshell SP from SQL. I also tried to use this solution from CodeProject. But both of them did not work for me: http://www.codeproject.com/KB/database/xyprocedure.aspx
Any help is appriciated!
Thanks and regards,
Leo
When you execute an external application through xp_cmdshell it will be run by the SQL Server Service account, on the Services desktop. Skype is probably running under your account on the interactive desktop. It's no way you can succeed with that approach. Services are not meant to directly interact with a client program that way.
Instead you have to create small program that runs on your desktop under your credentials. That program would regularly check some kind of work queue in the database. Each work item should contain the information that the small program needs to be able to interact with Skype.

Is it possible to deploy an out-proc COM server on Windows Azure and alter its activation permission?

I need to consume an out-proc COM server from both a worker role and a web role in a Windows Azure application. One step I'm almost sure I'll need to do is to alter the access permissions for the COM server - grant "local launch" and "local activation" permissions for the predefined user under which roles code executes.
So far I found there's DCOMPERM utility in Windows SDK samples which contains code that I guess would do that. So I could write similar code and package it into either a separate executable or into the COM registration code of the COM server and run that code from a role start-up task. That's not trivial, but certainly doable.
I only have one major concern before I start.
Are there any reasons why I can't do that? Maybe using out-proc COM servers is not allowed on Windows Azure or something? Are there any such limitations?
Are there any reasons why I can't do that? Maybe using out-proc COM servers is not allowed on Windows Azure or something? Are there any such limitations?
It's not something I've personally done, but if you can install a COM+ server running in a shell exe, then I think you should be able to do what you want - see this recent blog post http://michaelwasham.com/2011/05/15/deploying-a-com-servicedcomponent-to-windows-azure/
I don't think you will hit limitations - but I think you will hit a fair few problems along the way - good luck.

Resources