Home All Groups Group Topic Archive Search About

Managed C++ Mixed Assembly

Author
24 Nov 2006 5:01 PM
Olivier Matrot
Hello,

I have a VC++ Project that outputs an unmanaged DLL.

I would like to convert this project to a managed C++ Project.
The goal is to mix unmanaged and managed code. Un unmanaged exported
function will need to run managed code. Is it possible ?
TIA.

Author
24 Nov 2006 5:21 PM
Vadym Stetsyak
Hello, Olivier!

Yes, it is possible.
To compile with managed code use /clr compiler parameter.

And here's code sample
( http://www.winterdom.com/mcppfaq/archives/000370.html )

OM> I have a VC++ Project that outputs an unmanaged DLL.

OM> I would like to convert this project to a managed C++ Project.
OM> The goal is to mix unmanaged and managed code. Un unmanaged exported
OM> function will need to run managed code. Is it possible ?
OM> TIA.



--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Author
24 Nov 2006 5:25 PM
Olivier Matrot
Thanks for that.
Should I follow the following ? http://support.microsoft.com/?id=814472
I may be wrong but the sample you provider is not what I'm looking for.


Show quote
"Vadym Stetsyak" <vady***@ukr.net> wrote in message
news:uXf6%23w%23DHHA.4112@TK2MSFTNGP03.phx.gbl...
> Hello, Olivier!
>
> Yes, it is possible.
> To compile with managed code use /clr compiler parameter.
>
> And here's code sample
> ( http://www.winterdom.com/mcppfaq/archives/000370.html )
>
> OM> I have a VC++ Project that outputs an unmanaged DLL.
>
> OM> I would like to convert this project to a managed C++ Project.
> OM> The goal is to mix unmanaged and managed code. Un unmanaged exported
> OM> function will need to run managed code. Is it possible ?
> OM> TIA.
>
>
>
> --
> Regards, Vadym Stetsyak
> www: http://vadmyst.blogspot.com
Author
24 Nov 2006 5:46 PM
Olivier Matrot
Ok, this is not necessary with VS2005...
I have now a mixed DLL. But when I load it with LoadLibrary from unmanaged
code I have the following Error:
193 : %1 is not a valid Win32 application.
Ouch !

Show quote
"Olivier Matrot" <olivier.matrot.rte@online.nospam> wrote in message
news:uzX$61%23DHHA.4048@TK2MSFTNGP02.phx.gbl...
> Thanks for that.
> Should I follow the following ? http://support.microsoft.com/?id=814472
> I may be wrong but the sample you provider is not what I'm looking for.
>
>
> "Vadym Stetsyak" <vady***@ukr.net> wrote in message
> news:uXf6%23w%23DHHA.4112@TK2MSFTNGP03.phx.gbl...
>> Hello, Olivier!
>>
>> Yes, it is possible.
>> To compile with managed code use /clr compiler parameter.
>>
>> And here's code sample
>> ( http://www.winterdom.com/mcppfaq/archives/000370.html )
>>
>> OM> I have a VC++ Project that outputs an unmanaged DLL.
>>
>> OM> I would like to convert this project to a managed C++ Project.
>> OM> The goal is to mix unmanaged and managed code. Un unmanaged exported
>> OM> function will need to run managed code. Is it possible ?
>> OM> TIA.
>>
>>
>>
>> --
>> Regards, Vadym Stetsyak
>> www: http://vadmyst.blogspot.com
>
>
Author
25 Nov 2006 3:07 PM
Vadym Stetsyak
Hello, Olivier!

Hmm, strange. Do you have DllMain function  in your dll?
Is it called?

You wrote  on Fri, 24 Nov 2006 18:46:53 +0100:

OM> Ok, this is not necessary with VS2005...
OM> I have now a mixed DLL. But when I load it with LoadLibrary from
OM> unmanaged
OM> code I have the following Error:
OM> 193 : %1 is not a valid Win32 application.
OM> Ouch !

Show quote
OM> "Olivier Matrot" <olivier.matrot.rte@online.nospam> wrote in message
OM> news:uzX$61%23DHHA.4048@TK2MSFTNGP02.phx.gbl...
>> Thanks for that.
>> Should I follow the following ?
>> http://support.microsoft.com/?id=814472
>> I may be wrong but the sample you provider is not what I'm looking
>> for.


>> "Vadym Stetsyak" <vady***@ukr.net> wrote in message
>> news:uXf6%23w%23DHHA.4112@TK2MSFTNGP03.phx.gbl...
>>> Hello, Olivier!

>>> Yes, it is possible.
>>> To compile with managed code use /clr compiler parameter.

>>> And here's code sample
>>> ( http://www.winterdom.com/mcppfaq/archives/000370.html )

>>> OM> I have a VC++ Project that outputs an unmanaged DLL.

>>> OM> I would like to convert this project to a managed C++ Project.
>>> OM> The goal is to mix unmanaged and managed code. Un unmanaged
>>> exported
>>> OM> function will need to run managed code. Is it possible ?
>>> OM> TIA.



>>> --
>>> Regards, Vadym Stetsyak
>>> www: http://vadmyst.blogspot.com





--
With best regards, Vadym Stetsyak.
Blog: http://vadmyst.blogspot.com
Author
26 Nov 2006 9:05 PM
Olivier MATROT
This a a visual studio 2003 upgraded MFC DLL.
I've only added a managed C++ class to the project...

Show quote
"Vadym Stetsyak" <vady***@ukr.net> wrote in message
news:OkmIhNKEHHA.4312@TK2MSFTNGP06.phx.gbl...
> Hello, Olivier!
>
> Hmm, strange. Do you have DllMain function  in your dll?
> Is it called?
>
> You wrote  on Fri, 24 Nov 2006 18:46:53 +0100:
>
> OM> Ok, this is not necessary with VS2005...
> OM> I have now a mixed DLL. But when I load it with LoadLibrary from
> OM> unmanaged
> OM> code I have the following Error:
> OM> 193 : %1 is not a valid Win32 application.
> OM> Ouch !
>
> OM> "Olivier Matrot" <olivier.matrot.rte@online.nospam> wrote in message
> OM> news:uzX$61%23DHHA.4048@TK2MSFTNGP02.phx.gbl...
>>> Thanks for that.
>>> Should I follow the following ?
>>> http://support.microsoft.com/?id=814472
>>> I may be wrong but the sample you provider is not what I'm looking
>>> for.
>
>
>>> "Vadym Stetsyak" <vady***@ukr.net> wrote in message
>>> news:uXf6%23w%23DHHA.4112@TK2MSFTNGP03.phx.gbl...
>>>> Hello, Olivier!
>
>>>> Yes, it is possible.
>>>> To compile with managed code use /clr compiler parameter.
>
>>>> And here's code sample
>>>> ( http://www.winterdom.com/mcppfaq/archives/000370.html )
>
>>>> OM> I have a VC++ Project that outputs an unmanaged DLL.
>
>>>> OM> I would like to convert this project to a managed C++ Project.
>>>> OM> The goal is to mix unmanaged and managed code. Un unmanaged
>>>> exported
>>>> OM> function will need to run managed code. Is it possible ?
>>>> OM> TIA.
>
>
>
>>>> --
>>>> Regards, Vadym Stetsyak
>>>> www: http://vadmyst.blogspot.com
>
>
>
>
>
> --
> With best regards, Vadym Stetsyak.
> Blog: http://vadmyst.blogspot.com
>
Author
27 Nov 2006 5:46 AM
Gary Chang[MSFT]
Hi Olivier,

>This a a visual studio 2003 upgraded MFC DLL.
>I've only added a managed C++ class to the project...

Based on the error message: 193 : %1 is not a valid Win32 application.

The problem seems to be your mixed DLL is not a valid Win32 image. Is it
possible that  the DLL is built by any 64-bit version's library?

If you just upgrade that MFC DLL to VS2005, is there any problem to load it?

By the way, the KB article you mention does not target on your case, it
discuss the scenario that the original DLL is a pure .NET assembly.

Thanks!

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Author
27 Nov 2006 8:28 AM
Olivier Matrot
There is no problem to load the DLL, if there is no CLR module module in the
project.
As soon as I add a Managed C++ Class, the DLL does not load anymore.

""Gary Chang[MSFT]"" <v-gar***@online.microsoft.com> wrote in message
Show quote
news:cnlDideEHHA.5964@TK2MSFTNGXA01.phx.gbl...
> Hi Olivier,
>
>>This a a visual studio 2003 upgraded MFC DLL.
>>I've only added a managed C++ class to the project...
>
> Based on the error message: 193 : %1 is not a valid Win32 application.
>
> The problem seems to be your mixed DLL is not a valid Win32 image. Is it
> possible that  the DLL is built by any 64-bit version's library?
>
> If you just upgrade that MFC DLL to VS2005, is there any problem to load
> it?
>
> By the way, the KB article you mention does not target on your case, it
> discuss the scenario that the original DLL is a pure .NET assembly.
>
> Thanks!
>
> Best regards,
>
> Gary Chang
> Microsoft Online Community Support
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
Author
27 Nov 2006 4:44 PM
Olivier Matrot
My fault.
I started from scratch with this project. Now the DLL is successfully
loaded.
My problem now is to call a static managed function from unmanaged code (an
unmanaged exported C style function).

Show quote
"Olivier Matrot" <olivier.matrot.rte@online.nospam> wrote in message
news:%23DSxU4fEHHA.4740@TK2MSFTNGP03.phx.gbl...
> There is no problem to load the DLL, if there is no CLR module module in
> the project.
> As soon as I add a Managed C++ Class, the DLL does not load anymore.
>
> ""Gary Chang[MSFT]"" <v-gar***@online.microsoft.com> wrote in message
> news:cnlDideEHHA.5964@TK2MSFTNGXA01.phx.gbl...
>> Hi Olivier,
>>
>>>This a a visual studio 2003 upgraded MFC DLL.
>>>I've only added a managed C++ class to the project...
>>
>> Based on the error message: 193 : %1 is not a valid Win32 application.
>>
>> The problem seems to be your mixed DLL is not a valid Win32 image. Is it
>> possible that  the DLL is built by any 64-bit version's library?
>>
>> If you just upgrade that MFC DLL to VS2005, is there any problem to load
>> it?
>>
>> By the way, the KB article you mention does not target on your case, it
>> discuss the scenario that the original DLL is a pure .NET assembly.
>>
>> Thanks!
>>
>> Best regards,
>>
>> Gary Chang
>> Microsoft Online Community Support
>> ==================================================
>> Get notification to my posts through email? Please refer to
>> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>> ications.
>>
>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>> issues
>> where an initial response from the community or a Microsoft Support
>> Engineer within 1 business day is acceptable. Please note that each
>> follow
>> up response may take approximately 2 business days as the support
>> professional working with you may need further investigation to reach the
>> most efficient resolution. The offering is not appropriate for situations
>> that require urgent, real-time or phone-based interactions or complex
>> project analysis and dump analysis issues. Issues of this nature are best
>> handled working with a dedicated Microsoft Support Engineer by contacting
>> Microsoft Customer Support Services (CSS) at
>> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>> ==================================================
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>
>
Author
27 Nov 2006 6:00 PM
Olivier Matrot
Nothing special to do for calling managed code from unmanaged code.
Thanks for that.

Show quote
"Olivier Matrot" <olivier.matrot.rte@online.nospam> wrote in message
news:u1cFdNkEHHA.3768@TK2MSFTNGP06.phx.gbl...
> My fault.
> I started from scratch with this project. Now the DLL is successfully
> loaded.
> My problem now is to call a static managed function from unmanaged code
> (an unmanaged exported C style function).
>
> "Olivier Matrot" <olivier.matrot.rte@online.nospam> wrote in message
> news:%23DSxU4fEHHA.4740@TK2MSFTNGP03.phx.gbl...
>> There is no problem to load the DLL, if there is no CLR module module in
>> the project.
>> As soon as I add a Managed C++ Class, the DLL does not load anymore.
>>
>> ""Gary Chang[MSFT]"" <v-gar***@online.microsoft.com> wrote in message
>> news:cnlDideEHHA.5964@TK2MSFTNGXA01.phx.gbl...
>>> Hi Olivier,
>>>
>>>>This a a visual studio 2003 upgraded MFC DLL.
>>>>I've only added a managed C++ class to the project...
>>>
>>> Based on the error message: 193 : %1 is not a valid Win32 application.
>>>
>>> The problem seems to be your mixed DLL is not a valid Win32 image. Is it
>>> possible that  the DLL is built by any 64-bit version's library?
>>>
>>> If you just upgrade that MFC DLL to VS2005, is there any problem to load
>>> it?
>>>
>>> By the way, the KB article you mention does not target on your case, it
>>> discuss the scenario that the original DLL is a pure .NET assembly.
>>>
>>> Thanks!
>>>
>>> Best regards,
>>>
>>> Gary Chang
>>> Microsoft Online Community Support
>>> ==================================================
>>> Get notification to my posts through email? Please refer to
>>> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>>> ications.
>>>
>>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>>> issues
>>> where an initial response from the community or a Microsoft Support
>>> Engineer within 1 business day is acceptable. Please note that each
>>> follow
>>> up response may take approximately 2 business days as the support
>>> professional working with you may need further investigation to reach
>>> the
>>> most efficient resolution. The offering is not appropriate for
>>> situations
>>> that require urgent, real-time or phone-based interactions or complex
>>> project analysis and dump analysis issues. Issues of this nature are
>>> best
>>> handled working with a dedicated Microsoft Support Engineer by
>>> contacting
>>> Microsoft Customer Support Services (CSS) at
>>> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>>> ==================================================
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>>
>>
>>
>
>

AddThis Social Bookmark Button