<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 - Discussions by pompomJuice</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 - Discussions by pompomJuice</title>
		<link>http://channel9.msdn.com/Niners/pompomJuice/Discussions</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Niners/pompomJuice/Discussions</link>
	<language>en</language>
	<pubDate>Thu, 23 May 2013 22:31:30 GMT</pubDate>
	<lastBuildDate>Thu, 23 May 2013 22:31:30 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>0</c9:totalResults>
	<c9:pageCount>0</c9:pageCount>
	<c9:pageSize>0</c9:pageSize>
	<item>
		<title>Tech Off - Windows 7 strange locked files hidden to explorer...?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Sven Groot said:</div><div class="quoteText">What is the location you're trying to write to? If it's Program Files or something similar, it's possible you're getting hit by file virtualization which means your files are in %localappdata%\VirtualStore.</div></blockquote>Interesting comment.
<br /><br />I was using SuperC converter to convert VOBs to AVI which I then concatinated with VirtualDub. SuperC dumps its file in &quot;Program Files(x86)&quot; which I then concatenated to the same location... lemmy test that...<br /><br />Ok it does not help. If I save the files in c:\ I still can only access it with virtual dub. (Since virtual dub created it it must be linked to the files somehow )<br /><br />I have a workaround. Basically open the &quot;Open File Dialog&quot; and right click the file and compress it. Then only the compression program (7zip in my case) can &quot;see&quot; the files, but when you uncompress it it saves in a way that explorer can get to the file.
<br /><br />What is this?<br /><br /><a href="http://i42.photobucket.com/albums/e303/pompomJuice/MIA.jpg">http://i42.photobucket.com/albums/e303/pompomJuice/MIA.jpg</a><br /><br /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/468186-Windows-7-strange-locked-files-hidden-to-explorer/5ed34d4dc37f423482bc9deb0005e782#5ed34d4dc37f423482bc9deb0005e782</link>
		<pubDate>Wed, 06 May 2009 20:55:24 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/468186-Windows-7-strange-locked-files-hidden-to-explorer/5ed34d4dc37f423482bc9deb0005e782#5ed34d4dc37f423482bc9deb0005e782</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Windows 7 strange locked files hidden to explorer...?</title>
		<description><![CDATA[<p><br />Hi there.<br /><br />I am using virtual dub to concatenate AVI segments. After virtual dub was done I noticed that I could not access any Folders or files created through Virtual Dub.
<br /><br />For example, if I do Virtual Dub -&gt; File -&gt; Open -&gt; Right click -&gt; Create Folder<br /><br />That&nbsp; folder is not visible from anywhere but inside Virtual Dub. Inside virtual dub the folder also has this little lock at the bottom. Files created by virtual dub also have this lock and are also missing when trying to get to them via explorer...<br /><br />Any ideas?<br /><br /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/468186-Windows-7-strange-locked-files-hidden-to-explorer/468186#468186</link>
		<pubDate>Wed, 06 May 2009 12:18:18 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/468186-Windows-7-strange-locked-files-hidden-to-explorer/468186#468186</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Why does tlbimp.exe work but direct reference from VS2008 not work on some COM components?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">pdev said:</div><div class="quoteText">It sounds like you might have a type library problem.&nbsp; To add the com component they'll have to have the corrisponding tbl and register it with regtlib.exe or regtlibv12.exe.<br /><br />Hope that helps<br /></div></blockquote>That was genius.
<div><br /></div>
<div>It worked!!!!</div>
<div><br /></div>
<div>I was googling all day and found nothing. Thanks a lot I would never have figure this out, partly to the fact that it seems like a random fix.&nbsp;</div>
<div><br /></div>
<div>I googled that exe but I dont find much info on it. Where can I find more info on why there was an error and why this worked?</div>
<div><br /></div>
<div>Thanks again.</div>
<div><br /></div>
<div><br /></div></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/464153-Why-does-tlbimpexe-work-but-direct-reference-from-VS2008-not-work-on-some-COM-components/43c5492a08a74d29ac269deb00051316#43c5492a08a74d29ac269deb00051316</link>
		<pubDate>Tue, 07 Apr 2009 18:03:10 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/464153-Why-does-tlbimpexe-work-but-direct-reference-from-VS2008-not-work-on-some-COM-components/43c5492a08a74d29ac269deb00051316#43c5492a08a74d29ac269deb00051316</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>4</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Why does tlbimp.exe work but direct reference from VS2008 not work on some COM components?</title>
		<description><![CDATA[<p>I have this dll that I presume is a COM component. ( anyone that can give me any pointers as to how I would determine if a .dll is indeed a valid COM component? )
<div><br /></div>
<div>The reason I ask is there seems to be something going on that I am not fully aware of. I have a project that directly references some COM objects. It works fine on my box, but other developers ( using SVN to get the source ) get an error &quot;not a valid asssembly
 or COM component&quot; error when they try to add the respective COM component to the project.&nbsp;</div>
<div><br /></div>
<div>Interestingly I got two COM components from the SDK. One works on my machine fine, but the other fails to load with the same error that the other developers get when trying to load any one of the two. tlbimp.exe does make an assembly though.&nbsp;</div>
<div><br /></div>
<div>What is going on?</div>
<div><br /></div>
<div>Regards</div></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/464153-Why-does-tlbimpexe-work-but-direct-reference-from-VS2008-not-work-on-some-COM-components/464153#464153</link>
		<pubDate>Tue, 07 Apr 2009 11:26:33 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/464153-Why-does-tlbimpexe-work-but-direct-reference-from-VS2008-not-work-on-some-COM-components/464153#464153</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>4</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - WPF + WindowsFormsHost + .Net Forms + ( COM interfaces + Forms Invoke ) = E_NOINTERFACE Exception </title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Dexter said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">pompomJuice said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
A correction:<br /><br />Control.Invoke does not spawn a new thread. Control.Invoke does some &quot;magic&quot; that causes the &quot;invoked&quot; code to execute on the thread that created the control (tipically the main thread).<br /><br />And a note:<br /><br />I'm not sure what was your solution after all. Creating a new thread every time you need to call into the COM component? That's scary!
<img src="http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif" alt="Smiley"></div></blockquote>Aah thanks for informing me about the invoke mechanics. Thinking about it now, I realize I reduced it in my mind to &quot;it spawnes another thread that can touch
 the UI&quot;, since when I encountered invokes I did not fully grasp that it was using delegates. Now I do. Still learning here <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-5.gif' alt='Wink' />
<div><br /></div>
<div>That was my solution yes. Reason being that there are thousands of lines of code. I cannot go change the structure of the program now so I need to handle this problem on a case by case basis. And that is, creating a new MTA thread and then returning the
 resulting work somehow. It worked, no exceptions, but clearly I broke something. And it was scary to do it that way. I don't like hacking.</div>
<div><br /></div>
<div>Thanks for the help.</div>
<div><br /></div>
<div><br /></div></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/ba41677003aa466d90d59deb0004f11b#ba41677003aa466d90d59deb0004f11b</link>
		<pubDate>Mon, 06 Apr 2009 08:43:41 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/ba41677003aa466d90d59deb0004f11b#ba41677003aa466d90d59deb0004f11b</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - WPF + WindowsFormsHost + .Net Forms + ( COM interfaces + Forms Invoke ) = E_NOINTERFACE Exception </title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">dotnetisv said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">pompomJuice said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
Hi guys,&nbsp;<br /><strong><br />DISCLAIMER:</strong> for the record&nbsp;please accept my appology for rudely interupting to ask a pretty basic question&nbsp;the answer to which (of course)&nbsp;
<em>may</em> reveal&nbsp;my ignorance. <br /><br />If you are porting to WPF, as Dexter mentioned, mostly this kind of thing is handled by the CLR, why have you not optioned to just use&nbsp;<a href="http://msdn.microsoft.com/en-us/library/kew41ycz(VS.71).aspx" target="_blank">COM Interop</a> and WRAP your unmanaged
 code in a managed class? I may be wrong, however I think this&nbsp;might give you the added isolation you require.<br /><br />Interested in your replies.<br /><br />-James<br /><a href="http://www.dotnetisv.com">www.dotnetisv.com</a></div></blockquote>Actually, we are already doing this.
<br /><br />As I loosly mentioned before, there are two ways to &quot;use&quot; legacy COM interfaces in .Net. This article describes them best, with PRO's and CON's.&nbsp;<a href="http://msdn.microsoft.com/en-us/library/ms973800.aspx"><br /><br />http://msdn.microsoft.com/en-us/library/ms973800.aspx</a><br /><br />I edited my post above yours, explaining the solution to my original problem.<br /><br />Regards,<br /><br /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/dc8147990a9b4666a1209deb0004f09c#dc8147990a9b4666a1209deb0004f09c</link>
		<pubDate>Sat, 04 Apr 2009 19:39:38 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/dc8147990a9b4666a1209deb0004f09c#dc8147990a9b4666a1209deb0004f09c</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - WPF + WindowsFormsHost + .Net Forms + ( COM interfaces + Forms Invoke ) = E_NOINTERFACE Exception </title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">pompomJuice said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">Dexter said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>Thanks for that information. <br /><br />I have mailed the original authors of those COM objects for those questions.<br /><br />Also thanks for pointing out my miss interpretation of Dr. Dobbs. I also wondered about that, since he never mentions .Net in the article itself, only the heading. I think the heading might be wrong.<br /><br />All other research I did also pointed out that everything should just work. Oh well, kind of fixed that problem by removing them out of the invokes.<br /><br />Now the other error:&nbsp;I have checked it out for about 5 minutes. It looks less involved. There error seems to happen all on its own in one method call. Here it is:<br /><br /></p>
<pre class="brush: text"> 
public void SetClientRect(Rectangle rcClient) // exception
{
   if (m_objClientEnvelope == null)
      m_objClientEnvelope = new SMEnvelopeClass(); // The COM object
  m_objClientEnvelope.XMin = rcClient.Left;// &lt;---- EXCEPTION happens here on m_objClientEnvelope
  m_objClientEnvelope.XMax = rcClient.Right;
  m_objClientEnvelope.YMin = rcClient.Top;
  m_objClientEnvelope.YMax = rcClient.Bottom;
  ((IDisplayTransformation)m_objTransformation).ClientRect = m_objClientEnvelope; // exception
}

//The interface generated by that Assembly generator
[Guid( &quot;C3D7F3E5-28D7-407F-BBED-CF8F2222BE35&quot; )]
[TypeLibType( 2 )]
[ClassInterface( 0 )]
public class SMEnvelopeClass : SMEnvelope, IEnvelope
{
   public SMEnvelopeClass();
  [DispId( 4 )]
  public virtual double XMax { get; set; }
  [DispId( 3 )]
  public virtual double XMin { get; set; }
  [DispId( 2 )]
  public virtual double YMax { get; set; }
  [DispId( 1 )]
  public virtual double YMin { get; set; }
}
</pre>
<br /><br />Ok so again I think its a threading problem because that method instantiates&nbsp;m_objClientEnvelope the first time it is called. I injected a thread id call there and it is clear that if the creating thread accesses that member it works, if the thread ID changes
 it fails with that error. I think its a different kind of error for the same problem, those threads are not part of the same apartment and the marshalling between the apartments ( or thread and apartment? )&nbsp;is not working? I am guessing here, my COM knowledge
 is a day old. Baby steps.<br /><br />I think with the previous error I got lucky. A worker thread instantiated the COM object and used it inside that worker thread. Because I eliminated the other thread created by invoke I sidestepped that problem.<br /><br />The new error occurs because two worker threads ( that are essential to the program ) are trying to access the same COM object. This time trickery might not work. Sigh.... I am out of ideas here.<br /><br />With regards to your comment &quot;<i>So your component is either not registered correctly or it doesn't have a proxy at all.</i>&quot; Basically what I did was
<b>regsvr32 smmobile.dll</b> and&nbsp;<b>tlbimp smmobile.dll /out:NETSMMobile.dll</b>&nbsp;and referenced that NETSMMobile.dll in my devStudio. I read about that proxy/stub file and I have no idea if that information was &quot;imbedded&quot; within the COM object itself. But I
 don’t have that proxy dll file that they speak of.<br /><br />Thanks for the help.<br /><br />Regards,
<p></p>
<p>&nbsp;</p>
</div></blockquote>Update:<br /><br />Ok I have fixed the errors. It seems that I needed to pay closer attention when fiddeling with STAThread and MTAThread attributes.
<br /><br />The errors go away&nbsp;setting the creation/access threads to&nbsp;MTA, but ensuring all threads&nbsp;accessing the COM objects are&nbsp;MTA is tedious, as any events (OnMouseclick for instance)&nbsp;triggered from STA (Forms UI) required me to make worker threads that are MTA to
 do the work using COM interfaces. These MTA worker threads make calls to Form UI again so again more wrappers for invoke were required.<br /><br />So the original problem described at the top was caused by the fact that Control.Invoke spawned a STAThread, which&nbsp; caused that E_NOINTERFACE error. Therefor the mistake was made by me, or the programmer not making sure that all COM access originated from MTAThread.
 The original implementation onto Windows CE Masked this problem as windows CE does not seem to have a problem with this.
<br /><br />The port is compete, no exceptions, but the hackinng required to make it work must have broken something. Normal controls work fine but the map drawing failes for some reason. At least I understand the COM now.<br /><br />Thanks</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/880407a51e254b8fa5459deb0004f045#880407a51e254b8fa5459deb0004f045</link>
		<pubDate>Fri, 03 Apr 2009 23:31:27 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/880407a51e254b8fa5459deb0004f045#880407a51e254b8fa5459deb0004f045</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - WPF + WindowsFormsHost + .Net Forms + ( COM interfaces + Forms Invoke ) = E_NOINTERFACE Exception </title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Dexter said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">pompomJuice said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
I should have been more explicit about proxy/marshaling. Marshaling is something you don't need to be concerned about in .NET&nbsp; because the runtime will do that automatically. What the Dr. Dobb's article says only applies to the unmanaged world.<br /><br />Of course, that brings the question why this doesn't&nbsp;work if it's done automatically. That's because this marshaling requires that the component (or more exactly the interface) has a registered proxy. So your component is either not registered correctly or
 it doesn't have a proxy at all. <br /><br />As for the RCW error: I've never seen that before. Could you post a stack trace or at least the exact line that causes that?<br /><br />PS: you still need to figure out if your COM object is apartment threaded or free threaded
<img src="http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif" alt="Smiley"><br /></div></blockquote>
<p>Thanks for that information. <br /><br />I have mailed the original authors of those COM objects for those questions.<br /><br />Also thanks for pointing out my miss interpretation of Dr. Dobbs. I also wondered about that, since he never mentions .Net in the article itself, only the heading. I think the heading might be wrong.<br /><br />All other research I did also pointed out that everything should just work. Oh well, kind of fixed that problem by removing them out of the invokes.<br /><br />Now the other error:&nbsp;I have checked it out for about 5 minutes. It looks less involved. There error seems to happen all on its own in one method call. Here it is:<br /><br /><pre class="brush: text"> 
public void SetClientRect(Rectangle rcClient) // exception
{
   if (m_objClientEnvelope == null)
      m_objClientEnvelope = new SMEnvelopeClass(); // The COM object
  m_objClientEnvelope.XMin = rcClient.Left;// &lt;---- EXCEPTION happens here on m_objClientEnvelope
  m_objClientEnvelope.XMax = rcClient.Right;
  m_objClientEnvelope.YMin = rcClient.Top;
  m_objClientEnvelope.YMax = rcClient.Bottom;
  ((IDisplayTransformation)m_objTransformation).ClientRect = m_objClientEnvelope; // exception
}

//The interface generated by that Assembly generator
[Guid( &quot;C3D7F3E5-28D7-407F-BBED-CF8F2222BE35&quot; )]
[TypeLibType( 2 )]
[ClassInterface( 0 )]
public class SMEnvelopeClass : SMEnvelope, IEnvelope
{
   public SMEnvelopeClass();
  [DispId( 4 )]
  public virtual double XMax { get; set; }
  [DispId( 3 )]
  public virtual double XMin { get; set; }
  [DispId( 2 )]
  public virtual double YMax { get; set; }
  [DispId( 1 )]
  public virtual double YMin { get; set; }
}
</pre><br /><br />Ok so again I think its a threading problem because that method instantiates&nbsp;m_objClientEnvelope the first time it is called. I injected a thread id call there and it is clear that if the creating thread accesses that member it works, if the thread ID changes
 it fails with that error. I think its a different kind of error for the same problem, those threads are not part of the same apartment and the marshalling between the apartments ( or thread and apartment? )&nbsp;is not working? I am guessing here, my COM knowledge
 is a day old. Baby steps.<br /><br />I think with the previous error I got lucky. A worker thread instantiated the COM object and used it inside that worker thread. Because I eliminated the other thread created by invoke I sidestepped that problem.<br /><br />The new error occurs because two worker threads ( that are essential to the program ) are trying to access the same COM object. This time trickery might not work. Sigh.... I am out of ideas here.<br /><br />With regards to your comment &quot;<i>So your component is either not registered correctly or it doesn't have a proxy at all.</i>&quot; Basically what I did was
<b>regsvr32 smmobile.dll</b> and&nbsp;<b>tlbimp smmobile.dll /out:NETSMMobile.dll</b>&nbsp;and referenced that NETSMMobile.dll in my devStudio. I read about that proxy/stub file and I have no idea if that information was &quot;imbedded&quot; within the COM object itself. But I
 don’t have that proxy dll file that they speak of.<br /><br />Thanks for the help.<br /><br />Regards,</p>
<p>&nbsp;</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/f00893378a90498d9c959deb0004f011#f00893378a90498d9c959deb0004f011</link>
		<pubDate>Fri, 03 Apr 2009 21:30:07 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/f00893378a90498d9c959deb0004f011#f00893378a90498d9c959deb0004f011</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - WPF + WindowsFormsHost + .Net Forms + ( COM interfaces + Forms Invoke ) = E_NOINTERFACE Exception </title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">figuerres said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">pompomJuice said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
there are more than a few differences between CE and desktop windows OS stuff so I would really look to see if that code can be found or if a native win32 version of the dll can be found.<br /><br />you might (depends on the rest of the code in it) find other problems if it was written for CE and never tested on a desktop before.<br /><br />Hope it goes well and that I am just adding a caution note.<br /><br />WIth .Net CF 1.xx we always say &quot;Net CF is just a thin wapper around SystemNotImplimentedExeption&quot;&nbsp; NetCF 3.5 is WAY better than 1.x<br /><img src="http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif" alt="Smiley"></div></blockquote>
<p>I hear ya.<br /><br />See my boss don't care about that. Microsoft says it can be done, I get payed big bucks, so I must get it done. There is no please explain to boss man that things are always more complicated than a sticker on a box that says WPF hosts Forms apllications.<br /><br />Interestingly the app contains very little WindowsCE spesific parts. It seems that it was mostly developed as a WinForms app in .Net 2.0, deployed to a CF. Worked kinda well.
</p>
<p>To reiterate, I have the Winforms project that compiles and deployes to windows CE device. I have tested this on my phone and it worked. The code ported fairly easy to my WPF app, compiling whise. Runtime though I get HUGE issues. I thought .NET&nbsp;C# code&nbsp;was
 just intended so that if it compiles it will run on different platforms. But I know it is never that easy.<br /><br />LOL @ SystemNotImplimentedExeption. Luckaly for me the app was developed for CE thus porting it up to Full framework is much easier than the other way around which would basically be a&nbsp;SystemNotImplimentedExeption wrapper.
<br /><br />W<br /><br /></p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/14c58804269d454cbfcc9deb0004efae#14c58804269d454cbfcc9deb0004efae</link>
		<pubDate>Fri, 03 Apr 2009 14:03:09 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/14c58804269d454cbfcc9deb0004efae#14c58804269d454cbfcc9deb0004efae</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - WPF + WindowsFormsHost + .Net Forms + ( COM interfaces + Forms Invoke ) = E_NOINTERFACE Exception </title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Dexter said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">pompomJuice said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
On Windows CE it probably works because the &quot;CE&quot; COM does not implement synchronization, all COM objects are free threaded (the client code has the reponsability to synchronize access to a COM object).<br /><br />Now I'm not sure why that object doesn't have a proxy registered. One possibility is that it is actually a free threaded COM object and it doesn't have a proxy because that's not needed (I assume it's only used as an inproc server). However, if the object is
 created on the main UI thread it will be subject to apartment threading rules.<br /><br />You'll have to figure out what threading model the COM object supports (see its registration key in HKCR\CLSID\{guid}\InProcServer32). If it's indeed free threaded you could try to create the object on a different thread than the main UI thread.</div></blockquote>
<p>Thanks Dexter.<br /><br />Firstly, on a by note,&nbsp;anyone that uses Chrome with channel9, DONT it &quot;aw snaps&quot; when you copy and paste to it. I think I have lost about 5 posts like this, 3 of them the main post. I almost threw my laptop out of the window. I am back on exploder for now <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-5.gif' alt='Wink' />
 How many times do I have to realize that you only use Microsoft with Microsoft? Anything else is folly. ( I come from Linux, forced to convert to Microsoft recently because of all the hype Microsoft creates around their stuff. MS is&nbsp;bullying Linux IMO and
 must stop it because my boss is&nbsp;&nbsp;influenced by snazzy Microsoft posters, not actually working operating systems; In the end I sit with the mess)<br /><br />Ok so I hear you on the CE. Makes sense. I have done more reading on Marshalling and COM and came across this interesting article which you dont need to read, but maybe for someone else that knows as little as me.&nbsp;<br /><br /><a href="http://www.ddj.com/windows/184416838">http://www.ddj.com/windows/184416838</a><br /><br />I like that article. This makes me feel better because I was debugging till early morning hours as he states discovering multithreading issues. I felt like a chop.<br /><br />Ok so Dobbs showed me that Marshalling is just crazy and I opted to go with your initial advice to inspect those &quot;else&quot; code blocks more carefully. You said maybe I can take out those COM calls. Indeed!!! You were right. I removed the invokes completely and
 just tediously invoked every little UI change inside of that &quot;else&quot; code block. SUCCESS!!! Thanks.<br /><br />Ok but now further down the line I just hit another Exception. Sigh,&nbsp;<i>COM object that has been separated from its underlying RCW cannot be used.</i><i><br /></i><br />I have not yet investigated it, first I go to the gym to pump out some frustrations then I come back for round two. So far all I have figured out is that RCW stands for Runtime Callable Wrapper. Quick random spamming of STAThread and MTAThread has show me that
 this error actually responds to those modes. the MTAThread give that same interface cast exception above, but STAThread now gives the RCW disappearing error.
<br /><br />Any quick tips will be greatly appreciated. So far you have helped a lot.<br /><br />Thanks<br /><br />Werner<br /><br /></p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/45c555d3739d404495f89deb0004ef81#45c555d3739d404495f89deb0004ef81</link>
		<pubDate>Fri, 03 Apr 2009 13:48:51 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/45c555d3739d404495f89deb0004ef81#45c555d3739d404495f89deb0004ef81</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - WPF + WindowsFormsHost + .Net Forms + ( COM interfaces + Forms Invoke ) = E_NOINTERFACE Exception </title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Dexter said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">pompomJuice said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
So if I understand correctly this code from the Invoke method:<br /><br />double d = MapObject.Instance.MapView.RotationAngle; //This line throws the exception but only if the method was called inside the Invoke below.&nbsp;&nbsp;Look for&nbsp;MapView's explenation below.<br />&nbsp;&nbsp; if (m_bDisposed)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br /><br />involves the COM object somehow but it is executed on a different thread than the main thread (where I assume the COM object was created)?<br /><br />Then that's a possible cause of your problems. Accesing STA COM objects from a different thread involves marshaling/proxying. If that cannot be done for the requested interface the error manifests as if there was no interface at all.<br /><br />Try moving that code in the &quot;else&quot; block of your&nbsp;Instance_MapLoaded method and see if it works.<br /></div></blockquote>
<p class="MsoNormal"><font face="'Segoe UI', sans-serif" color="black">Indeed!</font></p>
<p class="MsoNormal"><font face="'Segoe UI', sans-serif" color="black">&nbsp;</font></p>
<p class="MsoNormal"><font face="'Segoe UI', sans-serif" color="black">The COM object was indeed created in that thread, which was actually a worker thread. That explains why I could access that interface before the invoke, but not after. I say this because
 MapObject.Instance was created outside of that worker thread, which would indicate that its contained COM interfaces were also created outside of the worker thread. But not in this case, that interface was created in the worker thread as you predicted!</font></p>
<p class="MsoNormal"><font face="'Segoe UI', sans-serif" color="black">&nbsp;</font></p>
<p class="MsoNormal"><font face="'Segoe UI', sans-serif" color="black">What is interesting is that I just went to test what happens on a Windows CE device, as the code runs there. I set up the same test and debugging the app while running in CE seems to have
 no problem with accessing COM objects between threads. So there I think we can learn something, that sometimes things are not so portable as you think when working with COM. The original implementer never got hit with the problem of marshalling between threads,
 so he clearly just fired away.&nbsp;</font></p>
<p class="MsoNormal"><font face="'Segoe UI', sans-serif" color="black">&nbsp;</font></p>
<p class="MsoNormal"><font face="'Segoe UI', sans-serif" color="black">I might be able to fix this instance, but I get a sneaky suspicion the entire program is going to be riddled with this issue. I am not looking forward to this.</font></p>
<p class="MsoNormal"><font face="'Segoe UI', sans-serif" color="black">&nbsp;You mention STA Com objects, can I instantiate them in a way that they are not single thread apartment objects? Which would mean I assume I can access them from multiple &quot;apartments&quot;? I
 am guessing here, I lack theory.</font></p>
<p class="MsoNormal"><font face="'Segoe UI', sans-serif" color="black">Regards,</font></p>
<p class="MsoNormal"><font face="'Segoe UI', sans-serif" color="black">&nbsp;</font></p>
<p class="MsoNormal"><font face="'Segoe UI', sans-serif" color="black">PS- I will probably check out marshalling/proxy you mentioned, but I have never done that before so. We never get a break in this world of computers ;'(</font></p>
<p class="MsoNormal">&nbsp;</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/56f35f3390c946d7ad3c9deb0004eef4#56f35f3390c946d7ad3c9deb0004eef4</link>
		<pubDate>Fri, 03 Apr 2009 09:40:38 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/56f35f3390c946d7ad3c9deb0004eef4#56f35f3390c946d7ad3c9deb0004eef4</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - WPF + WindowsFormsHost + .Net Forms + ( COM interfaces + Forms Invoke ) = E_NOINTERFACE Exception </title>
		<description><![CDATA[<p>Oh yea, I forgot to mention:&nbsp;<br /><br /><em>m_objTransformation</em> is actually pointing to an instance of a&nbsp;<strong><em>SM3DDisplayTransformationClass
</em></strong>object. That is why the exception is complaining about casing from&nbsp;<strong><em>SM3DDisplayTransformationClass</em></strong> to&nbsp;<strong><em>I3DDisplayTransformationSetup</em></strong>. This is legal though as&nbsp;<br /><strong><em>SM3DDisplayTransformationClass</em></strong> implements<strong><em>&nbsp;I3DDisplayTransformationSetup</em></strong>, or the compiler would have moaned <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-5.gif' alt='Wink' />&nbsp;<strong><em>SM3DDisplayTransformationClass</em></strong>&nbsp;by law must always be able to cast to
 one of its interfaces ,surely!<br /><br />Regards</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/38752c00707f4f8ab5a89deb0004ee98#38752c00707f4f8ab5a89deb0004ee98</link>
		<pubDate>Thu, 02 Apr 2009 23:41:30 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/38752c00707f4f8ab5a89deb0004ee98#38752c00707f4f8ab5a89deb0004ee98</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - WPF + WindowsFormsHost + .Net Forms + ( COM interfaces + Forms Invoke ) = E_NOINTERFACE Exception </title>
		<description><![CDATA[<p>Hi there.<br /><br />I really need help from someone who knows the ins and outs of Microsoft development. I am &quot;porting&quot; a .Net Winforms app written for Windows Mobile into WPF. This winforms app is actually a navigaion application, similar to tom-tom or Garmen navigation that
 we have come to know and love.&nbsp; I have in my posession the WinForms app, plus the COM library it requires to do its work. The COM library is compiled to x86 if someone was wondering, I have both x86 and ARMv4 version of it. BUT I do not have the source code
 of the COM object.<br /><br />Ok so what do we have? Exceptions for Africa&nbsp;as usual:<br /><br />Unable to cast COM object of type 'NETSMMobile.SM3DDisplayTransformationClass' to interface type 'NETSMMobile.I3DDisplayTransformationSetup'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{8D724E8D-E00A-4700-9722-009901156857}'
 failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).<br /><br />Now, this looks like a normal coding error, but&nbsp;SM3DDisplayTransformationClass implements&nbsp;I3DDisplayTransformationSetup. I have checked and double checked. So how can this happen then. Well, somehow WinForms' Invoke causes the &quot;cast&quot; to fail. I say &quot;cast&quot; because
 there is no real cast going on there. Anywais lets say there is a &quot;cast&quot;, implicid maybe, the cast works &quot;outside&quot; of the invoke, but not inside. Here is the code I used to test this:<br /><br /><pre class="brush: text">
private void Instance_MapLoaded(object sender, NETSMMobile.esriSMRendererLoadStatus eStatus)
{
   // Here I injected my little test line to cause an exception. The real exception actually happned in the else statement below.
   double d = MapObject.Instance.MapView.RotationAngle; //This line throws the exception but only if the method was called inside the Invoke below.  Look for MapView's explenation below.
   if (m_bDisposed)
      return;
   if (InvokeRequired)
      Invoke(new MapLoadedEventHandler(Instance_MapLoaded), new Object[] { sender, eStatus });
   else
   {
       //Where the exception actually fires, inside here somewhere.
   }
}
</pre><br /><br />MapView implements IMapView that exposes the RotationAngle Property. The MapView implementation redirects the call to a COM&nbsp;interface object hosted inside MapView:<br /><br /><pre class="brush: text">
class MapView : IMapView
{
   //Our COM interface
   private I3DDisplayTransformationSetup m_objTransformation;

   public double RotationAngle
   {
      get{ return m_objTransformation.RotationAngle; }
   }
}

// Generated by Microsoft (R) .NET Framework Type Library to Assembly Converter 3.5.30729.1
[TypeLibType( 2 )]
[ClassInterface( 0 )]
[Guid( &quot;36FAAB60-7424-4DF6-8DB6-B9931DF3EB26&quot; )]
public class SM3DDisplayTransformationClass : SM3DDisplayTransformation, I3DDisplayTransformationSetup, IDisplayTransformation
{
   [DispId( 2 )]
   public virtual double RotationAngle { get; set; }
}

[InterfaceType( 1 )]
[Guid( &quot;8D724E8D-E00A-4700-9722-009901156857&quot; )]
public interface I3DDisplayTransformationSetup
{
   [DispId( 2 )]
   double RotationAngle { get; set; }
}

</pre><br /><br />There, that should be enough to demonstrate the link to COM from that call that causes the exception. Now I have tried to guess things such as spamming [STAThread] and things like that but I am getting nowhere. I fear I have to little knowledge of COM and .Net-&gt;COM
 and to study these things might take 100 years, which I don’t have .</p>
<p>To add, I have tested that I registered the COM object on my BOX. If I unregistered it the code would fail much earlier with proper error basically saying that the COM interface does not exist.
</p>
<p>I also tried referencing the COM object directly, same error.</p>
<p>I also generated my own .NET assembly from the COM object using that tlbimp.exe, but&nbsp; same results.<br /><br />One more thing, if you compile the original Forms project and deploy it to a Windows mobile device, it would work. So I fear the problem lies in the port, or differences&nbsp;between&nbsp;WinForms on Compact Framework and full .Net.<br /><br />Please help someone, anyone.<br /><br />Regards.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/463602#463602</link>
		<pubDate>Thu, 02 Apr 2009 23:33:42 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/463602-WPF--WindowsFormsHost--Net-Forms---COM-interfaces--Forms-Invoke---ENOINTERFACE-Exception/463602#463602</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - WPF Image Source cache problem?</title>
		<description><![CDATA[<p>Hi there.&nbsp;
<div><br /></div>
<div>I wrote a small WPF app and I have the following code that loads images for me:</div>
<div><br /></div>
<div>
<div></div>
<span>
<div><span class="Apple-tab-span"></span>/// &lt;summary&gt;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;/// Loads an image from a path name</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;/// &lt;/summary&gt;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;/// &lt;param name=&quot;relativePath&quot;&gt;The path the the image&lt;/param&gt;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;/// &lt;returns&gt;An instance of the class &lt;see cref=&quot;ImageSource&quot;/&gt; that contains the loaded image&lt;/returns&gt;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public static ImageSource Load( string relativePath )</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//Test the cache if the internal cache is enabled</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</span>
<div></div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ImageSource imageSource = useInternalCache? TryCache( relativePath ) : null;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( imageSource != null )</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return imageSource;</div>
<div><br /></div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Logger.Instance.Log( null, Logger.LogLevel.Debug, &quot;Loading `&quot; &#43; relativePath &#43; &quot;'&quot; );</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Uri uri = new Uri( &quot;pack://siteoforigin:,,,/&quot; &#43; relativePath );</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string fileType = relativePath.Substring( relativePath.LastIndexOf( &quot;.&quot; ) );</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//Create the image source from the filetype</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( fileType == &quot;.ico&quot; )</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IconBitmapDecoder ico = new IconBitmapDecoder( uri, BitmapCreateOptions.None, BitmapCacheOption.Default );</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;imageSource = ico.Frames[0]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else if ( fileType == &quot;.bmp&quot; )</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;imageSource = new BitmapImage( uri );</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else if ( fileType == &quot;.png&quot; )</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PngBitmapDecoder png = new PngBitmapDecoder( uri, BitmapCreateOptions.None, BitmapCacheOption.Default );</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;imageSource = png.Frames[0];</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else if ( fileType == &quot;.jpg&quot; )</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;JpegBitmapDecoder jpg = new JpegBitmapDecoder( uri, BitmapCreateOptions.None, BitmapCacheOption.Default );</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;imageSource = jpg.Frames[0];</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//TODO default cross or something</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Logger.Instance.Log( null, Logger.LogLevel.Warn, &quot;Image of type `&quot; &#43; fileType &#43; &quot;' is not supported&quot; );</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;catch ( Exception e )</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Logger.Instance.Log( null, Logger.LogLevel.Warn, &quot;Image load failed `&quot; &#43; relativePath &#43; &quot;' with exception: &quot;, e );</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div>
<div><br /></div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//Cache the image</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_imageCache[ExtractFileName( relativePath )] = imageSource;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return imageSource;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div>
<div><br /></div>
<div>Firstly I would apreciate any criticism about the function. Really go to town, thats how I learn. Secondly that internal cache that I had to add there because if I load the same image twice I get an inner exeption on the lines that instantiate the new
 ImageSources.</div>
<div><br /></div>
<div>For example,&nbsp;</div>
<div><br /></div>
<div>IconBitmapDecoder ico = new IconBitmapDecoder( uri, BitmapCreateOptions.None, BitmapCacheOption.Default );<br /></div>
<div><br /></div>
<div>would throw a inner exception causing the image not to load.&nbsp;</div>
<div><br /></div>
<div>Further more, after enabling Common Language Runtime Exceptions those lines brings down the app. Looking at the stack trace it seems that the exception happnes somewhere down the caching code path. Could it be a caching problem? I tried fiddeling with
 those caching settings in the call but those seem to have no effect.</div>
<div><br /></div>
<div>What is even more disturbing is when you step to those lines, the inner exception would not happen and the image would load properly. Making debugging the problem even more confusing.&nbsp;</div>
<div><br /></div>
<div>Another weird thing is that after loading the image, if you access the image in any way, for instance 'if( image.height &gt; ) doSomething;' then the inner exception also fails to happen and the image loads.&nbsp;</div>
<div><br /></div>
<div>I am just posting the problem here for in case someone else ever come across the problem. &nbsp;While typing this email I realized that I set my target Framework to 3.0, I would test it on target Framework 3.5 and report if I get the same behaviour.</div>
<div><br /></div>
<div>Regards,</div>
<div><br /></div>
<div>W</div>
</div></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/461390-WPF-Image-Source-cache-problem/461390#461390</link>
		<pubDate>Wed, 18 Mar 2009 07:59:26 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/461390-WPF-Image-Source-cache-problem/461390#461390</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>1</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - WPF exceptions inside beginInvoke</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Sven Groot said:</div><div class="quoteText">
<p>Debug menu, Exceptions, for &quot;Common Language Runtime Exceptions&quot; check the &quot;Thrown&quot; checkbox. That'll cause the debugger to immediately break for all exceptions when they're thrown, even if they are handled somewhere.</p>
</div></blockquote>Thanks allot. <br /><br />I will test it out and see how it works <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-5.gif' alt='Wink' /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/458069-WPF-exceptions-inside-beginInvoke/80e8d76f04ed4fb4ab779deb0004011b#80e8d76f04ed4fb4ab779deb0004011b</link>
		<pubDate>Thu, 19 Feb 2009 15:33:53 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/458069-WPF-exceptions-inside-beginInvoke/80e8d76f04ed4fb4ab779deb0004011b#80e8d76f04ed4fb4ab779deb0004011b</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>4</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - WPF exceptions inside beginInvoke</title>
		<description><![CDATA[<p>Hi there.<br /><br />I am sorry if this has been answered before, somehow I find it difficult to steer Google to give me answers with regards to the topic.<br /><br />I am currently &quot;procedurally&quot; creating a WPF app. I am aware that this raises red flags for all, but down here there is no proper training available for the poor with regards to new MS technologies.&nbsp; I&nbsp;had difficulty grasping how I am going to create the kind
 of UI that was required within the expected timeline without training. Ok so that being out of the way this is my main problem:<br /><br />Every now and again I get the following exception on: _wpfApp.Run( _wndMain );<br /><br />An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll<br /><br />Now, I have since figured out that this is sometimes caused by exceptions within those dispatch thingies. Now, &quot;theoretically&quot; I should not be writing code inside those dispatches that's complicated enough to cause exceptions. But unfortunately it just is not
 so simple for me in practice.&nbsp; Maybe its because I am to lazy to spam 2 methods for basically every interaction with the UI, but I don't want to believe that.<br /><br />My question is, how can I get the debugger to actually break on the line of code that causes the exception instead of floating back to Application.Run. If I have suspicions on where the exception is located &nbsp;I can always manually steer the debugger towards
 it, so why can’t the IDE do that for me. Why does it no &quot;step to&quot; the problem manually like I have to do? It's driving me crazy.<br /><br />Thanks for any help.<br /><br />Regards</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/458069-WPF-exceptions-inside-beginInvoke/458069#458069</link>
		<pubDate>Thu, 19 Feb 2009 12:29:44 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/458069-WPF-exceptions-inside-beginInvoke/458069#458069</guid>
		<dc:creator>Werner</dc:creator>
		<slash:comments>4</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pompomJuice/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>