We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
a month ago
Hello,
During the adaptation of our addon to the new Archicad 28 Windows, an exception occurs in the function below.
inline void CCALL operator delete (void *p) noexcept
{
GS::MemoryManager::Free (p);
}
It's a simple std::string deallocation. The string contains valid data.
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.
We have
- Addon.apx
- Addon.Login.CLR.dll (CLR Bridge)
- Addon.WebView.dll (.NET)
The addon displays a login window (.NET) through the CLR and converts a managed string to std::string as return value.
Thanks,
Zoltan
a month ago
Uff, that's a tough one.
Do you get more info from debugging when compiling in Release mode with debug symbols?
Maybe you can also share the string conversion function for us to take a look.
a month ago
This is Release mode with debug symbols already.
std::string ManagedStringToUTF8String(System::String^ in)
{
if (!System::String::IsNullOrEmpty(in))
{
//std::string str = msclr::interop::marshal_as<std::string>(in); // Don't use this.
array<Byte>^ bytes = Encoding::UTF8->GetBytes(in);
pin_ptr<Byte> pinnedBytes = &bytes[0];
std::string str(reinterpret_cast<char*>(pinnedBytes));
return str;
}
return "";
}
a month ago
I see, so then my first guess is that it's due to the optimization for Release builds.
You can try /Od or wrap the function (or parts of it) in
#pragma optimize("", off)
...
#pragma optimize("", on)
as suggested here: https://stackoverflow.com/questions/24664865/preventing-the-optimizer-from-optimizing-a-variable-awa...
a month ago
I use msclr::interop::marshal_as<std::string>(str) in similar cases, but for .net APIs like Revit. I see you've commented "Don't use this" - was there a problem?
4 weeks ago
I tried several ways, none of them worked.
4 weeks ago
I don't know the reason, it's the work of another developer who no longer works for us.
4 weeks ago
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.
4 weeks ago
Please check this article, it may be related:
4 weeks ago
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,