By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,441 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,441 IT Pros & Developers. It's quick & easy.

Candidate function(s) not accessible strange case

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.