Archicad C++ API
About Archicad add-on development using the C++ API.

MEP.dll Error In API13 of AC13 when load com dll.

Anonymous
Not applicable
I use the com just like this.

HRESULT hr = CoInitialize(NULL);
try
{
    MyInterop::IMyDotNetInterfacePtr pdata(__uuidof(MyInterop::MyDotNetClass));
}
catch(_com_error err)
{
		
}
CoUninitialize();
When I Execute that code, then close the AC13, it crashed in mep.dll.

//================= BEGIN REPORT ======================

Exception (process terminated)
NetBIOS name: 
User name   : *
Account name: *
Domain name : *

Program Version: 13.0.0 R1 (3259)
Package Version: Kheops FULL CHI 3259
Command Line: <"C:\Program Files\Graphisoft\ArchiCAD 13\ArchiCAD.exe" >
Process ID  : 4112
Thread  ID  : 3244
WibuData: DemoMode
ProjectName: *
OS Version : Windows NT 5.1.2600 (32-bit) Service Pack 3
Session start: 2010/05/19 07:37:50
System time: 2010/05/19 07:39:57

MS VC minidump file created at: C:\Documents and Settings\*\Graphisoft\BugReporting-13\CrashDump-20100519(07-39-55)-[3244].dmp

Action Log:
00	0x4BF395B6	0x00000210	0x00000000	0x00000000
01	0x4BF395AB	0x7EF40001	0x34346D56	0x21965DF8

Exception code: C0000005 ACCESS_VIOLATION reading location: 60340000
Fault address:  4C0B021D 06:0009221D MEP.dll

Registers:
EAX:0012FCF0
EBX:79012218
ECX:07433880
EDX:00410001
ESI:60340000
EDI:FFFFFFFF
CS:EIP:001B:4C0B021D
SS:ESP:0023:0012FC90  EBP:0012FD30
DS:0023  ES:0023  FS:003B  GS:0000
Flags:00010213

Floating point Registers:
CTRL:027F  STAT:0020  TAGS:FFFF
CS:EIP:001B:69631235
DS:EDO:0023:0C007948
Cr0NpxState:00000000

ST(0) = --------- EMPTY ---------- [0012FD6000000001] [0]
ST(1) = --------- EMPTY ---------- [000000000012FD44] [1]
ST(2) = --------- EMPTY ---------- [00000000BF193BD3] [2]
ST(3) = --------- EMPTY ---------- [0018900000000000] [3]
ST(4) = --------- EMPTY ---------- [0000000000000000] [4]
ST(5) = --------- EMPTY ---------- [0000003BB3E1EB00] [5]
ST(6) = --------- EMPTY ---------- [0012FE0400000000] [6]
ST(7) = --------- EMPTY ---------- [C3EA963000000000] [7]

Disassembly

        4C0B01F7 50               push    eax
        4C0B01F8 8D442460         lea     eax,[esp+0x60]         ss:4E234973=45C6FFFF
        4C0B01FC 64A300000000     mov     fs:[00000000],eax      fs:00000000=????????
        4C0B0202 8B742470         mov     esi,[esp+0x70]         ss:4E234973=45C6FFFF
        4C0B0206 85F6             test    esi,esi
        4C0B0208 8B5C2474         mov     ebx,[esp+0x74]         ss:4E234973=45C6FFFF
        4C0B020C 0F84B2010000     je      4C0B03C4
        4C0B0212 83CFFF           or      edi,0xFF
        4C0B0215 3BF7             cmp     esi,edi
        4C0B0217 0F84A7010000     je      4C0B03C4
FAULT ->4C0B021D 66813E4D5A       cmp     word ptr [esi],0x5A4D      ds:60340000=????
        4C0B0222 7407             jz      4C0B022B
        4C0B0224 6A7E             push    0x7E
        4C0B0226 E99B010000       jmp     4C0B03C6
        4C0B022B 8B4E3C           mov     ecx,[esi+0x3C]         ds:AE444CE2=033C4E8B
        4C0B022E 03CE             add     ecx,esi
        4C0B0230 813950450000     cmp     dword ptr [ecx],0x4550 ds:07433880=4C02579C
        4C0B0236 894C2418         mov     [esp+0x18],ecx         ss:4E234973=45C6FFFF
        4C0B023A 75E8             jnz     4C0B0224
        4C0B023C 8B6978           mov     ebp,[ecx+0x78]         ds:55538562=????????
        4C0B023F 85ED             test    ebp,ebp
        4C0B0241 0F847D010000     je      4C0B03C4


Call stack:
0x4C0B021D!MEP.dll + 721437 (MEP::ItemEnumerator::`vftable' + 658313 bytes)
0x769E032F!ole32.dll + 328495 (CoFreeUnusedLibrariesEx + 210 bytes)
0x769E028B!ole32.dll + 328331 (CoFreeUnusedLibrariesEx + 46 bytes)
0x769E00B5!ole32.dll + 327861 (CoFreeUnusedLibraries + 9 bytes)
0x00E7CD60!ArchiCAD.exe + 10997088 (GS::ExecutorForTT::~ExecutorForTT + 1222595 bytes)
0x4E07D503!GSRoot.dll + 185603 (GS::Main + 66 bytes)
0x01540619!ArchiCAD.exe + 18089497 (GS::ExecutorForTT::~ExecutorForTT + 8315004 bytes)
0x0153F6AD!ArchiCAD.exe + 18085549 (GS::ExecutorForTT::~ExecutorForTT + 8311056 bytes)
0x7C817077!kernel32.dll + 94327 (RegisterWaitForInputIdle + 73 bytes)
The COM Code

namespace MyInterop
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	/// 
	[Guid("3E0E2EB2-CC13-40fb-9346-34809CB2418C")]
	public interface IMyDotNetInterface
	{
		void ShowDialog();
	}

	[ClassInterface(ClassInterfaceType.None)]
	[Guid("3A13EB34-3930-4e06-A3EB-10724CCC2F4B")]
	public class MyDotNetClass : IMyDotNetInterface
	{
		public MyDotNetClass()
		{
		}

		public void ShowDialog()
		{
			MessageBox.Show("I am a  Managed DotNET C# COM Object Dialog");
		}
	}
}

8 REPLIES 8
Ralph Wessel
Mentor
wcyoot wrote:
I use the com just like this.
Don't use C#, .NET, or COM in add-ons. There are two reasons for advice:
  • 1) Your add-on is not an application - it is a plugin for an application. This means your code can only expect to run when the host application allows/requests it to. Therefore, you cannot request services or resources with the freedom that an independent application or process can. In particular, do not expect any process to work if it has to make call-backs into your code.

    2) These are all proprietary Microsoft technologies, and ArchiCAD is a cross-platform application (with significant numbers of users in both camps). Microsoft technologies are designed to lock you into Windows and will not work anywhere else - avoid them wherever possible.
The API documentation also advises the use of C/C++. I'm doubt if C# will work in any case.
Ralph Wessel BArch
Anonymous
Not applicable
we have exactly the same exception....
and it really big problem for us, because we using c# + addon

and yes, it's crashing when closing AC

any ideals how to solve this problem... ?
Ralph Wessel
Mentor
Sergey.Babitsky wrote:
we using c# + addon
and yes, it's crashing when closing AC
any ideals how to solve this problem... ?
Yes - don't use C#. It isn't designed for this kind of development. Why not move to C++?
Ralph Wessel BArch
Anonymous
Not applicable
because we have a huge application (used as standalone) which connecting to ArchiCAD for gathering data. so, we need bridge between c++ addon and our application (application - c#)

so, any ideas?
mb any comments from Graphisoft?

i can provide simple project with logs
Ralph Wessel
Mentor
Sergey.Babitsky wrote:
because we have a huge application (can be used as standalone) which connecting to ArchiCAD for gathering data. so, we need bridge between c++ addon and our application, written on c#
so, any ideas?
Yes, you should definitely run your application outside of ArchiCAD and write an add-on (in C/C++) to manage communication between them. I've written several add-ons for this purpose.
Ralph Wessel BArch
Anonymous
Not applicable
Ralph wrote:
Sergey.Babitsky wrote:
because we have a huge application (can be used as standalone) which connecting to ArchiCAD for gathering data. so, we need bridge between c++ addon and our application, written on c#
so, any ideas?
Yes, you should definitely run your application outside of ArchiCAD and write an add-on (in C/C++) to manage communication between them. I've written several add-ons for this purpose.
we have add-on (c++) for archicad which communicating with our application by COM.

and yes, i need to run our application from ArchiCAD.

sorry, not really understood, what you offer?

now problem just with this exception... if exist some way to fix it, it will solve all our problems for communication between application and addon
Anonymous
Not applicable
Ralph Wessel, why you against c# ?
c++ and c# communicating well by COM

problem just with ArchiCAD
Ralph Wessel
Mentor
Sergey.Babitsky wrote:
Ralph Wessel, why you against c# ?
c++ and c# communicating well by COM
problem just with ArchiCAD
I'm happy to use any language or technology, provided it suits the context. I'm advising against C# and COM in this case because:
  • 1) They won't work (and that isn't an unusual problem for plugin development);

    2) They aren't cross-platform, and many ArchiCAD users use Macs.
If you were developing a Windows-only application (and you had no concerns about long-term portability) then I'd say great, use C# and COM if that's what you are familiar with.
Ralph Wessel BArch