.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
schesser
2540 Views, 3 Replies

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

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?

3 REPLIES 3
Message 3 of 4
chiefbraincloud
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
Message 4 of 4
schesser
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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost