.NET

.NET

Reply
Contributor
schesser
Posts: 11
Registered: ‎01-23-2004
Message 1 of 4 (805 Views)
Accepted Solution

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

805 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=4.0.0.0, 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?

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.

*Expert Elite*
GTVic
Posts: 929
Registered: ‎09-07-2004
Message 2 of 4 (801 Views)
*Expert Elite*
chiefbraincloud
Posts: 753
Registered: ‎02-13-2008
Message 3 of 4 (788 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
Contributor
schesser
Posts: 11
Registered: ‎01-23-2004
Message 4 of 4 (770 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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.