<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Suzanne Cook's .NET CLR Notes</title><link>http://blogs.msdn.com/b/suzcook/</link><description>Common Language Runtime Developer</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Channel 9 Interview</title><link>http://blogs.msdn.com/b/suzcook/archive/2005/02/11/channel-9-interview.aspx</link><pubDate>Sat, 12 Feb 2005 02:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:371395</guid><dc:creator>Suzanne Cook</dc:creator><slash:comments>19</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/suzcook/rsscomments.aspx?WeblogPostID=371395</wfw:commentRss><comments>http://blogs.msdn.com/b/suzcook/archive/2005/02/11/channel-9-interview.aspx#comments</comments><description>&lt;A href="http://blogs.msdn.com/lifeontitan/archive/2004/04/26/120368.aspx" mce_href="http://blogs.msdn.com/lifeontitan/archive/2004/04/26/120368.aspx"&gt;Charles Torre&lt;/A&gt; and &lt;A href="http://scobleizer.com/" mce_href="http://scobleizer.com/"&gt;Robert Scoble&lt;/A&gt; (behind the camera) dropped by my office to chat with me about the loader for MSDN's Channel 9: &lt;A href="http://channel9.msdn.com/ShowPost.aspx?PostID=40856" mce_href="http://channel9.msdn.com/ShowPost.aspx?PostID=40856"&gt;part I&lt;/A&gt; and &lt;A href="http://channel9.msdn.com/ShowPost.aspx?PostID=41389" mce_href="http://channel9.msdn.com/ShowPost.aspx?PostID=41389"&gt;part II&lt;/A&gt;.&lt;BR&gt;&lt;FONT color=white&gt;Also, check out the PDC video I was in for Channel 9: http://channel9.msdn.com/ShowPost.aspx?PostID=79591 &lt;/FONT&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=371395" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/suzcook/archive/tags/Loader+Info/">Loader Info</category></item><item><title>New Assembly, Old .NET (and Vice-Versa)</title><link>http://blogs.msdn.com/b/suzcook/archive/2005/01/26/new-assembly-old-net-and-vice-versa.aspx</link><pubDate>Thu, 27 Jan 2005 01:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:361092</guid><dc:creator>Suzanne Cook</dc:creator><slash:comments>17</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/suzcook/rsscomments.aspx?WeblogPostID=361092</wfw:commentRss><comments>http://blogs.msdn.com/b/suzcook/archive/2005/01/26/new-assembly-old-net-and-vice-versa.aspx#comments</comments><description>&lt;P&gt;I typically recommend that you build &lt;U&gt;and&lt;/U&gt; test your assemblies against the same version of .NET that you will be running them against. That way, you'll have correct references and avoid surprises from behavior differences between builds.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Older assembly, newer .NET&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;But, sometimes you don't run against the same version that you built against. For example, the latest available CLR is the default when interop causes it to be loaded. Or, if &lt;A href="http://blogs.msdn.com/suzcook/archive/2003/06/20/57191.aspx" mce_href="http://blogs.msdn.com/suzcook/archive/2003/06/20/57191.aspx"&gt;the version of the CLR the assembly was built against&lt;/A&gt; is not available, the latest version can also be used instead. If there is a compatibility problem with that for your application, you can force the use of a preferred CLR version by &lt;A href="http://blogs.msdn.com/suzcook/archive/2004/05/14/132022.aspx" mce_href="http://blogs.msdn.com/suzcook/archive/2004/05/14/132022.aspx"&gt;using an app.config&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Compatibility&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Yes, there are going to be behavior differences between versions - no way around it. It is the .NET team's goal to be as backwards compatible as realistically possible between versions. But, some changes are required - new features are added which sometimes require (hopefully minimal) behavior changes&amp;nbsp;in other features. If we were required to never break any app, ever, we wouldn't be able to fix any bugs or add any features for fear that someone, somewhere relied on the broken behavior in some strange way. As Dll Hell has&amp;nbsp;shown in the past, new versions of components aren't &lt;EM&gt;really&lt;/EM&gt; compatible.&amp;nbsp;The only guaranteed 100% compatible version is the same one you tested against.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;V2+ assembly, older .NET&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Say you see a BadImageFormatException for hresult 0x80131107 (CLDB_E_FILE_OLDVER) with message "Version [...] is not a compatible version." That means that you've tried to load an assembly built against a newer version of the CLR than was running.&lt;/P&gt;
&lt;P&gt;This fails because&amp;nbsp;new files can't be opened&amp;nbsp;on an older CLR that does not understand them. You will need to either use the v2 CLR to load the v2/v1 assemblies, or load only v1 assemblies on the v1 CLR. That's just good practice, anyway. If you try to use an older .NET than you built against, a method you built against may not exist, etc.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=361092" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/suzcook/archive/tags/Loader+Info/">Loader Info</category></item><item><title>Versioning/Deploying Unmanaged Files</title><link>http://blogs.msdn.com/b/suzcook/archive/2004/10/28/versioning-deploying-unmanaged-files.aspx</link><pubDate>Fri, 29 Oct 2004 00:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249280</guid><dc:creator>Suzanne Cook</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/suzcook/rsscomments.aspx?WeblogPostID=249280</wfw:commentRss><comments>http://blogs.msdn.com/b/suzcook/archive/2004/10/28/versioning-deploying-unmanaged-files.aspx#comments</comments><description>&lt;P&gt;An unmanaged dll can be wrapped in a managed assembly by adding it as a file of a multi-module assembly. Then, it can be deployed and versioned in the same way as managed assemblies. (So, that assembly could contain nothing but metadata and unmanaged code - no managed code, if you prefer. It can also contain multiple unmanaged files in the same assembly.)&lt;/P&gt;
&lt;P&gt;If your compiler does not support this directly, you can get this to work by adding that file as a&amp;nbsp;linked managed resource. For example, see Visual Studio's /linkresource option (if using it for command line compiling).&lt;/P&gt;
&lt;P&gt;This is useful in the case where DllImport() is used to access a function in that file. That call should be updated with the new assembly's info. For example, in the place of &lt;I&gt;"unmanagedfile.dll"&lt;/I&gt;, change it to include the &lt;A href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57137.aspx" mce_href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57137.aspx"&gt;display name&lt;/A&gt; like this: &lt;I&gt;"unmanagedfile.dll, managedassembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&lt;/I&gt;.&lt;/P&gt;
&lt;P&gt;If that unmanaged file needs to be loaded by LoadLibrary() outside of DllImport(), however, it will need to follow the rules of LoadLibrary(), like the usual unmanaged file use outside the CLR. (See &lt;A href="http://blogs.msdn.com/junfeng/archive/2004/07/14/181932.aspx" mce_href="http://blogs.msdn.com/junfeng/archive/2004/07/14/181932.aspx"&gt;Junfeng's blog&lt;/A&gt; for an extra tip regarding that when using v2.)&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=249280" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/suzcook/archive/tags/Loader+Info/">Loader Info</category></item><item><title>Load(AssemblyName)</title><link>http://blogs.msdn.com/b/suzcook/archive/2004/08/04/load-assemblyname.aspx</link><pubDate>Wed, 04 Aug 2004 23:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:208232</guid><dc:creator>Suzanne Cook</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/suzcook/rsscomments.aspx?WeblogPostID=208232</wfw:commentRss><comments>http://blogs.msdn.com/b/suzcook/archive/2004/08/04/load-assemblyname.aspx#comments</comments><description>&lt;P&gt;Calling Load(AssemblyName) is not necessarily the same as calling Load(String). If the AssemblyName.CodeBase is &lt;EM&gt;not&lt;/EM&gt; set, then they do do the same thing. So, if you've set the AssemblyName.Name, CultureInfo, public key token / public key and/or Version properties, it would be the same as if you had specified those properties in a String (as a &lt;A href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57137.aspx" mce_href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57137.aspx"&gt;display name&lt;/A&gt;) and passed that to Load(String).&lt;/P&gt;
&lt;P&gt;If the&amp;nbsp;CodeBase is set,&amp;nbsp;but the Name is &lt;EM&gt;not&lt;/EM&gt;, however, then it's the same as calling Assembly.LoadFrom() on that CodeBase.&lt;/P&gt;
&lt;P&gt;When both the CodeBase and the Name are set, then the bind is tried with all the given binding information except the CodeBase (so, again, just like calling Load(String)). If that succeeds, we're done. But, if that fails, then the bind is tried again with just the CodeBase (just like LoadFrom()). If it fails again, then, of course, the whole bind fails. But, if it succeeds, then we verify that the binding properties in the AssemblyName match the found assembly. If they don't match, a FileLoadException will be thrown for hresult FUSION_E_REF_DEF_MISMATCH.&lt;/P&gt;
&lt;P&gt;So, setting both the CodeBase and the Name is useful for when you want to both load an assembly at a given path into the LoadFrom context, and verify that it has the public key token, etc. that you expect. Of course, as described above (and due to &lt;A href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx" mce_href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx"&gt;binding context rules&lt;/A&gt;), keep in mind that just because you call Load(AssemblyName) with a CodeBase, it&amp;nbsp;does not mean that it will be loaded from that path.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=208232" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/suzcook/archive/tags/Loader+Info/">Loader Info</category></item><item><title>Debugging an InvalidCastException</title><link>http://blogs.msdn.com/b/suzcook/archive/2004/06/02/debugging-an-invalidcastexception.aspx</link><pubDate>Thu, 03 Jun 2004 04:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:147195</guid><dc:creator>Suzanne Cook</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/suzcook/rsscomments.aspx?WeblogPostID=147195</wfw:commentRss><comments>http://blogs.msdn.com/b/suzcook/archive/2004/06/02/debugging-an-invalidcastexception.aspx#comments</comments><description>&lt;P&gt;First, obviously, find the two types for which the cast failed and&amp;nbsp;verify that they are the same type or otherwise castable.&lt;/P&gt;
&lt;P&gt;Next,&amp;nbsp;if&amp;nbsp;the type was just&amp;nbsp;deserialized, also &lt;A href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx" mce_href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx"&gt;verify that its assembly successfully loaded&lt;/A&gt; in the target appdomain.&lt;/P&gt;
&lt;P&gt;If everything seems fine, check to see if the assemblies for those two types are loaded from different locations&amp;nbsp;and in&amp;nbsp;the same appdomain. (The actual cast is done in just one appdomain, even if the exception happens when passing a type between two appdomains.) Even if the bits of those assemblies are totally identical, if they are loaded from different paths, they will be considered different, so their types will be considered different. (See &lt;A href="http://blogs.msdn.com/suzcook/archive/2003/07/21/57232.aspx" mce_href="http://blogs.msdn.com/suzcook/archive/2003/07/21/57232.aspx"&gt;Comparing Already-Loaded Assemblies&lt;/A&gt;.)&lt;/P&gt;
&lt;P&gt;A quick way to check for that is to examine the loaded module window of a debugger to see if that assembly&amp;nbsp;was loaded multiple times. If it was, break on module loads to get the callstack for the unexpected load. If that's inconvenient, try getting the &lt;A href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx" mce_href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx"&gt;Fusion log&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Usually, the problem is that:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The assembly is available in the GAC (or the ApplicationBase) and loaded there by static reference (something was compiled against that assembly). 
&lt;LI&gt;It has also been loaded dynamically by path, from another path (LoadFrom(), LoadFile(), etc.). 
&lt;LI&gt;Then, the code tries to cast the type from (2) to the corresponding type from (1). &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;To fix this, once you find the offending caller, you will need to either cause the two types to be loaded from the same assembly from the exact same path, or avoid doing the cast. To decide between the assemblies at paths (1) and (2), see &lt;A href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx" mce_href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx"&gt;Choosing a Binding Context&lt;/A&gt;. Usually, I recommend using (1) - see &lt;A href="http://blogs.msdn.com/suzcook/archive/2003/06/13/57180.aspx" mce_href="http://blogs.msdn.com/suzcook/archive/2003/06/13/57180.aspx"&gt;Switching to the Load Context&lt;/A&gt; for help with&amp;nbsp;implementing that.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=147195" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/suzcook/archive/tags/Loader+Debugging+Advice/">Loader Debugging Advice</category></item><item><title>App.config Examples</title><link>http://blogs.msdn.com/b/suzcook/archive/2004/05/14/132022.aspx</link><pubDate>Fri, 14 May 2004 16:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:132022</guid><dc:creator>Suzanne Cook</dc:creator><slash:comments>25</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/suzcook/rsscomments.aspx?WeblogPostID=132022</wfw:commentRss><comments>http://blogs.msdn.com/b/suzcook/archive/2004/05/14/132022.aspx#comments</comments><description>&lt;P&gt;Below are three examples of useful &lt;A href="http://blogs.msdn.com/suzcook/archive/2003/06/02/57160.aspx"&gt;application configuration files&lt;/A&gt;.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Forces the v1.0 CLR to be run.&amp;nbsp;If the v1.0 CLR is not installed, the app will fail to run.&lt;BR&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;lt;?xml version ="1.0"?&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;lt;configuration&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;startup&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;requiredRuntime version="v1.0.3705"/&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;supportedRuntime version="v1.0.3705"/&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/startup&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;lt;/configuration&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;LI&gt;Redirects &amp;#8220;assemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=25283151a234958d&amp;#8220; to version 2.0.0.0 of that assembly. This is only useful for strongly-named assemblies, since versions don't matter for those that are simply-named.&lt;BR&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;lt;?xml version ="1.0"?&amp;gt; &lt;BR&gt;&amp;lt;configuration&amp;gt; &lt;BR&gt;&amp;lt;runtime&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;dependentAssembly&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;assemblyIdentity name="assemblyName" culture="" publicKeyToken="25283151a234958d"/&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/dependentAssembly&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/assemblyBinding&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;lt;/runtime&amp;gt; &lt;BR&gt;&amp;lt;/configuration&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;LI&gt;Redirects &amp;#8220;assemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8968ee41e78ce97a&amp;#8220; to codebase &amp;#8220;http://www.yourwebsite.com/filename.dll&amp;#8220;. 'Href' can also be set to something like &amp;#8220;file:///c:/localfile/filename.dll&amp;#8220;. Note that redirecting to a codebase causes a System.Net.WebPermission or System.IO.FileIOPermissionAccess.Read + PathDiscovery demand when loading that assembly.&lt;BR&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;lt;?xml version ="1.0"?&amp;gt; &lt;BR&gt;&amp;lt;configuration&amp;gt; &lt;BR&gt;&amp;lt;runtime&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;dependentAssembly&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;assemblyIdentity name="assemblyName" culture="" publicKeyToken="8968ee41e78ce97a"/&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;codeBase version="1.0.0.0"&amp;nbsp;href="http://www.yourwebsite.com/filename.dll"/&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/dependentAssembly&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/assemblyBinding&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;lt;/runtime&amp;gt;&lt;BR&gt;&amp;lt;/configuration&amp;gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=132022" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/suzcook/archive/tags/Loader+Info/">Loader Info</category></item><item><title>Determining Whether a File Is an Assembly</title><link>http://blogs.msdn.com/b/suzcook/archive/2004/03/17/determining-whether-a-file-is-an-assembly.aspx</link><pubDate>Thu, 18 Mar 2004 08:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:91715</guid><dc:creator>Suzanne Cook</dc:creator><slash:comments>10</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/suzcook/rsscomments.aspx?WeblogPostID=91715</wfw:commentRss><comments>http://blogs.msdn.com/b/suzcook/archive/2004/03/17/determining-whether-a-file-is-an-assembly.aspx#comments</comments><description>&lt;P&gt;A file is an assembly if and only if it's managed and it contains an Assembly entry in its CLR metadata. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Determining by hand&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;A fast way to determine whether a file is an assembly is to run ildasm.exe on it. If it immediately gives an error saying that&amp;nbsp;it may not be a PE file, then it's not a managed file. But, if it is an assembly, then ildasm will show an entry for the Assembly definition (“.assembly“ in the MANIFEST window or at the bottom of the original window). &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Determining programmatically&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;From unmanaged code, you can call GetAssemblyFromScope() on the IMetaDataAssemblyImport interface for the file. If it returns S_OK, it's an assembly. If it returns CLDB_E_RECORD_NOTFOUND, it's not an assembly. &lt;/P&gt;
&lt;P&gt;From managed code, if AssemblyName.GetAssemblyName(), Assembly.Load*(), etc. succeeds when given that file, then it's an assembly. If the load failed with a BadImageFormatException, then it may not be an assembly. There are other reasons, however,&amp;nbsp;why that exception may have been thrown (maybe it's an assembly but could not be loaded because it has an incorrect format). Coming soon in v2, if the hresult for&amp;nbsp;BadImageFormatException is COR_E_ASSEMBLYEXPECTED, then it's because it's not an assembly. Catch the exception and call System.Runtime.InteropServices.Marshal.GetHRForException() to get its hresult to find out. &lt;/P&gt;
&lt;P&gt;Note that this assumes that you are not concerned about performance. If you are concerned about that, then the way to optimize for it is to &lt;EM&gt;&lt;U&gt;not&lt;/U&gt; try to determine whether files are assemblies at runtime at all&lt;/EM&gt;. (Some people are concerned about the exception that is thrown if the file is not an assembly. They overlook that in order to determine that it is not one, it has to be loaded and then thrown away, which&amp;nbsp;can be&amp;nbsp;even more expensive than catching an exception!) Instead, require that only assemblies are given to you. Then, if a file is not an assembly, it will be an exceptional situation. That way, you avoid the bad perf of both the exception and the unnecessary file loading.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=91715" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/suzcook/archive/tags/Loader+Info/">Loader Info</category></item><item><title>Debugging a MissingMethodException, MissingFieldException, TypeLoadException</title><link>http://blogs.msdn.com/b/suzcook/archive/2004/02/13/debugging-a-missingmethodexception-missingfieldexception-typeloadexception.aspx</link><pubDate>Sat, 14 Feb 2004 03:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:72728</guid><dc:creator>Suzanne Cook</dc:creator><slash:comments>14</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/suzcook/rsscomments.aspx?WeblogPostID=72728</wfw:commentRss><comments>http://blogs.msdn.com/b/suzcook/archive/2004/02/13/debugging-a-missingmethodexception-missingfieldexception-typeloadexception.aspx#comments</comments><description>&lt;P&gt;Say you've just installed some assemblies from a third party&amp;nbsp;and now you're seeing a MissingMethodException, MissingFieldException, or&amp;nbsp;TypeLoadException (during the run of an application using those assemblies). Below are the common causes.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Loading failures&lt;/STRONG&gt;&lt;BR&gt;First, check for assembly binding failures by &lt;A href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx" mce_href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx"&gt;getting the Fusion log&lt;/A&gt;. Look for the assembly containing that method/field/type or assemblies containing types referenced by it. If an assembly failed to load, use the instructions at the same link to help resolve that issue.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Unexpected assembly version loaded&lt;/STRONG&gt; &lt;BR&gt;But, if that's not the problem, turn on the Fusion log for everything - not just failures - and check to see if the wrong version of those assemblies is being loaded. Look at the display names requested. Are any requesting outdated versions, even after policy has been applied (see further down in the log for the post-policy display name)? If so, you may want to recompile part of your app so that it has current references.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Loaded from unexpected path&lt;/STRONG&gt; &lt;BR&gt;If that doesn't help, run filever.exe on the file at the path it was loaded from. You can get that from the loaded modules list in a debugger. It's also the last path listed in the Fusion log, for a successful log (if it's in the GAC, no path is listed). Make sure it is the same path as you would expect.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Not in this version of the assembly&lt;/STRONG&gt;&lt;BR&gt;Next, run ildasm.exe on the file &lt;EM&gt;at the path it was loaded from at runtime.&lt;/EM&gt; Make sure that the method/field/type is there and&amp;nbsp;is defined&amp;nbsp;how you would expect it. Maybe the file has changed, adding or removing methods or the like,&amp;nbsp;but the assembly version and location have stayed the same.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Invalid IL&lt;/STRONG&gt; &lt;BR&gt;Now, try running peverify.exe on the file containing the method/field/type using the path it was loaded from at runtime. If it gives an error, check back to see if there was a warning at compile-time for this file.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=72728" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/suzcook/archive/tags/Loader+Debugging+Advice/">Loader Debugging Advice</category></item><item><title>Where to Find Technical Support</title><link>http://blogs.msdn.com/b/suzcook/archive/2003/12/05/where-to-find-technical-support.aspx</link><pubDate>Sat, 06 Dec 2003 02:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:57253</guid><dc:creator>Suzanne Cook</dc:creator><slash:comments>14</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/suzcook/rsscomments.aspx?WeblogPostID=57253</wfw:commentRss><comments>http://blogs.msdn.com/b/suzcook/archive/2003/12/05/where-to-find-technical-support.aspx#comments</comments><description>&lt;P&gt;Microsoft's official support website is &lt;A href="http://support.microsoft.com/" mce_href="http://support.microsoft.com/"&gt;http://support.microsoft.com/&lt;/A&gt;. It has all kinds of resources like product FAQs, downloads, searchable KB articles, newsgroup pointers, and ways to reach people to help with your individual needs or feedback. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#000000&gt;Unfortunately, I can't give attention to individual customer issues.&lt;/FONT&gt;&lt;/STRONG&gt; That's because I work in product design and development, not customer support. Someone has to be focused on that or else we'd never ship anything! So, I'm going to have to leave your questions and comments to MS's official channels which specialize in that. Please keep comments you post here general and about the loader or performance. &lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=57253" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/suzcook/archive/tags/Loader+Debugging+Advice/">Loader Debugging Advice</category></item><item><title>Determining the Referencing Assembly</title><link>http://blogs.msdn.com/b/suzcook/archive/2003/11/14/determining-the-referencing-assembly.aspx</link><pubDate>Sat, 15 Nov 2003 10:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:57250</guid><dc:creator>Suzanne Cook</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/suzcook/rsscomments.aspx?WeblogPostID=57250</wfw:commentRss><comments>http://blogs.msdn.com/b/suzcook/archive/2003/11/14/determining-the-referencing-assembly.aspx#comments</comments><description>&lt;P&gt;Say you're debugging your application and you see that version 1.0 of an assembly is being loaded when you thought it should be version 2.0. Where is the reference to 1.0 coming from? &lt;/P&gt;
&lt;P&gt;The easiest way to find out is to look at the &lt;A href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx" mce_href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx"&gt;Fusion log&lt;/A&gt; for this bind. If the version 1.0 assembly was successfully loaded, use the ForceLog/"Log all binds" option of FusLogVw. Then, look for the line in the log showing the calling assembly: &lt;/P&gt;
&lt;P&gt;&lt;I&gt;Calling assembly : referencingAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=12ab3bf24c56c45b. &lt;/I&gt;&lt;/P&gt;
&lt;P&gt;It shows the display name of the calling assembly when available. It doesn't tell you whether this is a static or a dynamic reference because Fusion doesn't know or care (that doesn't matter for binding purposes). So, this could mean that referencingAssembly was built against the other 1.0 assembly, or that it asked for it at runtime via Assembly.Load(), etc. &lt;/P&gt;
&lt;P&gt;Sometimes the calling assembly is not specified in the log. There are a few possible cases where that happens: 
&lt;UL&gt;
&lt;LI&gt;The assembly was requested by unmanaged code (interop). 
&lt;LI&gt;The calling assembly was in another appdomain (AppDomain.CreateInstance(), etc.). 
&lt;LI&gt;The calling assembly had not been loaded through Fusion (Assembly.Load(byte[]), Assembly.LoadFile(), etc.). &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=57250" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/suzcook/archive/tags/Loader+Debugging+Advice/">Loader Debugging Advice</category></item></channel></rss>