How to detect if a Type is a generated DynamicProxy without referencing Castle DynamicProxy?

31 views
Skip to first unread message

Simon

unread,
Jul 28, 2009, 8:17:14 PM7/28/09
to Castle Project Users
Sorry for the cross post.
I figure that, while this question is not specific to castle, the
castle folk may have the answer

http://stackoverflow.com/questions/1193366/

Jonathon Rossi

unread,
Jul 28, 2009, 8:21:39 PM7/28/09
to castle-pro...@googlegroups.com
Castle.Core.ProxyServices.IsDynamicProxy(type)
--
Jono

Ayende Rahien

unread,
Jul 28, 2009, 8:23:11 PM7/28/09
to castle-pro...@googlegroups.com
type.Assembly.FullName.StartsWith("DynamicProxyGenAssembly2")

Simon

unread,
Jul 28, 2009, 8:31:06 PM7/28/09
to Castle Project Users
Sorry i should have been a bit more specific.

My full question is

"I am using castle DynamicProxy and was wondering if there is a way of
detecting if a Type is a proxy without referencing Castle
DynamicProxy?
So while I am using Castle DynamicProxy as an example I would like
code that would work for any in memory generated type."
> >http://stackoverflow.com/questions/1193366/- Hide quoted text -
>
> - Show quoted text -

Ayende Rahien

unread,
Jul 28, 2009, 8:41:33 PM7/28/09
to castle-pro...@googlegroups.com
If you need that, you can check the Location property of the assembly.
But that is just a side effect.
This will look like a proxy too:

Assembly.Load(File.ReadAllBytes("Nhibernate.dll"));

Simon

unread,
Jul 28, 2009, 8:52:43 PM7/28/09
to Castle Project Users
thanks ayende this is something i had not considered and is a flaw
with my current hack.
> > > >http://stackoverflow.com/questions/1193366/-Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages