Visual studio 2015 and .NET 4.6.1 debugging problem

Visual studio 2015 and .NET 4.6.1 debugging problem

Anonymous
Not applicable
5,942 Views
15 Replies
Message 1 of 16

Visual studio 2015 and .NET 4.6.1 debugging problem

Anonymous
Not applicable

So im trying to debug with Visual studio 2015 and .NET 4.6.1.

 

When i set a conditional break point . For example element.Name.Contains("foo"); i get the following error when the code hits the line:

 

---------------------------
Microsoft Visual Studio
---------------------------
The condition for a breakpoint failed to execute. The condition was 'e.Id.IntegerValue != 397718'. The error returned was 'The metadata for 'RevitAPI' is invalid. If you are debugging a minidump, you may be able to fix this problem by collecting a new minidump with heap and evaluating the expression again.'. Click OK to stop at this breakpoint.
---------------------------
OK   
---------------------------

I used the checkbox "Enable native code debugging" in the Visual studio debug settings for the project. Any help would be appriciated.

5,943 Views
15 Replies
Replies (15)
Message 2 of 16

Mustafa.Salaheldin
Collaborator
Collaborator

It seems like your break point has the following condition "e.Id.IntegerValue != 397718" in the wrong place, so from the editor pane right click on the break point that causes the error then from the popup menu select Condition.

Break Point condition.png

Then you can simply either uncheck the Condition checkbox or just delete the condition from the textbox and press OK.

Condition.PNG

 

Please if this reply satisfies your needs mark it as an answer.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 3 of 16

Anonymous
Not applicable

Well the thing is that this condition is not in the wrong place, it's just a breakpoint condition i want to use, so disabling it is not really a fix. I see you are using visual studio 2013, this issue happens with 2015

0 Likes
Message 4 of 16

Mustafa.Salaheldin
Collaborator
Collaborator

The version of VS is not the issue. Can you please provide the code of the line raising the error and the condition?


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 5 of 16

Anonymous
Not applicable

it does not matter where i put the condition.

 

This only happens when i set a conditional breakpoint for revit api objects.

0 Likes
Message 6 of 16

Anonymous
Not applicable

bump

0 Likes
Message 7 of 16

matthew_taylor
Advisor
Advisor

Have you checked out the Modules window in Visual Studio? It allows you to see where your symbols are being loaded from (if at all), their versions etc.


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes
Message 8 of 16

Anonymous
Not applicable

When browsing trough the modules i see RevitAPI.dll with the following messages.

 

RevitAPI.dll M:\software\Autodesk\revit2017-2\Revit 2017\RevitAPI.dll Yes No Cannot find or open the PDB file. 36 17.00.1081.0 6-10-2016 9:59 00007FF97F5D0000-00007FF980F37000 [113364] Revit.exe [1] DefaultDomain
RevitAPI.dll M:\software\Autodesk\revit2017-2\Revit 2017\RevitAPI.dll N/A Yes Cannot find or open the PDB file. 396 17.00.1081.0 6-10-2016 9:59 00007FF97F5D0000-00007FF980F37000 [113364] Revit.exe
RevitAPI.dll M:\software\Autodesk\revit2017-2\Revit 2017\RevitAPI.dll N/A Yes Cannot find or open the PDB file. 417 17.00.1081.0 6-10-2016 9:59 00000286FB9F0000-00000286FD357000* [113364] Revit.exe

 

0 Likes
Message 9 of 16

matthew_taylor
Advisor
Advisor

I think you should be looking for your module - that is the one you want to debug, right?

Do you have your software actually installed at that location on your M drive? Because if not, that could be your issue. You need to reference the actual Revit API dlls that Revit is using (in the program files folder).


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes
Message 10 of 16

Anonymous
Not applicable

Yes i am trying to debug my own module, but it fails when i use Revit objects.

 

I have everything installed at that M: path so the Revit API dll is there.

 

This is what i get when i look at my module:

 

Kopersportaal.dll M:\files\dev\revit\builds\debug\kopersportaal\Kopersportaal.dll No Yes Symbols loaded. M:\files\dev\revit\builds\debug\kopersportaal\Kopersportaal.pdb 155 1.00.0.0 10-11-2016 9:28 00000286830E0000-0000028683142000 [113364] Revit.exe [1] DefaultDomain
Kopersportaal.dll M:\files\dev\revit\builds\debug\kopersportaal\Kopersportaal.dll N/A Yes Native debugger skipped loading symbols for managed module. 687 1.00.0.0 10-11-2016 9:28 00000286830E0000-0000028683142000* [113364] Revit.exe

0 Likes
Message 11 of 16

matthew_taylor
Advisor
Advisor

Have you created a basic addin from scratch to see if it's something to do with your addin?

 

Make sure you've cleaned and rebuilt your solution, and check out the build location to see if any dll/pdbs other than Kopersportaal are there. If so, try deleting them before debugging.

 

I've found issues with this, and I'm not sure what's causing them (the Add-in Manager?), but what worked for me was when I attached the debugger to the Revit.exe process, I changed the settings as shown in the image.

 

 

If that doesn't work for you, you're going to have to provide a lot more information about what your processes and (VS) settings are. Are you using the addin manager? What are all of your VS debug settings? Can you provide an example solution?


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes
Message 12 of 16

matthew_taylor
Advisor
Advisor

Oh, and according to the Revit 2017 API docs:

"Revit's binaries are built using .NET 4.5.2. However, Revit uses the runtime from .NET 4.6. At a minimum, add-ons will need to target .NET 4.5.2, but .NET 4.6 will also work."

 

Try 4.6 and see if that helps.


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes
Message 13 of 16

Anonymous
Not applicable

havent tried attaching to the process

0 Likes
Message 14 of 16

FRFR1426
Collaborator
Collaborator

You have to switch to the Managed Compatibility Mode to use conditional breakpoints. It's because the Revit DLLs API are using Managed C++ and this language provides its own expression evaluator. This is not supported by the current Visual Studio debug engine so you have to use the legacy one.

 

To switch to Managed Compatibility Mode, go to Tools, Options and in the Debugging, General page, you will find a checkbox "Use Managed Compatibility Mode".

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
Message 15 of 16

FRFR1426
Collaborator
Collaborator

You can also use "Use the legacy C# and VB expression evaluators" instead of "Use Managed Compatibility Mode"

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
Message 16 of 16

tbaloghCMT2Y
Explorer
Explorer

I bumped into the same issue and your suggestions worked, thanks Maxence! 

0 Likes