|
I am trying to access a C# dll from MFC application. One of this dll method, XMLDoc(), returns an XMLDocument object. When I compile the c++ project, a tlh file is created where I find:
virtual HRESULT __stdcall XMLDoc (
/*[out,retval]*/ IUnknown * * pRetVal ) = 0;
Seems this method returns IUnknown instead of XMLDocument object directly. I am facing problem getting the XMLDocument object from this IUnknown interface.
Can anybody show me a way/sample to do this?
Thanks in advance.
Nazmul
|
|
|
|
|
moved to top again..
Anybody?!
|
|
|
|
|
You can use this way
you can make you C# classes accessible to C++ app by registering them as
COM components.
Go to project properties/build and Select the "Register For COM Interop"
option in the Output section.
or if you like command prompt follow these steps:
You can also select the class which will be com visible. use the
ComVisible attribute on the class too.
Please note that for making a class COM visible
-the classes must use a default constructor with no parameters.
-Any type that is to be exposed must be public.
-Any member that is to be exposed must be public.
-Abstract classes will not be able to be consumed.
these steps are from the command line.
Let say your code is in myDLL.cs, then first you need to compile it
csc /t:library myDLL.cs
then you need to use the Type Library Exporter Utility.
tlbexp myDLL.dll /out:myDLL.tlb
Next you need to create a resource script (myDLL.res) with the following
Interface Definition Language (IDL) definition:
IDR_TYPELIB1 typelib "myDLL.tlb"
Then you recompile the application with the new resource file added
csc /t:library myDLL.cs /win32res:myDLL.res
after this is done you can use the class in C# as a COM component in C++
applicaiton
|
|
|
|
|
Hi,
I have inserted several resources in my project : ENU and FRA.
I would like to generate 2 applications:
- one only with the ENU resources
- the second only with the FRA resources
I tried to set the 'project settings > resources Tab' options with diferents parameters with no result.
Please help Me!
PS: I don't want a resource DLL. the project needs only one EXE file by language
XtremDev
|
|
|
|
|
|
If I use AfxSetRessourceHandle the problem is that I need a resource DLL.
so, it implies 2 files by language : 1 exe + 1 dll.
I need just one file by language
|
|
|
|
|
Actually, if you configure all your messages/names/... of every language in a dll... you should only need an *.exe for all languages and one *.dll for every language. Not a pair exe-dll for everyone.
Just wait to see what other people with more knowledge as me say.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
I am not sure but try this. in the rc file of your project, you can find section like
"LANGUAGE 12, 1\r\n"<br />
"#pragma code_page(1252)\r\n"<br />
"#endif //_WIN32\r\n"<br />
"#include ""res\\aaaa.rc2"" // non-Microsoft Visual C++ edited resources\r\n"<br />
"#include ""l.fra\\afxres.rc"" // Standard components\r\n"
put some predefinitions in your project before compiling and switch the language aacording to it. like..
#ifdef LAN_ENGLISH <br />
"LANGUAGE 9, 1\r\n"<br />
"#pragma code_page(1252)\r\n"<br />
"#endif //_WIN32\r\n"<br />
"#include ""res\\aaaa.rc2"" // non-Microsoft Visual C++ edited resources\r\n"<br />
"#include ""\\afxres.rc"" // Standard components\r\n"<br />
#elseif<br />
"LANGUAGE 12, 1\r\n"<br />
"#pragma code_page(1252)\r\n"<br />
"#endif //_WIN32\r\n"<br />
"#include ""res\\aaaa.rc2"" // non-Microsoft Visual C++ edited resources\r\n"<br />
"#include ""l.fra\\afxres.rc"" // Standard components\r\n"<br />
#endif
now if you want english before compiling put #define LAN_ENGLISH in the stdafx.h.
I would like to know whether it worked or not..
nave
|
|
|
|
|
Does the rc2 file always necessarly contain non-Microsoft Visual C++ edited resources?
Also let me know of the following
"#include ""res\\aaaa.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
I think the significance of the quotes is to have the literal meaning. Still I feel there is a typo in the closing quote.
|
|
|
|
|
Hello,
I have code written at VS 2003 which uses VS6/MFC6.
I build it at .NET 1.1 frame work and it run at debug mode very well.
Then I installed .Net 2.0 at my computer and try to run it as well at debug mode.
I got exception as I run at debug, but it is not at my code.
Do you know where can I find links for this problem?
thanks!
|
|
|
|
|
Did you trace youe program setp by step and if yes where you got an exception and whats your program?
|
|
|
|
|
I trying to run exe which includes a lot of code.
What I get is:
"Unhandled exception at 0x7c964ed1 in 12345.exe: 0xC0000142: DLL Initialization Failed."
Then, I countinue to run this exe (at denug state) and get exception on the first C++ object like: CTime or any Code from C++ libraries.
Can you help? Do you know how to progress?
Thanks!
|
|
|
|
|
Do you run CTime of your program or load of a dll ?
|
|
|
|
|
CTime of C++ (load a Dll)...
|
|
|
|
|
When you load this dll whats return value and when you want to load functions whats return value?
|
|
|
|
|
I do not understand your question...
|
|
|
|
|
How do you load your dll?
|
|
|
|
|
|
Im not sure this[^] thread does solve your program or not but anyway see that thread maybe it some helpfuls for you.
|
|
|
|
|
|
I am still working on it. thanks!
|
|
|
|
|
Tal S. wrote: code written at VS 2003 which uses VS6/MFC6.
Why 6?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
|
VS2003 is version 7 and comes with MFC version 7. So I'm confused - are you writing code in
VS2003 and building it with VS 6?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
You are right it is VS2003 with MFC ver. 7!!! not 6!!!
|
|
|
|