Hi, I have a .tlb-file which only contains Interfaces for a COM-Application. How can I use this Interfaces in C#? How can I "instantiate" these Interfaces to use the functions they provide? Thanks in advance, Andy
rncwnd
Posts
-
Retrieve Com-Object which implements interface -
passing dynamic MyStruct[] from unmanaged dll to C#I have to pass a dynamic array of structures from an unmanaged DLL to C#. I wrote the following wrapper-function. Unmanaged C++ DLL:
typedef struct browserStruct { unsigned long id; unsigned char name[250]; } structTypBrowser; extern "C" __declspec(dllexport) unsigned long __stdcall sv_getDocClassList( unsigned long &cnc, unsigned short numOfElems, structTypBrowser *browserArray ) {...}
In C#:public struct svStructTypBrowser { private UInt32 m_id; private string m_name; } [DllImport("SVConDll.dll")] private static extern UInt32 sv_getDocClassList( out UInt32 c, out ushort numOfElems, out IntPtr browserArray // svStructTypBrowser ); public getDocClassList() { IntPtr p1; svStructTypBrowser[] m_docClasses; ... try { result = sv_getDocClassList(out m_cnc, out noe, out p1); m_docClasses = (svStructTypBrowser[])Marshal.PtrToStructure(p1, typeof(svStructTypBrowser)); } }
The IntPtr p1 is null after calling sv_getDocClassList(). Has anybody a solution? -
MFC program errorAnonymous (that is bugDanny) wrote: I did read all the postings before I made my post. My post was intended as a comment on the mildly annoying, albeit funny way that you posted your error in German originally, since you seem to be able to write English as well and this is a worldwide slight. I did not judge, or even all you stupid. (This is bugDanny writing, from a computer a don't usually use.) Neither did toxcct, I don't think.
Well, then I misunderstood you both and I'm sorry for that. I didn't know that e.g. google translates of error messages are that good (I didn't want to translate the error message because I was afraid to give it a completly diferent signification...)!!!
My program works now. After I deinstalled VS and installed it again after a memory and hdd check... After a "new rebuild" of all my MFC-programs they worked again. Sometimes computers drive me really crazy.
-
MFC program errorSomeone said I should read the call trace to find a solution for this error. Well, there it is, but I don't understand it. The program which produced this error (stated above - translation just some post under my first post!!) is an empty MFC-app generated from the MFC-Application Wizard. I made NO changes to the code. If you guys (BugDanny & toxcct) would have read my first posting and the postings from the other guys, maybe you wouldn't have judged me stupid and annoying. No I am NOT a VC++/MFC guru like you might be. That's why I thought I could find some answers on this board.
-
MFC program errorWell, thanks so far. I recompiled the project with a map-file an debugging infos. Now I get this call stack:
testMFC.exe!ATL::CRegParser::MAX_VALUE() + 0x1f mfc71d.dll!CWnd::OnWndMsg(unsigned int message=272, unsigned int wParam=459270, long lParam=0, long * pResult=0x0012f990) Zeile 2013 + 0x11 mfc71d.dll!CWnd::WindowProc(unsigned int message=272, unsigned int wParam=459270, long lParam=0) Zeile 1745 + 0x1e mfc71d.dll!AfxCallWndProc(CWnd * pWnd=0x0012fe3c, HWND__ * hWnd=0x000300e6, unsigned int nMsg=272, unsigned int wParam=459270, long lParam=0) Zeile 241 + 0x1a mfc71d.dll!AfxWndProc(HWND__ * hWnd=0x000300e6, unsigned int nMsg=272, unsigned int wParam=459270, long lParam=0) Zeile 389 mfc71d.dll!AfxWndProcBase(HWND__ * hWnd=0x000300e6, unsigned int nMsg=272, unsigned int wParam=459270, long lParam=0) Zeile 209 + 0x15 user32.dll!77d18734() user32.dll!77d18816() user32.dll!77d1b89b() user32.dll!77d24e28() user32.dll!77d2514c() user32.dll!77d39b1b() mfc71d.dll!CWnd::CreateDlgIndirect(const DLGTEMPLATE * lpDialogTemplate=0x004188d8, CWnd * pParentWnd=0x00000000, HINSTANCE__ * hInst=0x00400000) Zeile 310 + 0x2a mfc71d.dll!CDialog::DoModal() Zeile 519 + 0x20 testMFC.exe!CtestMFCApp::InitInstance() Zeile 58 + 0xb mfc71d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00141f0c, int nCmdShow=1) Zeile 39 + 0xb testMFC.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00141f0c, int nCmdShow=1) Zeile 25 testMFC.exe!WinMainCRTStartup() Zeile 390 + 0x39 kernel32.dll!7c816d4f() ntdll.dll!7c925b4f() kernel32.dll!7c8399f3()
-
MFC program errorHi, when I use the MFC Application Wizard to generate a MFC application (dialog based), I can't even run this basic generated code anymore. "Anymore" because it worked 2 days ago. But I really didn't change anything in my VS .NET 2003 installation.
I can compile and link the generated program, but when i run it, i get the following error (it's german...):Die Anweisung in "0x0000000" verweist auf Speicher in "0x00000000". Der Vorgang "read" konnte nicht auf dem Speicher ausgeführt werden.
Any suggestions?