<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ColdFused? &#187; .NET</title>
	<atom:link href="http://www.rupeshk.org/blog/index.php/category/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rupeshk.org/blog</link>
	<description>My Views on ColdFusion, Java and related technologies</description>
	<lastBuildDate>Fri, 19 Nov 2010 14:22:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Issues with .NET integration in ColdFusion 9.0.1</title>
		<link>http://www.rupeshk.org/blog/index.php/2010/11/issues-with-net-integration-in-coldfusion-9-0-1/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2010/11/issues-with-net-integration-in-coldfusion-9-0-1/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 14:20:29 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[coldfusion]]></category>

		<guid isPermaLink="false">http://www.rupeshk.org/blog/?p=288</guid>
		<description><![CDATA[If you are using ColdFusion .NET integration and you are planning to upgrade or have already upgraded to ColdFusion 9.0.1, read on. Lately we  have seen lot of people facing issues with .NET integration after upgrading to ColdFusion 9.0.1. You will usually see the error &#8220;Dot Net side does not seem to be running&#8221;. [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using ColdFusion .NET integration and you are planning to upgrade or have already upgraded to ColdFusion 9.0.1, read on. Lately we  have seen lot of people facing issues with .NET integration after upgrading to ColdFusion 9.0.1. You will usually see the error &#8220;Dot Net side does not seem to be running&#8221;. There might also be an InvalidLicenseException in the logs.</p>
<p>To fix this, you need to uninstall .NET integration services and re-install it using &#8220;ColdFusion 9.0.1 .NET Integration Service Installer&#8221; provided at http://www.adobe.com/support/coldfusion/downloads.html.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2010/11/issues-with-net-integration-in-coldfusion-9-0-1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How to use .NET Generic classes from ColdFusion</title>
		<link>http://www.rupeshk.org/blog/index.php/2009/08/how-to-use-net-generic-classes-from-coldfusion/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2009/08/how-to-use-net-generic-classes-from-coldfusion/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 11:44:21 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[coldfusion]]></category>

		<guid isPermaLink="false">http://www.rupeshk.org/blog/index.php/2009/08/how-to-use-net-generic-classes-from-coldfusion/</guid>
		<description><![CDATA[I noticed an interesting thing about .NET Generic classes while fixing a bug (Thanks Shigeru Nakagaki for logging it). He was not able to use .NET class &#8216;System.Collections.Generic.List&#8217; . Here is the code he was trying.

&#60;cfset list = CreateObject&#40;&#34;.net&#34;,&#34;System.Collections.Generic.List&#34;&#41;&#62;

The proxy generator itself was throwing an error saying that this class was not found which was [...]]]></description>
			<content:encoded><![CDATA[<p>I noticed an interesting thing about .NET Generic classes while fixing a bug (Thanks Shigeru Nakagaki for logging it). He was not able to use .NET class &#8216;System.Collections.Generic.List&#8217; . Here is the code he was trying.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #0000FF;">list</span> <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">CreateObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;.net&quot;</span>,<span style="color: #009900;">&quot;System.Collections.Generic.List&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>The proxy generator itself was throwing an error saying that this class was not found which was quite mysterious because this class is part of core .NET library. With little debugging I found the reasons which is quite fascinating. </p>
<p>A Generic class will have some types associated. For example, System.Collections.Generic.List&lt;T&gt; has one associated type &#8216;T&#8217; where T will be any type like String, int or whatever. For Generic classes, the class name that .NET actually stores is different than the specified one. It actually stores the class name as &lt;className&gt;`&lt;No of Types&gt;. Notice the backquotes &#8216;`&#8217;? So for &#8216;System.Collections.Generic.List&#8217;, the actual .NET class name is &#8220;System.Collections.Generic.List`1&#8243;. Similarly for &#8216;System.Collections.Generic.Dictionary&lt;T, T&gt;&#8217; the actual class name is &#8216;System.Collections.Generic.Dictionary`2&#8242; . This is quite different from Java Generics where the type information is not written to bytecode and hence the class name never changes.</p>
<p>After figuring this out, I changed the code name like this (reluctantly as this is not a valid class name)</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #0000FF;">list</span> <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">CreateObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;.net&quot;</span>,<span style="color: #009900;">&quot;System.Collections.Generic.List&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>and this time, the error was something different. The proxy got generated fine but it still complained that it could not find the class which I had expected because backquotes &#8216;`&#8217; is not allowed in a java class name. (In case you are not aware, for using .NET classes in ColdFusion, we generate a java proxy for a .NET class and the invocation happens through that proxy &#8211; See my <a href="http://www.rupeshk.org/preso/Max06/WD305W-1_CFDotNet_Kumar.pdf">MAX 06 presentation</a> ). The immediate question them comes is &#8211; what was the name of the proxy class that got generated? And the proxy class was generated with name &#8220;System.Collections.Generic.List__1&#8243;. Notice that backquote &#8216;`&#8217; was replaced with two underscores &#8216;__&#8217;.</p>
<p>So we wanted to use &#8216;System.Collections.Generic.List&#8217;, but its actual .NET class name was &#8220;System.Collections.Generic.List`1&#8243; and its java proxy name was &#8220;System.Collections.Generic.List__1&#8243;. Interesting. Isn&#8217;t it?</p>
<p>Now the question is &#8211; how do you use it? If you give the class name as &#8216;System.Collections.Generic.List`1&#8242;, the class loading will fail and if you give the class name as &#8216;System.Collections.Generic.List__1&#8242; the proxy generation will not happen. The workaround for the time being is </p>
<ul>
<li>Generate the proxy for required classes separately using proxy generator (jnbproxyGui.exe)
<li>Use the proxy jar in assembly list of createObject
<li>Use the generated java class name with &#8216;`&#8217; replaced by &#8216;__&#8217;.</li>
</ul>
<p>Here is a sample code that uses .NET List&lt;String&gt;.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> eventList <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">CreateObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;.net&quot;</span>,<span style="color: #009900;">&quot;System.Collections.Generic.List__1&quot;</span>, <span style="color: #009900;">&quot;dotnetProxy.jar&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> dotnetstring <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">createObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;.net&quot;</span>, <span style="color: #009900;">&quot;System.String&quot;</span>, <span style="color: #009900;">&quot;dotnetProxy.jar&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!--- create a List of type String ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> stringType <span style="color: #0000FF;">=</span> dotnetstring.getDotNetClass<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> eventList.init<span style="color: #0000FF;">&#40;</span>stringType<span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- Add Events to List ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> eventList.add<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;MAX&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> eventList.add<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;CFUNITED&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span><span style="color: #0000FF;">#eventList.Get_Count<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>#</span><span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>For CF9, you will not need this workaround as we will do the .net class name to java class name translation automatically.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2009/08/how-to-use-net-generic-classes-from-coldfusion/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

