Hi ,
I am trying to host .Net UserControls in a MFC Application. The MFC
Application is an ActiveX DLL. I inserted required managed code inside the
MFC application, making it a mixed mode DLL.
I am following the KB article for mixed mode DLL's http://support.microsoft.com/?id=814472
I linked the DLL with /noentry option. Also I added and exported the
DllEnsureInit and DllForceTerm methods in my DLL which call
__crt_dll_initialize() and __crt_dll_terminate() respectively. So far so good.
Now in the consumer application, this ActiveX control is created dynamically
by the COleControlSite::CreateControl method. I understand that I would need
to invoke my init/term DLL functions manually after loading the the mixed
mode DLL.
How do I go about invoking these functions here ? The KB article
demonstrates use of GetModuleHandle and GetProcAddress which I believe may
not be usefule
Is this feasible ? Kindly advise.
Any inputs would be highly appreciated.
Thanks in advance,
Niranjan 5 3165
The intention of the delayed CRT initialization is to avoid a deadlock,
which can happen if managed code is executed during DLLMain. After DLLMain
is called, your client will likely call DllGetClassObject to instantiate the
COM object. Unless some other code is called before DllGetClassObject, I
would initialize the CRT in your DllGetClassObject implementation.
Marcus
"NPotnis" <NP*****@discussions.microsoft.comwrote in message
news:5C**********************************@microsof t.com...
Hi ,
I am trying to host .Net UserControls in a MFC Application. The MFC
Application is an ActiveX DLL. I inserted required managed code inside
the
MFC application, making it a mixed mode DLL.
I am following the KB article for mixed mode DLL's http://support.microsoft.com/?id=814472
I linked the DLL with /noentry option. Also I added and exported the
DllEnsureInit and DllForceTerm methods in my DLL which call
__crt_dll_initialize() and __crt_dll_terminate() respectively. So far so
good.
Now in the consumer application, this ActiveX control is created
dynamically
by the COleControlSite::CreateControl method. I understand that I would
need
to invoke my init/term DLL functions manually after loading the the mixed
mode DLL.
How do I go about invoking these functions here ? The KB article
demonstrates use of GetModuleHandle and GetProcAddress which I believe may
not be usefule
Is this feasible ? Kindly advise.
Any inputs would be highly appreciated.
Thanks in advance,
Niranjan
Hi Marcus,
Thanks for your reply.
I tried to investigate the current scenario without the CRT initialization
code in place. The client is calling the DllGetClassObject in library file
oleexp.cpp. I do not have my implementation of DllGetClassObject. If I try
to implement my DllGetClassObject in the DLL code, the linker gives error
saying DllGetClassObject is already linked from oleexp.cpp.
What would I need to do to provide and use my implementation of
DllGetClassObject ?
The call to DllGetClassObject is currently failing with
CLASS_E_CLASSNOTAVAILABLE (ClassFactory cannot supply
requested class ), which I would assume is because of lack of CRT
initialization.
Thanks,
Niranjan
"Marcus Heege" wrote:
The intention of the delayed CRT initialization is to avoid a deadlock,
which can happen if managed code is executed during DLLMain. After DLLMain
is called, your client will likely call DllGetClassObject to instantiate the
COM object. Unless some other code is called before DllGetClassObject, I
would initialize the CRT in your DllGetClassObject implementation.
Marcus
"NPotnis" <NP*****@discussions.microsoft.comwrote in message
news:5C**********************************@microsof t.com...
Hi ,
I am trying to host .Net UserControls in a MFC Application. The MFC
Application is an ActiveX DLL. I inserted required managed code inside
the
MFC application, making it a mixed mode DLL.
I am following the KB article for mixed mode DLL's http://support.microsoft.com/?id=814472
I linked the DLL with /noentry option. Also I added and exported the
DllEnsureInit and DllForceTerm methods in my DLL which call
__crt_dll_initialize() and __crt_dll_terminate() respectively. So far so
good.
Now in the consumer application, this ActiveX control is created
dynamically
by the COleControlSite::CreateControl method. I understand that I would
need
to invoke my init/term DLL functions manually after loading the the mixed
mode DLL.
How do I go about invoking these functions here ? The KB article
demonstrates use of GetModuleHandle and GetProcAddress which I believe may
not be usefule
Is this feasible ? Kindly advise.
Any inputs would be highly appreciated.
Thanks in advance,
Niranjan
I my answer, I assumed that you used ATL instead of MFC. In this case, it
would have been easy to overwrite DllGetClassObject.With MFC, the story is
more difficult. I currently don't have VS2003 installed on my machine.
Therefore, I can't easily try it before I suggest something. But you may try
the following:
Modify the .def file so that
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject = MyDllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
Implement MyDllGetClassObject so that you initialize the CRT if this has not
happened before. Once you ensured that the CRT is initialized, call
DllGetClassObject.
Please let us know if this works
Marcus
"NPotnis" <NP*****@discussions.microsoft.comwrote in message
news:3E**********************************@microsof t.com...
Hi Marcus,
Thanks for your reply.
I tried to investigate the current scenario without the CRT initialization
code in place. The client is calling the DllGetClassObject in library file
oleexp.cpp. I do not have my implementation of DllGetClassObject. If I
try
to implement my DllGetClassObject in the DLL code, the linker gives error
saying DllGetClassObject is already linked from oleexp.cpp.
What would I need to do to provide and use my implementation of
DllGetClassObject ?
The call to DllGetClassObject is currently failing with
CLASS_E_CLASSNOTAVAILABLE (ClassFactory cannot supply
requested class ), which I would assume is because of lack of CRT
initialization.
Thanks,
Niranjan
"Marcus Heege" wrote:
>The intention of the delayed CRT initialization is to avoid a deadlock, which can happen if managed code is executed during DLLMain. After DLLMain is called, your client will likely call DllGetClassObject to instantiate the COM object. Unless some other code is called before DllGetClassObject, I would initialize the CRT in your DllGetClassObject implementation.
Marcus
"NPotnis" <NP*****@discussions.microsoft.comwrote in message news:5C**********************************@microso ft.com...
Hi ,
I am trying to host .Net UserControls in a MFC Application. The MFC
Application is an ActiveX DLL. I inserted required managed code inside
the
MFC application, making it a mixed mode DLL.
I am following the KB article for mixed mode DLL's http://support.microsoft.com/?id=814472
I linked the DLL with /noentry option. Also I added and exported the
DllEnsureInit and DllForceTerm methods in my DLL which call
__crt_dll_initialize() and __crt_dll_terminate() respectively. So far
so
good.
Now in the consumer application, this ActiveX control is created
dynamically
by the COleControlSite::CreateControl method. I understand that I would
need
to invoke my init/term DLL functions manually after loading the the
mixed
mode DLL.
How do I go about invoking these functions here ? The KB article
demonstrates use of GetModuleHandle and GetProcAddress which I believe
may
not be usefule
Is this feasible ? Kindly advise.
Any inputs would be highly appreciated.
Thanks in advance,
Niranjan
Hi Marcus,
Actually I did it in a different way and it works. Though it has taken me by
a bit of surprise. Heres the story - If I provide implementation of only
DllGetClassObject
the linker complains of multiply defined symbols. Same is the case if I just
implement DllCanUnloadNow. However if I implement both, the linker is happy
and moreover my implementations get used. I implemented both
DllGetClassObject and DllCanUnloadNow and put the CRT initilization in
DllGetClassObject. It worked.
What do you think have made this happen ? (is it an intelligent compiler /
linker ?)
Thanks,
Niranjan
"Marcus Heege" wrote:
I my answer, I assumed that you used ATL instead of MFC. In this case, it
would have been easy to overwrite DllGetClassObject.With MFC, the story is
more difficult. I currently don't have VS2003 installed on my machine.
Therefore, I can't easily try it before I suggest something. But you may try
the following:
Modify the .def file so that
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject = MyDllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
Implement MyDllGetClassObject so that you initialize the CRT if this has not
happened before. Once you ensured that the CRT is initialized, call
DllGetClassObject.
Please let us know if this works
Marcus
"NPotnis" <NP*****@discussions.microsoft.comwrote in message
news:3E**********************************@microsof t.com...
Hi Marcus,
Thanks for your reply.
I tried to investigate the current scenario without the CRT initialization
code in place. The client is calling the DllGetClassObject in library file
oleexp.cpp. I do not have my implementation of DllGetClassObject. If I
try
to implement my DllGetClassObject in the DLL code, the linker gives error
saying DllGetClassObject is already linked from oleexp.cpp.
What would I need to do to provide and use my implementation of
DllGetClassObject ?
The call to DllGetClassObject is currently failing with
CLASS_E_CLASSNOTAVAILABLE (ClassFactory cannot supply
requested class ), which I would assume is because of lack of CRT
initialization.
Thanks,
Niranjan
"Marcus Heege" wrote:
The intention of the delayed CRT initialization is to avoid a deadlock,
which can happen if managed code is executed during DLLMain. After
DLLMain
is called, your client will likely call DllGetClassObject to instantiate
the
COM object. Unless some other code is called before DllGetClassObject, I
would initialize the CRT in your DllGetClassObject implementation.
Marcus
"NPotnis" <NP*****@discussions.microsoft.comwrote in message
news:5C**********************************@microsof t.com...
Hi ,
I am trying to host .Net UserControls in a MFC Application. The MFC
Application is an ActiveX DLL. I inserted required managed code inside
the
MFC application, making it a mixed mode DLL.
I am following the KB article for mixed mode DLL's http://support.microsoft.com/?id=814472
I linked the DLL with /noentry option. Also I added and exported the
DllEnsureInit and DllForceTerm methods in my DLL which call
__crt_dll_initialize() and __crt_dll_terminate() respectively. So far
so
good.
Now in the consumer application, this ActiveX control is created
dynamically
by the COleControlSite::CreateControl method. I understand that I would
need
to invoke my init/term DLL functions manually after loading the the
mixed
mode DLL.
How do I go about invoking these functions here ? The KB article
demonstrates use of GetModuleHandle and GetProcAddress which I believe
may
not be usefule
Is this feasible ? Kindly advise.
Any inputs would be highly appreciated.
Thanks in advance,
Niranjan
Marcus,
I have tried it your way too and it works as well. However I have still not
been able to find how does the linker permits multiply defined symbols in my
case, as I have mentioned in the previous post.
Thanks.
"NPotnis" wrote:
Hi Marcus,
Actually I did it in a different way and it works. Though it has taken me by
a bit of surprise. Heres the story - If I provide implementation of only
DllGetClassObject
the linker complains of multiply defined symbols. Same is the case if I just
implement DllCanUnloadNow. However if I implement both, the linker is happy
and moreover my implementations get used. I implemented both
DllGetClassObject and DllCanUnloadNow and put the CRT initilization in
DllGetClassObject. It worked.
What do you think have made this happen ? (is it an intelligent compiler /
linker ?)
Thanks,
Niranjan
"Marcus Heege" wrote:
I my answer, I assumed that you used ATL instead of MFC. In this case, it
would have been easy to overwrite DllGetClassObject.With MFC, the story is
more difficult. I currently don't have VS2003 installed on my machine.
Therefore, I can't easily try it before I suggest something. But you may try
the following:
Modify the .def file so that
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject = MyDllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
Implement MyDllGetClassObject so that you initialize the CRT if this has not
happened before. Once you ensured that the CRT is initialized, call
DllGetClassObject.
Please let us know if this works
Marcus
"NPotnis" <NP*****@discussions.microsoft.comwrote in message
news:3E**********************************@microsof t.com...
Hi Marcus,
Thanks for your reply.
>
I tried to investigate the current scenario without the CRT initialization
code in place. The client is calling the DllGetClassObject in library file
oleexp.cpp. I do not have my implementation of DllGetClassObject. If I
try
to implement my DllGetClassObject in the DLL code, the linker gives error
saying DllGetClassObject is already linked from oleexp.cpp.
>
What would I need to do to provide and use my implementation of
DllGetClassObject ?
>
The call to DllGetClassObject is currently failing with
CLASS_E_CLASSNOTAVAILABLE (ClassFactory cannot supply
requested class ), which I would assume is because of lack of CRT
initialization.
>
Thanks,
Niranjan
>
"Marcus Heege" wrote:
>
>The intention of the delayed CRT initialization is to avoid a deadlock,
>which can happen if managed code is executed during DLLMain. After
>DLLMain
>is called, your client will likely call DllGetClassObject to instantiate
>the
>COM object. Unless some other code is called before DllGetClassObject, I
>would initialize the CRT in your DllGetClassObject implementation.
>>
>Marcus
>>
>"NPotnis" <NP*****@discussions.microsoft.comwrote in message
>news:5C**********************************@microso ft.com...
Hi ,
>
I am trying to host .Net UserControls in a MFC Application. The MFC
Application is an ActiveX DLL. I inserted required managed code inside
the
MFC application, making it a mixed mode DLL.
I am following the KB article for mixed mode DLL's http://support.microsoft.com/?id=814472
I linked the DLL with /noentry option. Also I added and exported the
DllEnsureInit and DllForceTerm methods in my DLL which call
__crt_dll_initialize() and __crt_dll_terminate() respectively. So far
so
good.
>
Now in the consumer application, this ActiveX control is created
dynamically
by the COleControlSite::CreateControl method. I understand that I would
need
to invoke my init/term DLL functions manually after loading the the
mixed
mode DLL.
How do I go about invoking these functions here ? The KB article
demonstrates use of GetModuleHandle and GetProcAddress which I believe
may
not be usefule
>
Is this feasible ? Kindly advise.
Any inputs would be highly appreciated.
Thanks in advance,
Niranjan
>
>
>>
>>
>>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mike Kamzyuk |
last post by:
Hello all. Basically, I need to call a mixed-mode dll's function
(which uses managed code) from a native or mixed-mode dll function
(which does not use managed code). I'm wondering if this could...
|
by: Edward Diener |
last post by:
I have some questions about the instructions for creating a mixed mode DLL
in the MSDN topic "Converting Managed Extensions for C++ Projects from Pure
Intermediate Language to Mixed Mode" in the...
|
by: Edward Diener |
last post by:
I received no answers about this the first time I posted, so I will try
again. My inability to decipher an MSDN topic may find others who have the
same inability and someone who can decipher and...
|
by: Bern McCarty |
last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains
other than the default AppDomain? Is there any means at all of doing this?
Mixed-mode is incredibly convenient, but if I...
|
by: Nadav |
last post by:
Hi,
I am writing a performence critical application, this require me to stick to unmanaged C++ as performance is much better using unmanaged C++ ( about 33% better ), Still, I am trying to avoid...
|
by: Doug Belkofer |
last post by:
We have created a fairly complex mixed-mode DLL that we want to use from
VB.NET. The mixed-mode DLL is written in C++, and does use the standard C
runtime libraries. An unusual thing is happening...
|
by: Doug Belkofer |
last post by:
We have created a fairly complex mixed-mode DLL that we want to use from
VB.NET. The mixed-mode DLL is written in C++, and does use the standard C
runtime libraries. An unusual thing is happening...
|
by: Edward Diener |
last post by:
By reuse, I mean a function in an assembly which is called in another
assembly.
By a mixed-mode function I mean a function whose signature has one or
more CLR types and one or more non-CLR...
|
by: emu |
last post by:
Hi All,
I have an unmanaged C++ application that references a mixed mode image
DLL (mixed managed and unmanaged). Under .NET 1.1 we could trust the
dll (the mixed mode dll) by running the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |