<?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>Art Of Creation - Dynamics AX Blog &#187; RPC</title>
	<atom:link href="http://www.artofcreation.be/tag/rpc/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.artofcreation.be</link>
	<description>The everyday life of a Dynamics AX developer</description>
	<lastBuildDate>Thu, 02 Feb 2012 12:20:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Error 1740: The endpoint is a duplicate</title>
		<link>http://www.artofcreation.be/2009/05/06/error-1740-the-endpoint-is-a-duplicate/</link>
		<comments>http://www.artofcreation.be/2009/05/06/error-1740-the-endpoint-is-a-duplicate/#comments</comments>
		<pubDate>Wed, 06 May 2009 11:42:43 +0000</pubDate>
		<dc:creator>Klaas Deforche</dc:creator>
				<category><![CDATA[Dynamics AX]]></category>
		<category><![CDATA[RPC]]></category>

		<guid isPermaLink="false">http://www.artofcreation.be/?p=78</guid>
		<description><![CDATA[Today, I came across the following error when trying to start an AOS: Error 1740: The endpoint is a duplicate This error occurs when the port that is specified in the server configuration of the AOS is in use by another process. You&#8217;ll also find an entry in the event log on the AOS: Object [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I came across the following error when trying to start an AOS:</p>
<blockquote><p>Error 1740: The endpoint is a duplicate</p></blockquote>
<p>This error occurs when the port that is specified in the server configuration of the AOS is in use by another process.<br />
You&#8217;ll also find an entry in the event log on the AOS:</p>
<blockquote><p>Object Server 03: RPC error:  The Dynamics Server could not be started because TCP Port 2752 is already in use.</p></blockquote>
<p>To figure out what process is using the port, you can use the Netstat command on the server. You&#8217;ll find something like this if an AOS is using the port:</p>
<blockquote><p>  TCP    AOSServer:2752          DBServer.domain:ms-sql-s  ESTABLISHED</p></blockquote>
<p>It is possible that an other process is using that port, so either terminate that process or restart the AOS that&#8217;s occupying the port.<br />
When you have more then one AOS on the server, the problem is figuring out what AOS is using the port.<br />
You can search all server configurations for the port, but in my case, an AOS was connected to the wrong port because of a bug of some sort, so I used a program called <a href="http://www.nirsoft.net/utils/cports.html">CurrPorts</a>.<br />
CurrPorts shows you more information than the Netstat command, and gives you the option to terminate a TCP/IP connection.<br />
I only needed to restart the AOS that was using the wrong port and the problem was solved. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.artofcreation.be/2009/05/06/error-1740-the-endpoint-is-a-duplicate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AOS crashed when importing XPO</title>
		<link>http://www.artofcreation.be/2009/04/22/aos-crashed-when-importing-xpo/</link>
		<comments>http://www.artofcreation.be/2009/04/22/aos-crashed-when-importing-xpo/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 21:26:49 +0000</pubDate>
		<dc:creator>Klaas Deforche</dc:creator>
				<category><![CDATA[Dynamics AX]]></category>
		<category><![CDATA[AOS]]></category>
		<category><![CDATA[RPC]]></category>

		<guid isPermaLink="false">http://www.artofcreation.be/?p=68</guid>
		<description><![CDATA[A colleague came up to me today with a problem. She was trying to import an xpo file, and when she ticked the check box &#8216;Show details&#8217; in order to compare the objects in the xpo file, the Dynamics AX client crashed. No message was shown, the application just quit. It was also impossible to [...]]]></description>
			<content:encoded><![CDATA[<p>A colleague came up to me today with a problem. She was trying to import an xpo file, and when she ticked the check box &#8216;Show details&#8217; in order to compare the objects in the xpo file, the Dynamics AX client crashed. No message was shown, the application just quit. It was also impossible to reconnect to the Application Object Server because the AOS had crashed as well. When you restarted the AOS, you could easily reproduce this scenario by repeating the above steps. </p>
<p>Sometimes, the following message was logged in the event log on the client, basically informing you that the AX client had crashed:</p>
<blockquote><p>Faulting application ax32.exe, version 5.0.1000.52, stamp 490c41fb, faulting module unknown, version 0.0.0.0, stamp 00000000, debug? 0, fault address 0x0bbf0b3c.</p></blockquote>
<p>In the event log on the server an other message was logged, but not every time the AOS crashed:</p>
<blockquote><p>Object Server 16: RPC error: Client provided an invalid session ID 3</p></blockquote>
<p>From what I understand, this message is logged when a client sends an RPC request to a server that has ended the session for this client, which would be the case if the AOS crashed.</p>
<p>Once again, the event log is pretty useless. The real problem lies in the application files, more specifically the Microsoft Dynamics AX Label Index files. These are the files that have the extension .ali. For some reason, one or more of these index files are corrupt, and this causes the import process to fail, and the AOS to crash. At the time, the AOS server was low on diskspace, and that could be the cause of the corrupt index files. Luckily, index files such as ali files can be deleted when the AOS is down, and will be rebuilt when the AOS is started.<br />
After all label index files were deleted, and the AOS restarted, the xpo could be imported, and the AOS didn&#8217;t crash anymore.</p>
<p>So, when the AOS crashed when you are trying to import an xpo file, stopping the AOS, deleting the ali files from the application directory and restarting the AOS might be the solution. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.artofcreation.be/2009/04/22/aos-crashed-when-importing-xpo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WinAPI, RPC 1702 and FindFirstFileW</title>
		<link>http://www.artofcreation.be/2009/04/08/winapi-rpc-1702-and-findfirstfilew/</link>
		<comments>http://www.artofcreation.be/2009/04/08/winapi-rpc-1702-and-findfirstfilew/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 21:39:50 +0000</pubDate>
		<dc:creator>Klaas Deforche</dc:creator>
				<category><![CDATA[Dynamics AX]]></category>
		<category><![CDATA[RPC]]></category>
		<category><![CDATA[System.IO]]></category>
		<category><![CDATA[WinAPI]]></category>

		<guid isPermaLink="false">http://www.artofcreation.be/?p=46</guid>
		<description><![CDATA[A very common scenario when doing interfaces with other applications, is to have a directory where one application places files, and the other one picks those up and processes them. Let&#8217;s say some application want to interface with Dynamics AX, one way, from that application to AX. That application will drop files of a specific [...]]]></description>
			<content:encoded><![CDATA[<p>A very common scenario when doing interfaces with other applications, is to have a directory where one application places files, and the other one picks those up and processes them.<br />
Let&#8217;s say some application want to interface with Dynamics AX, one way, from that application to AX. That application will drop files of a specific format, say *.txt, in a directory. You&#8217;ll want to have a batch job in AX that checks that directory every 5 minutes for those files. When your batch job finds those files, it will open them and do something with that data, then move them to an other directory, so you don&#8217;t process them twice.</p>
<p>Now the first thing you&#8217;ll probably think of (well, I did&#8230;), is to use the class <a href="http://msdn.microsoft.com/en-us/library/aa678136(AX.10).aspx">WinAPI</a>. This class has some useful static methods for checking if folders or files exist, finding files with a filename of a certain format. Just the kind of thing we&#8217;re looking for. Your code might look like this:</p>
<div class="codecolorer-container xpp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> loopfilesWinApi<span style="color: #000000;">&#40;</span>Args _args<span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">str</span> fileName;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">int</span> handle;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">str</span> format <span style="color: #00007f;">=</span> <span style="color: #ff0000;">&quot;*.txt&quot;</span>;<br />
&nbsp; &nbsp; ;<br />
<br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span><span style="color: #000000;">&#40;</span>WinApi<span style="color: #00007f;">::</span><span style="color: #000000;">folderExists</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;C:<span style="color: #000000;">\\</span>Temp<span style="color: #000000;">\\</span>&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>handle<span style="color: #00007f;">,</span>fileName<span style="color: #000000;">&#93;</span> <span style="color: #00007f;">=</span> WinApi<span style="color: #00007f;">::</span><span style="color: #000000;">findFirstFile</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;C:<span style="color: #000000;">\\</span>Temp<span style="color: #000000;">\\</span>&quot;</span> <span style="color: #00007f;">+</span> format<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">while</span><span style="color: #000000;">&#40;</span>fileName<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007f00;">//currentfileName = fileName;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; info<span style="color: #000000;">&#40;</span>filename<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filename <span style="color: #00007f;">=</span> WinApi<span style="color: #00007f;">::</span><span style="color: #000000;">findNextFile</span><span style="color: #000000;">&#40;</span>handle<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; WinApi<span style="color: #00007f;">::</span><span style="color: #000000;">closeHandle</span><span style="color: #000000;">&#40;</span>handle<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>That&#8217;s perfect. It checks a directory, in this cas C:\temp, for files with the extension txt&#8230; <strong>until</strong> you try to run this in batch. Your batch will have the status error, and there will be an entry in the event log saying:</p>
<blockquote><p>RPC error: RPC exception 1702 occurred in session xxx</p></blockquote>
<p>That error message is very misleading, but <a href="http://blogs.msdn.com/floditt/archive/2009/01/29/rpc-error-1702-when-calling-a-winapi-method-from-a-batch-job.aspx">Florian Dittgen has a nice blog entry about this</a>, that explains why this goes wrong: WinAPI methods a static and run on client. In batch, you can not use these client methods.<br />
But hey! There is a class called WinAPIServer, surely this runs on server, right? Correct, but a lot of the methods available in WinAPI are missing in WinAPIServer. You can however extend the WinAPI server class by copying methods from the WinAPI class and modifying them a bit. Let&#8217;s try that.</p>
<p>This is what the WinAPI::FindFirstFile() method looks like:</p>
<div class="codecolorer-container xpp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">client</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">container</span> findFirstFile<span style="color: #000000;">&#40;</span><span style="color: #0000ff;">str</span> filename<span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; Binary data <span style="color: #00007f;">=</span> <span style="color: #0000ff;">new</span> Binary<span style="color: #000000;">&#40;</span><span style="color: #000000;">592</span><span style="color: #000000;">&#41;</span>; <span style="color: #007f00;">// size of WIN32_FIND_DATA when sizeof(TCHAR)==2</span><br />
&nbsp; &nbsp; DLL _winApiDLL <span style="color: #00007f;">=</span> <span style="color: #0000ff;">new</span> DLL<span style="color: #000000;">&#40;</span>#KernelDLL<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; DLLFunction _findFirstFile <span style="color: #00007f;">=</span> <span style="color: #0000ff;">new</span> DLLFunction<span style="color: #000000;">&#40;</span>_winApiDLL<span style="color: #00007f;">,</span> <span style="color: #ff0000;">'FindFirstFileW'</span><span style="color: #000000;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; _findFirstFile.<span style="color: #000000;">returns</span><span style="color: #000000;">&#40;</span>ExtTypes<span style="color: #00007f;">::</span><span style="color: #000000;">DWord</span><span style="color: #000000;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; _findFirstFile.<span style="color: #000000;">arg</span><span style="color: #000000;">&#40;</span>ExtTypes<span style="color: #00007f;">::</span><span style="color: #000000;">WString</span><span style="color: #00007f;">,</span>ExtTypes<span style="color: #00007f;">::</span><span style="color: #000000;">Pointer</span><span style="color: #000000;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #000000;">&#91;</span>_findFirstFile.<span style="color: #000000;">call</span><span style="color: #000000;">&#40;</span>filename<span style="color: #00007f;">,</span> data<span style="color: #000000;">&#41;</span><span style="color: #00007f;">,</span>data.<span style="color: #000000;">wString</span><span style="color: #000000;">&#40;</span>#offset44<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>;<br />
<span style="color: #000000;">&#125;</span></div></div>
<p>As you can see, this method uses the function FindFirstFileW from the Kernel32 dll located in the folder C:\WINDOWS\system32. Let&#8217;s copy this method to WinAPIServer and modify it to look like this:</p>
<div class="codecolorer-container xpp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">server</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">container</span> findFirstFile<span style="color: #000000;">&#40;</span><span style="color: #0000ff;">str</span> filename<span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; #define.<span style="color: #000000;">KernelDLL</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">'KERNEL32'</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; #define.<span style="color: #000000;">offset44</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">44</span><span style="color: #000000;">&#41;</span><br />
<br />
&nbsp; &nbsp; InteropPermission interopPerm;<br />
&nbsp; &nbsp; Binary data;<br />
&nbsp; &nbsp; DLL _winApiDLL;<br />
&nbsp; &nbsp; DLLFunction _findFirstFile;<br />
&nbsp; &nbsp; ;<br />
<br />
&nbsp; &nbsp; interopPerm <span style="color: #00007f;">=</span> <span style="color: #0000ff;">new</span> InteropPermission<span style="color: #000000;">&#40;</span>InteropKind<span style="color: #00007f;">::</span><span style="color: #000000;">DllInterop</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; interopPerm.<span style="color: #000000;">assert</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; data <span style="color: #00007f;">=</span> <span style="color: #0000ff;">new</span> Binary<span style="color: #000000;">&#40;</span><span style="color: #000000;">592</span><span style="color: #000000;">&#41;</span>; <span style="color: #007f00;">// size of WIN32_FIND_DATA when sizeof(TCHAR)==2</span><br />
&nbsp; &nbsp; _winApiDLL <span style="color: #00007f;">=</span> <span style="color: #0000ff;">new</span> DLL<span style="color: #000000;">&#40;</span>#KernelDLL<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; _findFirstFile <span style="color: #00007f;">=</span> <span style="color: #0000ff;">new</span> DLLFunction<span style="color: #000000;">&#40;</span>_winApiDLL<span style="color: #00007f;">,</span> <span style="color: #ff0000;">'FindFirstFileW'</span><span style="color: #000000;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; _findFirstFile.<span style="color: #000000;">returns</span><span style="color: #000000;">&#40;</span>ExtTypes<span style="color: #00007f;">::</span><span style="color: #000000;">DWord</span><span style="color: #000000;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; _findFirstFile.<span style="color: #000000;">arg</span><span style="color: #000000;">&#40;</span>ExtTypes<span style="color: #00007f;">::</span><span style="color: #000000;">WString</span><span style="color: #00007f;">,</span>ExtTypes<span style="color: #00007f;">::</span><span style="color: #000000;">Pointer</span><span style="color: #000000;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #000000;">&#91;</span>_findFirstFile.<span style="color: #000000;">call</span><span style="color: #000000;">&#40;</span>filename<span style="color: #00007f;">,</span> data<span style="color: #000000;">&#41;</span><span style="color: #00007f;">,</span>data.<span style="color: #000000;">wString</span><span style="color: #000000;">&#40;</span>#offset44<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>;<br />
<span style="color: #000000;">&#125;</span></div></div>
<p>Three things have changed here:</p>
<ol>
<li>&#8220;Client&#8221; has been change to &#8220;Server&#8221; so it can run on server;</li>
<li>The code has been changed to use the InteropPermission class; this is required because the code runs on server;</li>
<li>Initialization of the variables is moved to after assertion of the InteropPermission.</li>
</ol>
<p>When you test this in batch (running on server), this will work, and you can do this for all WinAPI methods in the examples above&#8230; <strong>until</strong> you try this on a x64 architecture. You&#8217;ll receive a message saying that an error occurred when calling the FindFirstFileW function in the Kernel32 DLL (the exact message slipped my mind).<br />
The problem is described on the <a href="http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.axapta.programming&amp;tid=c5b2f7c6-0dc3-49f3-a49e-dcd836625563&amp;cat=&amp;lang=&amp;cr=&amp;sloc=&amp;p=1">Axapta Programming Newsgroup</a>. You can code your way around this problem, but I think the message is clear: <strong>don&#8217;t use WinAPI</strong>.</p>
<p>Instead, use the .NET Framework <strong>System.IO</strong> namespace (watch out for lowercase/uppercase here), in our case in specific, System.IO.File and System.IO.Directory.<br />
I get this nice code example from <a href="http://greg.agiletortoise.com/2007/04/02/dynamics-ax-making-net-calls-from-inside-ax/">Greg Pierce’s blog</a> (modified it a bit):</p>
<div class="codecolorer-container xpp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> loopfilesSystemIO<span style="color: #000000;">&#40;</span>Args _args<span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #007f00;">// loop all files that fit the required format</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">str</span> fileName;<br />
&nbsp; &nbsp; InteropPermission interopPerm;<br />
<br />
&nbsp; &nbsp; System.<span style="color: #000000;">Array</span> files;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">int</span> i<span style="color: #00007f;">,</span> j;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">container</span> fList;<br />
&nbsp; &nbsp; ;<br />
<br />
&nbsp; &nbsp; interopPerm <span style="color: #00007f;">=</span> <span style="color: #0000ff;">new</span> InteropPermission<span style="color: #000000;">&#40;</span>InteropKind<span style="color: #00007f;">::</span><span style="color: #000000;">ClrInterop</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; interopPerm.<span style="color: #000000;">assert</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; files <span style="color: #00007f;">=</span> System.<span style="color: #000000;">IO</span>.<span style="color: #000000;">Directory</span><span style="color: #00007f;">::</span><span style="color: #000000;">GetFiles</span><span style="color: #000000;">&#40;</span>@<span style="color: #ff0000;">&quot;C:<span style="color: #000000;">\t</span>emp&quot;</span><span style="color: #00007f;">,</span> <span style="color: #ff0000;">&quot;*.txt&quot;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">for</span><span style="color: #000000;">&#40;</span> i<span style="color: #00007f;">=</span><span style="color: #000000;">0</span>; i<span style="color: #00007f;">&lt;</span>ClrInterop<span style="color: #00007f;">::</span><span style="color: #000000;">getAnyTypeForObject</span><span style="color: #000000;">&#40;</span>files.<span style="color: #000000;">get_Length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>; i<span style="color: #00007f;">++</span> <span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fList <span style="color: #00007f;">=</span> <span style="color: #0000ff;">conins</span><span style="color: #000000;">&#40;</span>fList<span style="color: #00007f;">,</span> <span style="color: #0000ff;">conlen</span><span style="color: #000000;">&#40;</span>fList<span style="color: #000000;">&#41;</span><span style="color: #00007f;">+</span><span style="color: #000000;">1</span><span style="color: #00007f;">,</span> ClrInterop<span style="color: #00007f;">::</span><span style="color: #000000;">getAnyTypeForObject</span><span style="color: #000000;">&#40;</span>files.<span style="color: #000000;">GetValue</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0000ff;">for</span><span style="color: #000000;">&#40;</span>j<span style="color: #00007f;">=</span><span style="color: #000000;">1</span>;j<span style="color: #00007f;">&amp;</span>lt;<span style="color: #00007f;">=</span> <span style="color: #0000ff;">conlen</span><span style="color: #000000;">&#40;</span>fList<span style="color: #000000;">&#41;</span>; j<span style="color: #00007f;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fileName <span style="color: #00007f;">=</span> <span style="color: #0000ff;">conpeek</span><span style="color: #000000;">&#40;</span>fList<span style="color: #00007f;">,</span> j<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; info<span style="color: #000000;">&#40;</span>fileName<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>This will run on client and on server without any problems. To have clean code, you could create your own class, just like WinAPI, but using the System.IO namespace. That way, you can reuse this code and save time.</p>
<p>Conclusion: abandon WinAPI, and use System.IO instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.artofcreation.be/2009/04/08/winapi-rpc-1702-and-findfirstfilew/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
	</channel>
</rss>

