E
Edward Diener
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 types.
The problem:
I have a number of mixed-mode functions which I want reuse. These
functions revolve around converting a CLR String to a C++ std::string or
a C++ std::wstring, and vice versa, but of course they could
theoretically be anything.
In VS 2003 I was able to put these functions in a normal C++ class as
static functions and export the class. I was then able to call these
functions from another assembly. This worked fine, but because of the
loader lock bug, I did not pursue my use of C++ mixed-mode programming
in .NET assemblies.
In VS 2005 the loader lock bug is fixed and C++ .NET developers using
mixed-mode assemblies are back in business. Trying the exact same thing
I did in VS 2003, I now receive the error message telling me, for the
mixed-mode functions, that a function with the clr calling convention
can not be exported. Evidently mixed-mode functions are automatically
called with the clr calling convention.
I then decide to put my mixed-mode functions as static functions in a
ref class. This builds without error. However when I know try to call
this function from another assenbly, I receive an error message telling
me that "Candidate Functions Not Accessible".
So now we have the situation where one can not create a mixed-mode
reusable function in VC++ in VS 2005.
Has anyone else encountered this ? Am I the only one in the world that
finds such a simple usage to be a major imposition of VC++ in VS 2005 ?
I know I can duplicate my mixed-mode functions directly in every
assembly which needs to use them, but what a PITA ! I have already
reported this to Microsoft as a "bug", but I am curious to know if
anyone else has run into this problem before me, and to understand how
they reacted to it. Maybe there is a workaround to allow mixed-mode
function reuse but I have not found one.
I realize that programming C++ in .NET using mixed-mode assemblies has
some limitations, but this really appears extreme. C++ .NET programming
was supposed to get easier with this release of VS 2005, not harder.
While I applaud the efforts of integrating C++ with .NET, this sort of
new limitation was not what I expected.
assembly.
By a mixed-mode function I mean a function whose signature has one or
more CLR types and one or more non-CLR types.
The problem:
I have a number of mixed-mode functions which I want reuse. These
functions revolve around converting a CLR String to a C++ std::string or
a C++ std::wstring, and vice versa, but of course they could
theoretically be anything.
In VS 2003 I was able to put these functions in a normal C++ class as
static functions and export the class. I was then able to call these
functions from another assembly. This worked fine, but because of the
loader lock bug, I did not pursue my use of C++ mixed-mode programming
in .NET assemblies.
In VS 2005 the loader lock bug is fixed and C++ .NET developers using
mixed-mode assemblies are back in business. Trying the exact same thing
I did in VS 2003, I now receive the error message telling me, for the
mixed-mode functions, that a function with the clr calling convention
can not be exported. Evidently mixed-mode functions are automatically
called with the clr calling convention.
I then decide to put my mixed-mode functions as static functions in a
ref class. This builds without error. However when I know try to call
this function from another assenbly, I receive an error message telling
me that "Candidate Functions Not Accessible".
So now we have the situation where one can not create a mixed-mode
reusable function in VC++ in VS 2005.
Has anyone else encountered this ? Am I the only one in the world that
finds such a simple usage to be a major imposition of VC++ in VS 2005 ?
I know I can duplicate my mixed-mode functions directly in every
assembly which needs to use them, but what a PITA ! I have already
reported this to Microsoft as a "bug", but I am curious to know if
anyone else has run into this problem before me, and to understand how
they reacted to it. Maybe there is a workaround to allow mixed-mode
function reuse but I have not found one.
I realize that programming C++ in .NET using mixed-mode assemblies has
some limitations, but this really appears extreme. C++ .NET programming
was supposed to get easier with this release of VS 2005, not harder.
While I applaud the efforts of integrating C++ with .NET, this sort of
new limitation was not what I expected.