468,249 Members | 1,511 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

Candidate function(s) not accessible strange case

When trying to call a __gc class static function in an assembly which
has CLR and non-CLR types in its signature, I get a Candidate
function(s) not accessible error.

In an assembly, using /clr:oldSyntax:

TSEShared.h
--------------

// TSEShared.h
#pragma once
#include <string>
using namespace System;
namespace TSEShared {
public __gc class Global
{
public:
static std::string ToCppString(System::String *);
};
}

TSEShared.cpp
----------------

#include "stdafx.h"
#include "TSEShared.h"
std::string TSEShared::Global::ToCppString(System::String * str)
{
if (str == 0)
{
return(std::string());
}
System::IntPtr
ptr(System::Runtime::InteropServices::Marshal::Str ingToHGlobalAnsi(str));
std::string ret(static_cast<const char *>(static_cast<void *>(ptr)));
System::Runtime::InteropServices::Marshal::FreeCoT askMem(ptr);
return(ret);
}

Called from another assembly using /clr:oldSyntax which references the
TSEShared assembly.

UseTSEShared.h
------------------

#pragma once
//#include <string>
//---------------------------------------------------------------------------
namespace UseTSEShared
{
public __gc class SomeClass {
public:
SomeClass();
};
}

UseTSEShared.cpp
--------------------

#include "stdafx.h"
#include "UseTSEShared.h"
UseTSEShared::SomeClass::SomeClass()
{
TSEShared::Global::ToCppString(0); // compiler error on this line
}

I do not see the reason why ?

I am trying to create reusable functions in an assembly, which can be
called from other assemblies, which have mixed types in its signature.
Clearly this should be doable. When I tried it within a __nogc class,
exporting the functions, I received an error that functions with clr
calling conventions can not be exported. Now that I try it with a __gc
class, I receive this error.
Mar 20 '06 #1
0 908

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Steve Jaworski | last post: by
2 posts views Thread by ajtaylor | last post: by
9 posts views Thread by Gilbert | last post: by
3 posts views Thread by Dan Noland | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.