<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Exception in GSNew.hpp (operator delete) in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/635309#M9882</link>
    <description>&lt;P&gt;I tried several ways, none of them worked.&lt;/P&gt;</description>
    <pubDate>Fri, 11 Oct 2024 06:21:32 GMT</pubDate>
    <dc:creator>torokze</dc:creator>
    <dc:date>2024-10-11T06:21:32Z</dc:date>
    <item>
      <title>Exception in GSNew.hpp (operator delete)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/634739#M9863</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;During the adaptation of our addon to the new Archicad 28 Windows, an exception occurs in the function below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;inline void CCALL operator delete (void *p) noexcept
{
	GS::MemoryManager::Free (p);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;It's a simple std::string deallocation. The string contains valid data.&lt;/P&gt;&lt;P&gt;This exception occurs in Release mode build only, the Debug build runs flawlessly just like the Archicad 26/27 version of the addon. The exception occurs in Archicad 28 Release build only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have&lt;/P&gt;&lt;P&gt;- Addon.apx&lt;/P&gt;&lt;P&gt;- Addon.Login.CLR.dll (CLR Bridge)&lt;/P&gt;&lt;P&gt;- Addon.WebView.dll (.NET)&lt;/P&gt;&lt;P&gt;The addon displays a login window (.NET) through the CLR and converts a managed string to std::string as return value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="torokze_0-1728313656052.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/77818i8AC164902A2B0CDA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="torokze_0-1728313656052.png" alt="torokze_0-1728313656052.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="torokze_1-1728313738462.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/77819iEFC8E2838924B9F1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="torokze_1-1728313738462.png" alt="torokze_1-1728313738462.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Zoltan&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 06:30:34 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/634739#M9863</guid>
      <dc:creator>torokze</dc:creator>
      <dc:date>2024-10-08T06:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: Exception in GSNew.hpp (operator delete)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/634776#M9864</link>
      <description>&lt;P&gt;Uff, that's a tough one.&lt;BR /&gt;Do you get more info from debugging when compiling in Release mode with debug symbols?&lt;BR /&gt;Maybe you can also share the string conversion function for us to take a look.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 09:31:46 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/634776#M9864</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2024-10-08T09:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Exception in GSNew.hpp (operator delete)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/634806#M9867</link>
      <description>&lt;P&gt;This is Release mode with debug symbols already.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;std::string ManagedStringToUTF8String(System::String^ in)
{
    if (!System::String::IsNullOrEmpty(in))
    {
        //std::string str = msclr::interop::marshal_as&amp;lt;std::string&amp;gt;(in); // Don't use this.

        array&amp;lt;Byte&amp;gt;^ bytes = Encoding::UTF8-&amp;gt;GetBytes(in);

        pin_ptr&amp;lt;Byte&amp;gt; pinnedBytes = &amp;amp;bytes[0];

        std::string str(reinterpret_cast&amp;lt;char*&amp;gt;(pinnedBytes));

        return str;
    }

    return "";
}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 08 Oct 2024 12:33:49 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/634806#M9867</guid>
      <dc:creator>torokze</dc:creator>
      <dc:date>2024-10-08T12:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Exception in GSNew.hpp (operator delete)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/634807#M9868</link>
      <description>&lt;P&gt;I see, so then my first guess is that it's due to the optimization for Release builds.&lt;BR /&gt;You can try /Od or wrap the function (or parts of it) in&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;#pragma optimize("", off)
...
#pragma optimize("", on)&lt;/LI-CODE&gt;
&lt;P&gt;as suggested here:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/24664865/preventing-the-optimizer-from-optimizing-a-variable-away-in-visual-studio/71844643#71844643" target="_blank"&gt;https://stackoverflow.com/questions/24664865/preventing-the-optimizer-from-optimizing-a-variable-away-in-visual-studio/71844643#71844643&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 12:58:31 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/634807#M9868</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2024-10-08T12:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Exception in GSNew.hpp (operator delete)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/634873#M9873</link>
      <description>&lt;P&gt;I use msclr::interop::marshal_as&amp;lt;std::string&amp;gt;(str) in similar cases, but for .net APIs like Revit. I see you've commented "Don't use this" - was there a problem?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 21:17:54 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/634873#M9873</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2024-10-08T21:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Exception in GSNew.hpp (operator delete)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/635309#M9882</link>
      <description>&lt;P&gt;I tried several ways, none of them worked.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2024 06:21:32 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/635309#M9882</guid>
      <dc:creator>torokze</dc:creator>
      <dc:date>2024-10-11T06:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Exception in GSNew.hpp (operator delete)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/635310#M9883</link>
      <description>&lt;P&gt;I don't know the reason, it's the work of another developer who no longer works for us.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2024 06:23:51 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/635310#M9883</guid>
      <dc:creator>torokze</dc:creator>
      <dc:date>2024-10-11T06:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Exception in GSNew.hpp (operator delete)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/635319#M9884</link>
      <description>&lt;P&gt;Is there a compelling reason use .net for an Archicad add-on? You are almost certain to hit a significant number of technical issues trying to use this outside a .net context. I recommend either writing everything using the Archicad API and native OS API in C++ (without .net) or writing an independent .net application and talking to an Archicad add-on using the http interface (or similar). Then you don't have to struggle with mixing platforms.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2024 06:53:19 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/635319#M9884</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2024-10-11T06:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: Exception in GSNew.hpp (operator delete)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/635441#M9889</link>
      <description>&lt;P&gt;Please check this article, it may be related:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.graphisoft.com/t5/Developer-Insights/New-memory-allocator-in-Archicad-28/ba-p/635403" target="_blank"&gt;https://community.graphisoft.com/t5/Developer-Insights/New-memory-allocator-in-Archicad-28/ba-p/635403&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2024 18:01:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/635441#M9889</guid>
      <dc:creator>Viktor Kovacs</dc:creator>
      <dc:date>2024-10-11T18:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: Exception in GSNew.hpp (operator delete)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/635559#M9890</link>
      <description>&lt;P&gt;This addon is part of an addon package (Archicad/Revit/Navis/Autocad/Tekla). The login module is the same in all of them. It's a .NET dll paired with a CLR wrapper. What's the reason? I don't know, I just maintain the code,&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2024 08:36:18 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Exception-in-GSNew-hpp-operator-delete/m-p/635559#M9890</guid>
      <dc:creator>torokze</dc:creator>
      <dc:date>2024-10-13T08:36:18Z</dc:date>
    </item>
  </channel>
</rss>

