Hi Phnimx,
This is a common problem in managed C++ by mixing unamanged and managed
code. The key point is that some header file includes "using namespace
System;" statement which makes names from the System namespace accessible
to the entire program. However, windows.h indirectly contains #include
servprov.h, which has the following declaration:
"typedef interface IServiceProvider IServiceProvider;"
The IServiceProvider becomes an ambiguous symbol.
The link below talks about this problem in details:
"Managed Extensions for C++ Migration Guide--Ambiguous References"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/ht
ml/vcmg_ambiguousreferences.asp
You may follow the resolution in the link to move "#include <windows.h>" to
the top.
MFC application may use some more complex header files including, in which
case you do not use any IServiceProvider directly in code. If the the
resolution in the link does not work for you, you may try to find "using
namespace system" in MCDll.h and move it below the #includes in MCDll.h.
This should fix the problem.
Please feel free to let me know the result. Thanks.
Best regards,
Jeffrey Tan
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.
Ben Voigt - 05 Jan 2007 15:49 GMT
> Hi Phnimx,
>
> This is a common problem in managed C++ by mixing unamanged and managed
> code. The key point is that some header file includes "using namespace
> System;" statement which makes names from the System namespace accessible
This is a good reason to absolutely forbid use of "using namespace" at file
scope in any header file.
I no longer have any recognizable wizard-generated code in any of my C++/CLI
files, but the few "using namespace System;" I do have are inside my own
namespace ProjectName {} blocks.
Jeffrey Tan[MSFT] - 08 Jan 2007 03:19 GMT
Yep, thanks for your sharing.
Best regards,
Jeffrey Tan
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.