Hello,
Thanks for your post. As I understand, you want to detect whether a .NET
class is instantiated from managed or unmanaged client. Please correct me
if there is any misunderstanding. I'd like to share the following
information with you:
As you know, a managed class is always created on .NET side. That is,
unmanaged client cannot access your managed component directly, it should
call through CCW (COM callable wrappers) instead. Please refer to the
following MSDN article for detailed information on CCW:
Calling a .NET Component from a COM Component
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/callnetfrcom.asp
One method comes up to my mind so far is that: In the constructor of your
managed class, throw and catch an exception so that you can get the call
stack, look up the call stack that will help you determine where the call
is originated from. I am afraid that there is no easy way.
Please feel free to let me know if you have any problems or concerns.
Have a nice day!
Regards,
HuangTM
Microsoft Online Partner Support
MCSE/MCSD
Get Secure! --
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.