Posts: 11
Registered: ‎01-23-2004
Message 1 of 4 (739 Views)
Accepted Solution

Error need reference to 'System.Windows.Interop.IWin32Window' to use MainWindow

739 Views, 3 Replies
07-30-2012 12:59 PM

Hi, Everyone

I am upgrading from AutoCAD 2008 to AutoCAD 2013. I have a project that was in VB.NET 2005 that I converted to VB.NET 2010 (Express). When I compile it, I get the following error:

Error    19    Reference required to assembly 'PresentationCore, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' containing the implemented interface 'System.Windows.Interop.IWin32Window'. Add one to your project.    

The line causing the error is
        ACApp.Application.MainWindow.Visible = False

The module imports the following:
Imports AC = Autodesk.AutoCAD
Imports ACApp = Autodesk.AutoCAD.ApplicationServices
Imports AcadDB = Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime

I have tried changing the line to
        ACApp.Core.Application.MainWindow.Visible = False
but that did not correct the error.

The .NET Migration Guide said that MainWindow was moved from Autodesk.AutoCAD.ApplicationServices.Application to Autodesk.AutoCAD.ApplicationServices.Core.Application, so as far as I know that change should have worked.

I feel like I must be missing something really obvious here, since I searched the discussion board and couldn't find anyone else asking about it. What am I missing?

*Expert Elite*
Posts: 907
Registered: ‎09-07-2004
Message 2 of 4 (735 Views)
*Expert Elite*
Posts: 752
Registered: ‎02-13-2008
Message 3 of 4 (722 Views)

Re: Error need reference to 'System.Windows.Interop.IWin32Window' to use MainWin

07-30-2012 04:04 PM in reply to: schesser

I don't know if this is covered in the video or not.  I kind of doubt that it is, because it is not something new to 2013.  It happened in at the latest 2012, maybe 2010, I don't remember. (I skipped 2011, and have not yet switched to 2013, and I had to deal with this already.)


It is very simple though, all you have to do is do what it tells you.  Add a Reference to PresentationCore v4.  This is not the same thing as Autodesk.AutoCAD.ApplicationServices.Core.  It is also not your accessing of the MainWindow object that requires the change per se, it is something AuoCAD is doing under the hood, which accesses the iWin32Window interface, which creates a dependancy on PresentationCore.

Dave O.                                                                  Sig-Logos32.png
Posts: 11
Registered: ‎01-23-2004
Message 4 of 4 (704 Views)

Re: Error need reference to 'System.Windows.Interop.IWin32Window' to use MainWin

08-01-2012 08:05 AM in reply to: schesser

chiefbraincloud, thank you for the answer and the explanation. I found PresentationCore.dll and added a reference to it.
I have read a number of your posts before when I was looking for answers.

GTVic, thanks for the links. The video on .NET migration was also helpful.

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.