.NET

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

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

716 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?

*Expert Elite*
GTVic
Posts: 906
Registered: ‎09-07-2004
Message 2 of 4 (712 Views)
*Expert Elite*
chiefbraincloud
Posts: 752
Registered: ‎02-13-2008
Message 3 of 4 (699 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 (681 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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
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 to get help installing your software.

Ask the Community