Debug Start Problem

Debug Start Problem

stefano.cartaKGT96
Advocate Advocate
937 Views
6 Replies
Message 1 of 7

Debug Start Problem

stefano.cartaKGT96
Advocate
Advocate

Hi Guys, 
I am trying to debug a plug-in, but during the revit opening, I receive this exception:

The Application is in break mode

"System.ExecutionEngineException"

 

I have to set some option?
The "Native code" and "Use managed Compatibility mode" are disabled

 

0 Likes
Accepted solutions (1)
938 Views
6 Replies
Replies (6)
Message 2 of 7

RPTHOMAS108
Mentor
Mentor

Revit Version?

Visual Studio Version?

x64 set?

 

That exception is quite broad can range from something as innocuous as wrong debug settings to anything really. Last time I got it was with P/Invoke.

 

Apparently the exception itself is also obsolete.

 

On newer Revit versions you don't have to use managed compatibility mode, on older versions you do. Previous threads that exist here will aid you in finding the best settings to use for Revit/VS version combinations.

0 Likes
Message 3 of 7

stefano.cartaKGT96
Advocate
Advocate
Hi..Revit 2020 and VisualStudio 2019
0 Likes
Message 4 of 7

RPTHOMAS108
Mentor
Mentor

I'm not using managed compatibility mode on that.

 

If you share a small cut down version of your solution file I can look at it, otherwise these things become like a game of 20 questions.

 

In the meantime check out this expertly stitched together image of my settings:

210301.png

0 Likes
Message 5 of 7

stefano.cartaKGT96
Advocate
Advocate

Hi  and thanks for your replay..

My plug-in was created for Revit 2018 and now I would convert it to use with 2020 version.

...

so I decided to make a last try with a new empty project.

I used the Revit 2020 wizard for create a new project. with the below standard module:

When I start debug, Revit splash screen start and after I receive the Exception error..

so I think that the problem is in some setting and not in code....

I try it with 2021 and revit start correctly...I have to try it on other pc wih Revit 2020

#Region "Imported Namespaces"
Imports System
Imports System.Collections.Generic
Imports Autodesk.Revit.ApplicationServices
Imports Autodesk.Revit.Attributes
Imports Autodesk.Revit.DB
Imports Autodesk.Revit.UI
Imports Autodesk.Revit.UI.Selection
#End Region

<Transaction(TransactionMode.Manual)>
Public Class AdskCommand
    Implements IExternalCommand

    ''' <summary>
    ''' The one and only method required by the IExternalCommand interface, the main entry point for every external command.
    ''' </summary>
    ''' <param name="commandData">Input argument providing access to the Revit application, its documents and their properties.</param>
    ''' <param name="message">Return argument to display a message to the user in case of error if Result is not Succeeded.</param>
    ''' <param name="elements">Return argument to highlight elements on the graphics screen if Result is not Succeeded.</param>
    ''' <returns>Cancelled, Failed or Succeeded Result code.</returns>
    Public Function Execute(
      ByVal commandData As ExternalCommandData,
      ByRef message As String,
      ByVal elements As ElementSet) _
    As Result Implements IExternalCommand.Execute

        Dim uiapp As UIApplication = commandData.Application
        Dim uidoc As UIDocument = uiapp.ActiveUIDocument
        Dim app As Application = uiapp.Application
        Dim doc As Document = uidoc.Document

        Dim sel As Selection = uidoc.Selection

        'TODO: Add your code here

        Using tx As New Transaction(doc)
            tx.Start("Revit")
            tx.Commit()
        End Using

        'Must return some code
        Return Result.Succeeded
    End Function
End Class
#Region "Imported Namespaces"
Imports Autodesk.Revit.ApplicationServices
Imports Autodesk.Revit.Attributes
Imports Autodesk.Revit.DB
Imports Autodesk.Revit.UI
#End Region

Class AdskApplication
    Implements IExternalApplication
    ''' <summary>
    ''' This method is called when Revit starts up before a 
    ''' document or default template is actually loaded.
    ''' </summary>
    ''' <param name="app">An object passed to the external 
    ''' application which contains the controlled application.</param>
    ''' <returns>Return the status of the external application. 
    ''' A result of Succeeded means that the external application started successfully. 
    ''' Cancelled can be used to signify a problem. If so, Revit informs the user that 
    ''' the external application failed to load and releases the internal reference.
    ''' </returns>
    Public Function OnStartup(
      ByVal app As UIControlledApplication) _
    As Result Implements IExternalApplication.OnStartup

        'TODO: Add your code here

        'Must return some code
        Return Result.Succeeded
    End Function

    ''' <summary>
    ''' This method is called when Revit is about to exit.
    ''' All documents are closed before this method is called.
    ''' </summary>
    ''' <param name="app">An object passed to the external 
    ''' application which contains the controlled application.</param>
    ''' <returns>Return the status of the external application. 
    ''' A result of Succeeded means that the external application successfully shutdown. 
    ''' Cancelled can be used to signify that the user cancelled the external operation 
    ''' at some point. If false is returned then the Revit user should be warned of the 
    ''' failure of the external application to shut down correctly.</returns>
    Public Function OnShutdown(
      ByVal app As UIControlledApplication) _
    As Result Implements IExternalApplication.OnShutdown

        'TODO: Add your code here

        'Must return some code
        Return Result.Succeeded
    End Function
End Class

 

0 Likes
Message 6 of 7

RPTHOMAS108
Mentor
Mentor
Accepted solution

Yes it is more likely the settings, the references or runtime version etc.

 

I'm not familiar with those Wizards, I recall someone mentioning an issue with REX at some point in the past and that was fixed I believe. May still be an issue for projects based on historic templates however (not sure).

0 Likes
Message 7 of 7

stefano.cartaKGT96
Advocate
Advocate

Thanks..I try it with 2021 and debug work fine..

 

Stefano

0 Likes