Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: 12 May 2006 07:39:18 -0700,    group: microsoft.public.dotnet.distributed_apps        back       


Getting Calling Process name and information when using COM+   
I have a DLL written in C#  that does logging for many of our
processes.  The calling process just passes messages and the DLL will
write the messages to a database with a unique log id for each instance
of a program that uses it so all messages passed by that program can be
identified by that single log id.  As well, the logging DLL gets the ip
address, calling processname, and pid of the program calling it.  The
calling program does not have to gather that info.  The logging DLL
obtains it.  I notice though that when the logging DLL is called by a
process running under COM+ the process name written to the database is
DLLHOST.  I understand why that is but I want to know how to get the
name of the real calling process, not DLLHOST.  So for instance if
Executablea.exe calls LinkLibrarya.dll which is installed in COM+ and
LinkLibrarya.Dll uses the logging dll, I want to know how the logging
dll can obtain the calling processes Executablea.exe and/or
linklibrarya.dll.  I do not want the calling processes to have to
obtain the information and pass it in the call to the logging DLL.

Here is code in the logging dll I use to get the calling process names:


using System;
using System.Diagnostics;
using System.Reflection;
using System.Net;

namespace testprocessname
{
	public class ProcNames
	{
		public ProcNames()
		{
			m_strCallingProcess =
Assembly.GetCallingAssembly().GetName().Name.ToString();
		}

		public string GetInfo()
		{
			return m_strProgramName + "^" + GetExeAssembly() + "^" +
GetCallAssembly() + "^" + GetEnterAssembly();
		}

		public static string GetStaticInfo()
		{
			return Process.GetCurrentProcess().ProcessName.ToString() + "^" +
GetStaticExeAssembly() + "^" + GetStaticCallAssembly() + "^" +
GetStaticEnterAssembly();
		}

		private string m_strProgramName =
Process.GetCurrentProcess().ProcessName.ToString();
		private string m_strCallingProcess = "";



		private string GetEnterAssembly()
		{
			try
			{
				return Assembly.GetEntryAssembly().GetName().Name.ToString();
			}
			catch
			{
				return Process.GetCurrentProcess().ProcessName.ToString() +
"~error~";
			}
		}

		private  string GetExeAssembly()
		{
			try
			{
				return Assembly.GetExecutingAssembly().GetName().Name.ToString();
			}
			catch
			{
				return Process.GetCurrentProcess().ProcessName.ToString() +
"~error~";
			}
		}

		private  string GetCallAssembly()
		{
			try
			{
				return Assembly.GetCallingAssembly().GetName().Name.ToString();
			}
			catch
			{
				return Process.GetCurrentProcess().ProcessName.ToString() +
"~error~";
			}
		}

		private static string GetStaticEnterAssembly()
		{
			try
			{
				return Assembly.GetEntryAssembly().GetName().Name.ToString();
			}
			catch
			{
				return Process.GetCurrentProcess().ProcessName.ToString() +
"~error~";
			}
		}

		private static string GetStaticExeAssembly()
		{
			try
			{
				return Assembly.GetExecutingAssembly().GetName().Name.ToString();
			}
			catch
			{
				return Process.GetCurrentProcess().ProcessName.ToString() +
"~error~";
			}
		}

		private static string GetStaticCallAssembly()
		{
			try
			{
				return Assembly.GetCallingAssembly().GetName().Name.ToString();
			}
			catch
			{
				return Process.GetCurrentProcess().ProcessName.ToString() +
"~error~";
			}
		}
	}
}
date: 12 May 2006 07:39:18 -0700   author:   unknown

Re: Getting Calling Process name and information when using COM+   
There are 2 types of COM+ applications. Library which is inprocess, and
Server which is a stand alone process called dllhost.exe that is the
container (surrogate) for your COM+ objects or application.

Now, whatever you are doing above, you are querying process information
as if you are a library application whereas you are a server type COM+
application. So, the information you will be getting is about the
dllhost.exe rather than the client process itself.

No, so far I did not answer your question as I don't know the answer.
There is no standard way that you can get such information about the
calling process. Not that I know of.

Thanks,
Ashraf ElSwify
Software Architect.
date: 16 May 2006 23:53:15 -0700   author:   unknown

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us