• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Active Contributor
    Posts: 42
    Registered: ‎09-05-2012

    Re: Catastrophic failure HRESULT: 0x8000FFFF (E_UNEXPECTED)

    01-29-2013 12:07 PM in reply to: tonofsteel

    When you say "crashes" what do you mean?!  It goes away or just throws some exception.  If the latter what does it say?!  Also, you should be using the one that comes with VS

     

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\WcfTestClient.exe

     

    If that's crashing you have an Visual Studio installation issue.

     

    Also make sure the cmd window you are using to launch WcfTestClient.exe knows about the correct .NET path.  Mine is

     

    C:\Windows\Microsoft.NET\Framework64\v4.0.30319

    Please use plain text.
    Valued Contributor
    Posts: 78
    Registered: ‎12-04-2009

    Re: Catastrophic failure HRESULT: 0x8000FFFF (E_UNEXPECTED)

    01-29-2013 12:17 PM in reply to: tonofsteel

    I get the Exception: Object reference not set to an instance of an object

     

    ************** Exception Text **************
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.Tools.Common.SdkPathUtility.GetRegistryValue(String registryPath, String registryValueName)
       at Microsoft.Tools.Common.SdkPathUtility.GetSdkPath(Version targetFrameworkVersion)
       at Microsoft.Tools.TestClient.ToolingEnvironment.get_MetadataTool()

     

    etc.....

     

     

    Please use plain text.
    Active Contributor
    Posts: 42
    Registered: ‎09-05-2012

    Re: Catastrophic failure HRESULT: 0x8000FFFF (E_UNEXPECTED)

    01-29-2013 12:20 PM in reply to: tonofsteel

    Ok, I don't know.  But good thing you can at least see it with WCFStorm.  The weird stuff is when you add that SendCommand I posted above.  That invokes the DOSELECTION command that works when invoked from the command line and still results in the same exact error on the same line of code when called through wcf SendCommand...

    Please use plain text.
    Valued Contributor
    Posts: 78
    Registered: ‎12-04-2009

    Re: Catastrophic failure HRESULT: 0x8000FFFF (E_UNEXPECTED)

    01-29-2013 12:28 PM in reply to: sszabo

    This works for me:

     

     Public Sub DoSelection()
            Try
                activeDoc = MgdAcApplication.DocumentManager.MdiActiveDocument
                Using acDocLck As DocumentLock = activeDoc.LockDocument()
                    Dim td As AcadDocument = DocumentExtension.GetAcadDocument(activeDoc)
                    Dim ssetObj As AcadSelectionSet = td.SelectionSets.Add("SSALL0")   ' creates named selection set
                    ssetObj.Select(AcSelect.acSelectionSetAll)
                    log.Trace("We have a selection of size = {0}", ssetObj.Count)
                    activeDoc.Editor.WriteMessage("We have a selection of size = {0}", ssetObj.Count)
                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("We have a selection of size = " & ssetObj.Count.ToString())
                    Try
                        For Each ent As AcadEntity In ssetObj
                            log.Trace("{0}", ent.ObjectName)
                        Next
                    Catch
                        log.Error("This is the crash: '{0}'", Err.Description)
                    End Try
                End Using
            Catch
                log.Error(Err.Description)
            End Try
    
        End Sub

     

    At the beginning right after try I added this line:

     

    activeDoc = MgdAcApplication.DocumentManager.MdiActiveDocument

    When you step through the code it looks like active document is alright, but this class gets instantiated by the WCF system and when this property is initialized something is not connecting properly. 

     

    To ensure this is working on the current active document maybe this should be a method instead of a property so it always checks and returns the active document?

     

    Results:

     

    2013-01-29 14:22:03.3589 INFO Listening on http://127.0.0.1:7200/ISelectItems
    2013-01-29 14:22:18.6964 INFO This will crash
    2013-01-29 14:22:18.7094 TRACE We have a selection of size = 13
    2013-01-29 14:22:21.1977 TRACE AcDbLine
    2013-01-29 14:22:21.1977 TRACE AcDbLine
    2013-01-29 14:22:21.1977 TRACE AcDbLine
    2013-01-29 14:22:21.1977 TRACE AcDbLine
    2013-01-29 14:22:21.1977 TRACE AcDbLine
    2013-01-29 14:22:21.1977 TRACE AcDbLine
    2013-01-29 14:22:21.1977 TRACE AcDbLine
    2013-01-29 14:22:21.1977 TRACE AcDbLine
    2013-01-29 14:22:21.1977 TRACE AcDbLine
    2013-01-29 14:22:21.1977 TRACE AcDbLine
    2013-01-29 14:22:21.1977 TRACE AcDbLine
    2013-01-29 14:22:21.1977 TRACE AcDbLine
    2013-01-29 14:22:21.1977 TRACE AcDbLine

     

    I think the difference is because the Initialize plugin method is run by AutoCAD so when the current document is set it is correct.  The WCF deals with the wcfSelectItems class and when this class is created it is not in the same context as when AutoCAD loads the plugin class.

    Please use plain text.
    Active Contributor
    Posts: 42
    Registered: ‎09-05-2012

    Re: Catastrophic failure HRESULT: 0x8000FFFF (E_UNEXPECTED)

    01-29-2013 01:39 PM in reply to: tonofsteel

    I tried this solution but I think you are right somehow I have to force autocad to activate the current document.  If I make the change you are suggesting I get a Object reference not set to an instance of an object.  I also tried to make it a function that returns the document: same result.

     

        Private Function activeDoc() As Document
            Return MgdAcApplication.DocumentManager.MdiActiveDocument
        End Function

    Please use plain text.
    Valued Contributor
    Posts: 78
    Registered: ‎12-04-2009

    Re: Catastrophic failure HRESULT: 0x8000FFFF (E_UNEXPECTED)

    01-29-2013 01:50 PM in reply to: sszabo

    Which line does the exception get thrown on?

    Please use plain text.
    Active Contributor
    Posts: 42
    Registered: ‎09-05-2012

    Re: Catastrophic failure HRESULT: 0x8000FFFF (E_UNEXPECTED)

    01-29-2013 01:57 PM in reply to: tonofsteel

        Public Sub DoSelection()
            Try
                Dim activeDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
                Using acDocLck As DocumentLock = activeDoc.LockDocument()

    Please use plain text.
    Valued Contributor
    Posts: 78
    Registered: ‎12-04-2009

    Re: Catastrophic failure HRESULT: 0x8000FFFF (E_UNEXPECTED)

    01-29-2013 02:00 PM in reply to: sszabo

    Is there any difference if you leave your property how you originally had it and change the line line after try to:

    activeDoc = MgdAcApplication.DocumentManager.MdiActiveDocument

     

    My code works if I take your original sample and just add this one line,  I still have the property in my code exactly how you had yours in the first post, I just update the activeDoc at the start of the method just after try

    Please use plain text.
    Active Contributor
    Posts: 42
    Registered: ‎09-05-2012

    Re: Catastrophic failure HRESULT: 0x8000FFFF (E_UNEXPECTED)

    01-29-2013 02:06 PM in reply to: tonofsteel

    Yes, I tried that too.  Do you have ACAD 2013?

    Please use plain text.
    Valued Contributor
    Posts: 78
    Registered: ‎12-04-2009

    Re: Catastrophic failure HRESULT: 0x8000FFFF (E_UNEXPECTED)

    01-29-2013 02:10 PM in reply to: sszabo

    I have AutoCAD Electrical 2013, but should work the same for this example.  I am attaching my project that works.

    Please use plain text.