Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / June 2005

Tip: Looking for answers? Try searching our database.

COM interop: no change but get TypeLoadException

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg Bacon - 16 Jun 2005 21:30 GMT
I have a solution with many projects, of which several have COM
references to a third-party DLL.  At initialization, our application
performs reflection searches through the assemblies in its start
directory to discover its functionality.  In other words, most of the
projects know very little about each other.

A few of these projects -- mostly C#, but some managed C++ -- depend on
the same COM server, and the generated interop assembly causes
occasional trouble.

After a build, we run a postbuild step that searches for *.dll and
*.exe and for each hit, if its modification time is more recent than
that of the file by the same name in the staging area, we update the
staging area accordingly.

This heuristic works fine in from-scratch builds, but if we modify one
of the projects that talk to the (in-process) COM server, perform an
incremental build, and then run the postbuild again, we get a
TypeLoadException from any method that tries to instantiate the
coclass.

As I wrote above, the underlying DLL is from a third party and does not
change.  The MVID changes of course, but no other changes are obvious
when examining with ildasm.  Looking at hex dumps shows some pretty
extensive differences, but they must only be shuffling because all the
copies of the interop assembly have the same length.

We can work around the issue by going back and copying the interop
assembly from the build directory of the project we updated, but it'd
be nice to be able to either fix whatever the underlying problem is or
at least be able to automate the workaround.

Why is the most-recent-wins heuristic inadequate?  Note that when our
postbuild copies a file to the staging area, it updates the
modification time to mirror that of its source's so files other than
the first one found have a shot at making it.

What significant differences (i.e., other than commentary metadata) are
there between interop assemblies generated for different projects but
for the identical underlying DLL?  Why aren't they interchangeable?

Thanks for any help,
Greg
Greg Bacon - 17 Jun 2005 17:16 GMT
Here's an interesting wrinkle.  I compared the ildasm output from the
build of the interop that generates the TypeLoadException to the same
for an assembly from which the load is happy.  I noticed an interesting
difference:

   --- nogo.il     2005-06-17 09:49:34.172981600 -0500
   +++ go.il       2005-06-17 09:50:52.806050400 -0500
   @@ -18,7 +18,7 @@
      .ver 1:0:0:0
    }
    .module TACGRAPHDOCLib.dll
   -// MVID: {E2568D0B-BF0B-43A0-BF19-8B370C854218}
   +// MVID: {92521547-3CF1-49F3-B289-F3F3D75E5A8D}
    .imagebase 0x00400000
    .subsystem 0x00000003
    .file alignment 4096
   @@ -27,17 +27,17 @@
    //
    // ============== CLASS STRUCTURE DECLARATION ==================
    //
   -.namespace Interop.TACGRAPHDOCLib
   +.namespace TACGRAPHDOCLib
   [...]

Why would the namespace change?  If this is the source of the
TypeLoadException, what do I need to do to prevent it?

Thanks,
Greg

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.