2016-09-13 6 views
0

일부 응용 프로그램에는 일부 autocad 기능이 필요합니다. 그래서 독립형 응용 프로그램을 인터넷에서 시도했지만 아무것도 일어나지 않고 항상 오류를 반환합니다. (그것은 열어 사전 설치된 AutoCAD를 플러그인 뭔가를 그릴되지 않음) 내 첫 번째 시도 :독립 실행 형 autocad .net 응용 프로그램을 만드는 방법

AcadApplication gbl_app = new AcadApplication(); 
AcadDocument gbl_doc = gbl_app.ActiveDocument; 
gbl_app.Application.Visible = true; 

을 그리고 이것은 첫 번째 줄에 올릴 오류입니다.

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in SBDesign.exe 

Additional information: 
Retrieving the COM class factory for component with CLSID {0D327DA6-B4DF-4842-B833-2CFF84F0948F} 
failed due to the following error: 80040154 
Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). 

내 두 번째 시도 :

AcadApplication acAppComObj = null; 
      const string strProgId = "AutoCAD.Application.20"; 

      // Get a running instance of AutoCAD 
      try 
      { 
       acAppComObj = (AcadApplication)Marshal.GetActiveObject(strProgId); 
      } 
      catch // An error occurs if no instance is running 
      { 
       try 
       { 
        // Create a new instance of AutoCAD 
        acAppComObj = (AcadApplication)Activator.CreateInstance(Type.GetTypeFromProgID(strProgId), true); 
       } 
       catch(Exception er) 
       { 
        // If an instance of AutoCAD is not created then message and exit 
        System.Windows.Forms.MessageBox.Show("Instance of 'AutoCAD.Application'" + 
                 " could not be created."); 

        return; 
       } 
      } 

      // Display the application and return the name and version 
      acAppComObj.Visible = true; 
      System.Windows.Forms.MessageBox.Show("Now running " + acAppComObj.Name + 
               " version " + acAppComObj.Version); 

그리고이 오류입니다 :

Unable to cast COM object of type 'System.__ComObject' to interface type 'Autodesk.AutoCAD.Interop.AcadApplication'. 
This operation failed because the QueryInterface call on the COM component for 
the interface with IID '{10E73D12-A037-47E5-8464-9B0716BE3990}' 
failed due to the following error: 
No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). 

그래서 정말 내가 독립 실행 형 응용 프로그램을 만들 수있는 방법?

+0

"AutoCAD.Application.20"은 AutoCAD 2015 및 2016에서만 작동합니다. "AutoCAD.Application"을 사용하여 AutoCAD 버전 (LT 제외)을 대상으로 해보십시오. – gileCAD

+0

"AutoCAD.Application"을 사용할 때 아무 일도 일어나지 않습니다. AutoCAD가 2015입니다. –

+0

@gileCAD "AutoCAD.Application"을 시도했지만 "AutoCAD.Application.20"과 동일한 오류가 발생합니다. –

답변

0

IID {10E73D12-A037-47E5-8464-9B0716BE3990}이 제대로 설치되지 않은 것 같다의 AutoCAD 2017 AcadApplication의 IID입니다 a.h 감사드립니다.

ProgId : AutoCAD.Application.20을 사용하고 참조 용으로 Autodesk.AutoCAD.Interop.dll 및 Autodesk.AutoCAD.Interop.Common.dll 20.0.51.0을 사용하여 AutoCAD 2015 설치를 사용해야합니다. 실제로 21.0.52.0 (AutoCAD 2017)을 사용하고 있다고 생각합니다.

+0

안녕하세요. 답해 주셔서 감사합니다. 내 COM 참조는 20.0.51.0.0이지만 내 Autodesk.AutoCAD.Interop.common.dll은 21.0.0.0입니다. 내 [ScreenShot] (https://1drv.ms/i/s!ApRBiX7lvlBibweEWHo3Uaj0M-k)을 살펴보십시오. 그래서 어디에서 20.0.51.0을 얻을 수 있습니까? –

+0

_ 감사합니다 !!!!! 너 해결 했어. 죄송합니다. 투표가 안되면 내 평판이 15 점 미만 이니까요. 정말로 저는 희망이 없으며 많은 답변을 기다리고있었습니다. 하지만 당신은 남자를 비난합니다. 내 문제가있는 사람들을 위해 Autodesk.AutoCAD.Interop.Common.dll은 autocad와 동일한 버전이어야하므로'DRIVE : \ Program Files \ Autodesk \ AutoCAD 2015 \ Autodesk.AutoCAD.Interop.Common .dll'과'DRIVE : ₩ Program Files ₩ Autodesk ₩ AutoCAD 2015 ₩ Autodesk.AutoCAD.Interop.dll' 디렉토리에 있습니다. 그리고 모든 것이 지금 작동합니다. !!!! –

+0

내 IDE는 항상 잘못된 버전의 참조를 추가 했으므로 새 프로젝트를 만들고 새로운 코드로 전체 코드를 복사하기로 결정했습니다. 모든 것이 작동합니다 !!!!! –