Marshal C++ struct array into C#

I would try adding some attributes to your struct decloration [StructLayout(LayoutKind.Sequential, Size=TotalBytesInStruct),Serializable] public struct LPRData { /// char[15] [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 15)] public string data; /// int[15] [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 15)] public int[] prob; } *Note TotalBytesInStruct is not intended to represent a variable JaredPar is also correct that using the IntPtr class could be … Read more

Access x86 COM from x64 .NET

If a component is running x64-native, it can’t load a 32-bit COM server in-process, because it’s the wrong sort of process. There are a couple of solutions possible: If you can, build a 64-bit version of the COM code (which would of course register itself in the 64-bit registry). This is the cleanest solution, but … Read more

Use Visual Studio Setup Project to automatically register and GAC a COM Interop DLL

Gacutil.exe won’t be available on the target machine. Not a problem, MSI can get the job done. Right-click “File System on Target Machine”, Add, GAC. Right-click that added folder, Add, Project Output. That ensures the assembly is gac-ed. It can also register the assembly like Regasm.exe does. Set the Register property of the project output … Read more

Hosting the .NET runtime in a Delphi Program

In the Jedi Code Library (JCL) – free – there is a JclDotNet.pas, containing a class TJclClrHost, probably doing what you want: TJclClrHost = class(TJclClrBase, ICorRuntimeHost) private FDefaultInterface: ICorRuntimeHost; FAppDomains: TObjectList; procedure EnumAppDomains; function GetAppDomain(const Idx: Integer): TJclClrAppDomain; function GetAppDomainCount: Integer; function GetDefaultAppDomain: IJclClrAppDomain; function GetCurrentAppDomain: IJclClrAppDomain; protected function AddAppDomain(const AppDomain: TJclClrAppDomain): Integer; function RemoveAppDomain(const … Read more