Get calling assembly name inside WCF service

I'm trying to achieve the following: whenever a call to service is performed I want to be able to identify the client. I thought about getting the calling assembly name by iterating over stack trace but I failed to get the client assembly name. Sample code:

private List<System.Reflection.Assembly> GetCallingAssemblies()

            List<System.Reflection.Assembly> assemblies = new List<System.Reflection.Assembly>();

            StackTrace stackTrace = new StackTrace(0, true);

            for (int i = 0; i < stackTrace.FrameCount; i++)

                StackFrame stackFrame = stackTrace.GetFrame(i);

                System.Reflection.MethodBase methodBase = stackFrame.GetMethod();

                Type type = methodBase.ReflectedType;
                System.Reflection.Assembly assembly;
                if (type != null)
                    assembly = System.Reflection.Assembly.GetAssembly(type);
                    if (assemblies.Contains(assembly) == false)
            return assemblies;


I must be missing something: you're trying to identify the client through assemblies? Why not use authentication?

Besides, who says the client even has assemblies? It may be a Java client, or some other platform.

When your client calls a WCF service, all that goes between the two is the serialized message - the method to call and all the parameters to pass in.

There is no other connection at runtime between server and client. The server cannot "reach back" and look at the client - there is no connection.

All your service can look at is the serialized message, and any message headers. So if you really really need this (what do you need it for??) then you need to make sure the client puts a marker / identification of some sort as a message header into the call.

Need Your Help

How to make N runnables run for random periods of time, multiple times?

java concurrency time random

Let's say you have N runnable objects, and for each you want them to execute for random periods of time. Once a runnable object executes for that time period, you want to reschedule it to run for a...

OpenGL textures fails on Motorola Milestone

android opengl-es textures milestone

I have troubles with OpenGL textures on Motorola Milestone with 2.1 firmware. Each call to glGenTextures fails with error GL_INVALID_OPERATION and sets the id with random numbers. The exact same