# The xml2skp sample crashes SketchUp 2020

I am using the SDK_WIN_x64_2020-1-229 version of the SketchUp SDK. I followed the instructions in the read me file…

1. Open xmlimporter.vcxproj
2. Change configuration to Debug x64 or Release x64 (recommended: Release x64)
3. Build (using VS2015 community version with the v140 toolset)
next i followed these instructions to deploy the dll
4. Go to C:\path\to\xml_to_skp\win\Release_64
5. Copy/paste xml2skp.dll into C:\Program Files\SketchUp\SketchUp 2019\Importers
6. Open SketchUp 2019.
7. Go to File -> Import.
8. Choose “XML Importer (*.xml)” as your file type.
9. Click on your xml file and click Import.

SketchUp crashes a soon as I select the Import command.

Any advice as to how to make it work will be most gratefully received.
Ken

You might check the official issue tracker .with filter for “C API” …

Thank you Dan for pointing that out. I could not find any relevant cases. Should I add it as a new issue?

Many Thanks
Ken

Except that the main page (in the SDK “documentation” subfolder) for SketchUp 2020 API (ver 8.x)
[which is also the main page for the online C API documentation,] … says …

The C API library for Windows is built using Microsoft Visual Studio 2019 (v142). It includes only 64-bit binaries. Building and releasing an application using the SketchUp C API for Windows requires including SketchUpAPI.dll and SketchUpCommonPreferences.dll, which can be found in the SketchUp C SDK for Windows. Also, the following C runtime DLLs must be included: msvcp140.dll and msvcr140.dll. Due to Microsoft binary compatability, the runtime DLLs remain named "-v140.dll"

… and further down …

Using a different Platform Toolset will likely cause the plugin to fail to load and cause SketchUp to crash.

So, no (before opening a new issue) … I’d first suggest setting getting a newer VS version and trying again, or try your import plugin in SketchUp 2019.

Besides … I already opened several documentation issues for those old docs in the C SDK. ie …

I would guess that you are compiling in “Debug” mode (opposed to “Release” mode). The
“Debug”-compiled code WILL crash Sketchup the moment you select the Import command.
Compile as “Release” and you will be good.
This has been discussed previously on the forum (although some years ago).

1 Like

Just for the record, I have been using Visual Studio 2019 and toolset v142 for my own Sketchup importers with no particular problems.

1 Like

Thank you Dan and JoNos for your suggestions. I tried them and still get same result SketchUp crashes when I select the Import menu.

Maybe the problem lies in the xml_to_skp code?

Many thanks,
Ken

The only times I have seen this particular behavior - crashing when selecting the Import command, has been caused by incorrectly applying “Debug” mode.
However, I guess there could be other causes out there…
For mywself, I have used SDK_WIN_x64_2019-3-253 and SDK_WIN_x64_2020-0-363 without issues, I am not sure if there are newer versions available…

looking at the call stack after the crash suggests that it is related to when SketchUp is displaying the file selection dialog. If I just force it to continue when an exception occurs it eventually shows the dialog and I can select and import the xml file.

> ntdll.dll!RtlReportCriticalFailure() Unknown
ntdll.dll!RtlpHeapHandleError() Unknown
ntdll.dll!RtlpHpHeapHandleError() Unknown
ntdll.dll!RtlpLogHeapFailure() Unknown
ntdll.dll!RtlpFreeHeapInternal() Unknown
ntdll.dll!RtlFreeHeap() Unknown
ucrtbase.dll!_free_base() Unknown
SketchUp.exe!00007ff60c60e269() Unknown
SketchUp.exe!00007ff60c60e621() Unknown
SketchUp.exe!00007ff60c60c491() Unknown
SketchUp.exe!00007ff60c60c223() Unknown
SketchUp.exe!00007ff60c194c17() Unknown
mfc140u.dll!00007ff9e8ac51cb() Unknown
SketchUp.exe!00007ff60c1f07c8() Unknown
mfc140u.dll!00007ff9e8b87241() Unknown
mfc140u.dll!00007ff9e894a342() Unknown
SketchUp.exe!00007ff60c1aa25d() Unknown
mfc140u.dll!00007ff9e8b769e5() Unknown
mfc140u.dll!00007ff9e8b860be() Unknown
mfc140u.dll!00007ff9e8949190() Unknown
mfc140u.dll!00007ff9e8b75c10() Unknown
mfc140u.dll!00007ff9e8b75b6f() Unknown
mfc140u.dll!00007ff9e8b73453() Unknown
mfc140u.dll!00007ff9e8b73824() Unknown
mfc140u.dll!00007ff9e8a18cc9() Unknown
user32.dll!UserCallWinProcCheckWow() Unknown
user32.dll!DispatchMessageWorker() Unknown
mfc140u.dll!00007ff9e8b5c0f2() Unknown
mfc140u.dll!00007ff9e8b5c9f5() Unknown
SketchUp.exe!00007ff60c1f3272() Unknown
mfc140u.dll!00007ff9e8b8f580() Unknown
SketchUp.exe!00007ff60c800272() Unknown

Just to chime in - I have the very same problem with the same exact call stack when it crashes. I am compiling with Platform Toolset Visual Studio 2019 (v142) and Windows Platform SDK 8.1 (Also tried with Platform SDK 10.0 but ended up in the same place). I haven’t tried SketchUp 2019 though…has anyone else come across the same issue and resolved it? it sounds like a bug in the sample code not being compatible with 2020 IMO…

just tried with SketchUp 2019.3 - and the same thing happens…::curses

JoNos, Dan, any comments or ideas.

No ideas. @thomthom ?

FWIW, just as a check I took one of my own importers and recompiled it using the very latest Visual Studio 2019 (v142). I use Windows SDK version 10.0.
Interestingly, after applying the very latest Visual Studio 2019 upgrades, my code did not directly compile anymore, so I had to add some #includes which were not necessary before…
Anyway, after dropping the recompiled dll into the Importers directory, the importer still operated as expected.

In this particular case I am still using the SDK_WIN_x64_2019-3-253 (I have not upgraded that solution to use SDK_WIN_x64_2020-0-363 yet, I guess it will work, but I do not know with certainty).
I am working within Windows 10 Version 1903.

I am still using the Sketchup version 20.0.373 as the later versions gave me serious problems. These Sketchup problems have been discussed on the forum, they might have been fixed by now, but I have not taken the time to check this.

I have not taken the (latest?) xml_to_skp code, so I do not know how this behave. It is summer vacation now so I am just occasionally within reach of my computer…

Updated:
I updated to Sketchup 20.1.235 on another machine (I will not change from 20.0.373 on my main machine without some serious testing).
Dropping my own recently recompiled importer to this machine works nicely as well.

Updated again:
Recompiling and linking my own importer with SDK_WIN_x64_2020-0-363 appears to give no problems as well.
Oddity: On Sketchup’s SDK page (https://extensions.sketchup.com/sketchup-sdk) they refer to the latest Windows SDK version as 20.0.362. Well, the minor version I have is 363 (not 362).
Maybe just a typing error on the SDK page?

Ok - some progress on my end trying to make this work…

I am using Windows 10 - build 1803. VS 2019, Windows SDK Platform 8.1, Platform Toolset VS 2019 (v142), SketchUp 2020.1.235.

I didn’t need to change the include path to resolve the include files.
I can compile successfully. When I run SketchUp on its own and select “import…” it crashes.
When I run SketchUp with the VS Debugger or even attaching to the debugger to the SketchUp process, I can select “Import…”, and the Debugger traps the exception with the call stack listed above. I can then hit F5 and continue - which hits another exception for which I can also continue and with F5 to then get the File Dialog to pop up and successfully load a .xml previously generated by the other skp_2_xml sample. I hope this helps some as clearly, attaching the debugger allows to get forward but either a race condition or something else is at play here…
Note: I also tried with Windows Platform SDK 10 and the same behavior can be observed (as a mean to rule out any dependency on 10 vs 8.1)

I know. Please be aware that I am in the process of updating one of my own importers (not the sample xml-to-skp code).

I currently build on top of a CPP wrapper.

But all this stuff was built based on the sample xml-to-skp code many years ago…

worth noting that a Debug build and associated Debugger session fails to publish the .xml as a valid file to import. I haven’t pinpointed where the plugin fails though

Please note that a Debug version of the DLL will crash. You need to compile the DLL as Release.

BTW: I observe now that there exists a still newer version of the Sketchup SDK (SDK_WIN_x64_2020-1-229) which I have never tried so far…

EDIT, yes a typo. These versions are the application release version/build numbers.
Ie, they are incorrectly swapped, .363 was the Windows build, .362 was the MacOS build.

The C SDK (API) has it’s own version release numbers.
(It is listed in the “version.txt” file in the root of the SDK package.)
The latest public C API release is …
2020 April 23: API Version 8.1 - SketchUp 2020.1

Also there is a C API function to return the API version you are using …
SUGetAPIVersion() in file: "initialize.h"

This is distinct from SUGetVersionStringUtf8() which is the application version you referenced and is only exported by the SketchUp executable.

I am using the SketchUp SDK 229.
i don’t understand why anyone would ship an SDK Sample that can’t be debugged in Debug - this raises a lot of question about the quality of the sample IMO.