.NET

Reply
Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 11 of 30 (439 Views)

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

Valued Contributor
tonofsteel
Posts: 93
Registered: ‎12-04-2009
Message 12 of 30 (435 Views)

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.....

 

 

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 13 of 30 (434 Views)

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...

Valued Contributor
tonofsteel
Posts: 93
Registered: ‎12-04-2009
Message 14 of 30 (430 Views)

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.

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 15 of 30 (425 Views)

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

Valued Contributor
tonofsteel
Posts: 93
Registered: ‎12-04-2009
Message 16 of 30 (418 Views)

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?

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 17 of 30 (413 Views)

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()

Valued Contributor
tonofsteel
Posts: 93
Registered: ‎12-04-2009
Message 18 of 30 (409 Views)

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

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 19 of 30 (403 Views)

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?

Valued Contributor
tonofsteel
Posts: 93
Registered: ‎12-04-2009
Message 20 of 30 (401 Views)

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.

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 or visit the Installation and Licensing Forum to get help installing your software.