<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments for DotNetReflections</title>
	<atom:link href="http://blogs.tallan.com/dotnetreflections/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.tallan.com/dotnetreflections</link>
	<description>Tallan's .NET Blog Site</description>
	<pubDate>Wed, 17 Mar 2010 00:50:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on Recover from a WCF Service Fault, Part 2 (Generic ServiceClientFactory Class) by mgerety</title>
		<link>http://blogs.tallan.com/dotnetreflections/2009/05/06/recover-from-a-wcf-service-fault-part-2-generic-serviceclientfactory-class/comment-page-1/#comment-160</link>
		<dc:creator>mgerety</dc:creator>
		<pubDate>Wed, 16 Sep 2009 14:58:44 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.tallan.com/dotnetreflections/2009/05/recover-from-a-wcf-service-fault-part-2-generic-serviceclientfactory-class/#comment-160</guid>
		<description>@Robert:
I'm glad the code was able to help you out.  

I hadn't thought about your issue as the services I was using this for are pretty simple, however your solution seems to work nicely.  I may add something like this into the next iteration.

Thanks for submitting your additions to it!</description>
		<content:encoded><![CDATA[<p>@Robert:<br />
I&#8217;m glad the code was able to help you out.  </p>
<p>I hadn&#8217;t thought about your issue as the services I was using this for are pretty simple, however your solution seems to work nicely.  I may add something like this into the next iteration.</p>
<p>Thanks for submitting your additions to it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Recover from a WCF Service Fault, Part 2 (Generic ServiceClientFactory Class) by Robert Sullivan</title>
		<link>http://blogs.tallan.com/dotnetreflections/2009/05/06/recover-from-a-wcf-service-fault-part-2-generic-serviceclientfactory-class/comment-page-1/#comment-159</link>
		<dc:creator>Robert Sullivan</dc:creator>
		<pubDate>Tue, 15 Sep 2009 22:49:41 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.tallan.com/dotnetreflections/2009/05/recover-from-a-wcf-service-fault-part-2-generic-serviceclientfactory-class/#comment-159</guid>
		<description>Thanks for the above code, it is well written and easy to understand, and was exactly what I was looking for!

I do have one thought if I may...

I have a service client with multiple endpoints defined in web/app.config. Using the GetClient() method will cause an exception to be thrown because WCF can't decide for me which endpoint to use. I edited the above method and added a new one as follows:


	}

	/// 
	/// Retrieves a service client for the interface specified in generic parameter.
	/// 
	/// Interface type to use for Service Client creation.
	/// Service client instance for specified interface.
	public T GetClient()
	{
	    // Passing null causes reflection to use the default constructor of the Service Client (This works if only one endpoint is defined for the service)
	    return GetClient(null);
	}

	/// 
	/// Retrieves a service client for the interface specified in generic parameter.
	/// 
	/// Interface type to use for Service Client creation.
	/// Object array of arguments to pass to the Service Client's constuctor
	/// Service client instance for specified interface.
	/// The ' values must match the order and type of a constructor for the Service Client.
	public T GetClient(params object[] constructorArgs)
	{
	    var genericType = typeof(T);
	    Type serviceClientType;
	    if (genericType.IsInterface)
	    {
		serviceClientType = GetClientType(genericType);

		if (serviceClientType == null)
		    return default(T);

		// Pass the supplied constructor arguments to the CreateInstance method
		var client = Activator.CreateInstance(serviceClientType, constructorArgs);
		if (!(client is ICommunicationObject))
		{
		    client = null;
		    return (T)client;

		}
		(client as ICommunicationObject).Faulted += Channel_Faulted;

		if (!factories.ContainsKey(typeof(T)))
		{
		    var prop = serviceClientType.GetProperty("ChannelFactory");
		    var factory = prop.GetValue(client, null);
		    factories.Add(typeof(T), factory);
		}
		return (T)client;
	    }
	    return default(T);
	}

For my personal situation, I only need to pass the endpointConfigurationName as a constructor parameter, but I think this implementation will allow for any of the service client's constructors to be called.

I've tested it in a limited fashion, but wanted to see if you had any comments/concerns.

Once again thanks for pointing me in the right direction.</description>
		<content:encoded><![CDATA[<p>Thanks for the above code, it is well written and easy to understand, and was exactly what I was looking for!</p>
<p>I do have one thought if I may&#8230;</p>
<p>I have a service client with multiple endpoints defined in web/app.config. Using the GetClient() method will cause an exception to be thrown because WCF can&#8217;t decide for me which endpoint to use. I edited the above method and added a new one as follows:</p>
<p>	}</p>
<p>	///<br />
	/// Retrieves a service client for the interface specified in generic parameter.<br />
	///<br />
	/// Interface type to use for Service Client creation.<br />
	/// Service client instance for specified interface.<br />
	public T GetClient()<br />
	{<br />
	    // Passing null causes reflection to use the default constructor of the Service Client (This works if only one endpoint is defined for the service)<br />
	    return GetClient(null);<br />
	}</p>
<p>	///<br />
	/// Retrieves a service client for the interface specified in generic parameter.<br />
	///<br />
	/// Interface type to use for Service Client creation.<br />
	/// Object array of arguments to pass to the Service Client&#8217;s constuctor<br />
	/// Service client instance for specified interface.<br />
	/// The &#8216; values must match the order and type of a constructor for the Service Client.<br />
	public T GetClient(params object[] constructorArgs)<br />
	{<br />
	    var genericType = typeof(T);<br />
	    Type serviceClientType;<br />
	    if (genericType.IsInterface)<br />
	    {<br />
		serviceClientType = GetClientType(genericType);</p>
<p>		if (serviceClientType == null)<br />
		    return default(T);</p>
<p>		// Pass the supplied constructor arguments to the CreateInstance method<br />
		var client = Activator.CreateInstance(serviceClientType, constructorArgs);<br />
		if (!(client is ICommunicationObject))<br />
		{<br />
		    client = null;<br />
		    return (T)client;</p>
<p>		}<br />
		(client as ICommunicationObject).Faulted += Channel_Faulted;</p>
<p>		if (!factories.ContainsKey(typeof(T)))<br />
		{<br />
		    var prop = serviceClientType.GetProperty(&#8221;ChannelFactory&#8221;);<br />
		    var factory = prop.GetValue(client, null);<br />
		    factories.Add(typeof(T), factory);<br />
		}<br />
		return (T)client;<br />
	    }<br />
	    return default(T);<br />
	}</p>
<p>For my personal situation, I only need to pass the endpointConfigurationName as a constructor parameter, but I think this implementation will allow for any of the service client&#8217;s constructors to be called.</p>
<p>I&#8217;ve tested it in a limited fashion, but wanted to see if you had any comments/concerns.</p>
<p>Once again thanks for pointing me in the right direction.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Could not load file or assembly &#8216;AjaxControlToolkit&#8217; or one of its dependencies. Access is denied. by JessicaD</title>
		<link>http://blogs.tallan.com/dotnetreflections/2009/09/01/could-not-load-file-or-assembly-ajaxcontroltoolkit-or-one-of-its-dependencies-access-is-denied/comment-page-1/#comment-156</link>
		<dc:creator>JessicaD</dc:creator>
		<pubDate>Wed, 02 Sep 2009 14:03:29 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.tallan.com/dotnetreflections/?p=185#comment-156</guid>
		<description>Kadasani,

Microsoft does have an official Windows 7 RC Support Forum located here http://tinyurl.com/9fhdl5 . It is supported by product specialists as well as engineers and support teams. You may want to check the threads available there for additional assistance and feedback.

Jessica
Microsoft Windows Client Team</description>
		<content:encoded><![CDATA[<p>Kadasani,</p>
<p>Microsoft does have an official Windows 7 RC Support Forum located here <a href="http://tinyurl.com/9fhdl5" onclick="javascript:pageTracker._trackPageview('/outbound/comment/tinyurl.com');" rel="nofollow">http://tinyurl.com/9fhdl5</a> . It is supported by product specialists as well as engineers and support teams. You may want to check the threads available there for additional assistance and feedback.</p>
<p>Jessica<br />
Microsoft Windows Client Team</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Recover from a WCF Service Fault by u7</title>
		<link>http://blogs.tallan.com/dotnetreflections/2009/05/06/recover-from-a-wcf-service-fault/comment-page-1/#comment-155</link>
		<dc:creator>u7</dc:creator>
		<pubDate>Wed, 05 Aug 2009 08:09:32 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.tallan.com/dotnetreflections/2009/05/recover-from-a-wcf-service-fault/#comment-155</guid>
		<description>sender = AuthChannelFactory.CreateChannel();

Why setting this parameter? it is not passed by ref !</description>
		<content:encoded><![CDATA[<p>sender = AuthChannelFactory.CreateChannel();</p>
<p>Why setting this parameter? it is not passed by ref !</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The Cost of Reflection by mcf</title>
		<link>http://blogs.tallan.com/dotnetreflections/2008/08/18/the-cost-of-reflection/comment-page-1/#comment-5</link>
		<dc:creator>mcf</dc:creator>
		<pubDate>Wed, 20 Aug 2008 15:32:15 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.tallan.com/dotnetreflections/?p=30#comment-5</guid>
		<description>Good article.  Reflection really is an interesting topic because it's not a simple question of being slow or fast - it tends to force you to think about the whole situation, and start thinking about strategic points in the app where you can leverage the levels of usage and refresh requirements.

Being that performance, maintenance, and repetitive code are the key factors here, I've found that a discussion of code generation enters the room quite gracefully.  Past projects I've worked on that have leveraged code generation (and regeneration) always seem to have arrived there by either trying to eliminate the writing of repetitive, code like property accessors or maps, or by looking at code generation as a sort of caching mechanism that does its work pre-compile-time as opposed to doing it at runtime.

Code Generation can add that third dimension to your matrices above, allowing you to provide the performance of the static loading method, while being able to do so (with some required foresight) in a maintainable manner.</description>
		<content:encoded><![CDATA[<p>Good article.  Reflection really is an interesting topic because it&#8217;s not a simple question of being slow or fast - it tends to force you to think about the whole situation, and start thinking about strategic points in the app where you can leverage the levels of usage and refresh requirements.</p>
<p>Being that performance, maintenance, and repetitive code are the key factors here, I&#8217;ve found that a discussion of code generation enters the room quite gracefully.  Past projects I&#8217;ve worked on that have leveraged code generation (and regeneration) always seem to have arrived there by either trying to eliminate the writing of repetitive, code like property accessors or maps, or by looking at code generation as a sort of caching mechanism that does its work pre-compile-time as opposed to doing it at runtime.</p>
<p>Code Generation can add that third dimension to your matrices above, allowing you to provide the performance of the static loading method, while being able to do so (with some required foresight) in a maintainable manner.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The Cost of Reflection by derek.strickland</title>
		<link>http://blogs.tallan.com/dotnetreflections/2008/08/18/the-cost-of-reflection/comment-page-1/#comment-4</link>
		<dc:creator>derek.strickland</dc:creator>
		<pubDate>Tue, 19 Aug 2008 12:38:53 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.tallan.com/dotnetreflections/?p=30#comment-4</guid>
		<description>Thanks for the comment.  Very good point on the property caching.  I do that with the SQL statements that are used to query the DB so as to limit the amount of string manipulation that gets done, it should be a simple enough to apply the same principle to the PropertyInfo's.  

I too agree that there must be a merit to using it.  Microsoft makes heavy use of Reflection techniques in many of their approaches to problem solving in 3.5,. so it looks like a strategy we should learn more about.  

Thanks for reading and commenting!</description>
		<content:encoded><![CDATA[<p>Thanks for the comment.  Very good point on the property caching.  I do that with the SQL statements that are used to query the DB so as to limit the amount of string manipulation that gets done, it should be a simple enough to apply the same principle to the PropertyInfo&#8217;s.  </p>
<p>I too agree that there must be a merit to using it.  Microsoft makes heavy use of Reflection techniques in many of their approaches to problem solving in 3.5,. so it looks like a strategy we should learn more about.  </p>
<p>Thanks for reading and commenting!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The Cost of Reflection by seungykim</title>
		<link>http://blogs.tallan.com/dotnetreflections/2008/08/18/the-cost-of-reflection/comment-page-1/#comment-3</link>
		<dc:creator>seungykim</dc:creator>
		<pubDate>Mon, 18 Aug 2008 20:55:54 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.tallan.com/dotnetreflections/?p=30#comment-3</guid>
		<description>I like this topic, since the whole Reflection issue has come up ever since any metadata based language such as Java and C# have been developed.

Many frameworks such as Spring, Hibernate and many other ORM for database mapping use reflection, so there must be a merit to using reflection in proper manner.

Especially when using reflection to assign a value to a variable, most of people use class inspection and iterator to iterate through the properties and assign values accordingly.

The funny part is that most of the process power and time wasted happens during the property/method iteration.

This can easily resolved by caching the properties/methods information in a shared cache.  If the cache is empty or stale, then iterate over the list of properties and store the information to cache.

Once the cache has the information, we can just easily do a simple value assignment without going through the class type inspectino via reflection again.

just my 2c. :)

-SK</description>
		<content:encoded><![CDATA[<p>I like this topic, since the whole Reflection issue has come up ever since any metadata based language such as Java and C# have been developed.</p>
<p>Many frameworks such as Spring, Hibernate and many other ORM for database mapping use reflection, so there must be a merit to using reflection in proper manner.</p>
<p>Especially when using reflection to assign a value to a variable, most of people use class inspection and iterator to iterate through the properties and assign values accordingly.</p>
<p>The funny part is that most of the process power and time wasted happens during the property/method iteration.</p>
<p>This can easily resolved by caching the properties/methods information in a shared cache.  If the cache is empty or stale, then iterate over the list of properties and store the information to cache.</p>
<p>Once the cache has the information, we can just easily do a simple value assignment without going through the class type inspectino via reflection again.</p>
<p>just my 2c. <img src='http://blogs.tallan.com/dotnetreflections/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>-SK</p>
]]></content:encoded>
	</item>
</channel>
</rss>
