473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

error C3767: candidate function(s) not available

Using VS2005Beta 2 I have VC++/CLI class defined in a Class Library DLL as:

#foo.h

namespace foo
{
public ref class Convert
{
public:
static Obj^ ToObj(UnmanagedObj* uObj);
};
}

Calling this static method from another VC++/CLI class in another Class
Library DLL as:

Obj^ obj = NULL;
obj = foo::Convert::ToObj(uObj);

results in a compilation error C3763: 'foo::Convert::ToObj': candidate
function(s) not accessible.

This worked fine in VS2003 and VS2005Beta1, any idea what's going on here?

Thanks,
Steve
Nov 17 '05 #1
3 5465

--
Kapil Khosla, Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights
"Steve Jaworski" wrote:
Using VS2005Beta 2 I have VC++/CLI class defined in a Class Library DLL as:

#foo.h

namespace foo
{
public ref class Convert
{
public:
static Obj^ ToObj(UnmanagedObj* uObj);
};
}

Calling this static method from another VC++/CLI class in another Class
Library DLL as:

Obj^ obj = NULL;
obj = foo::Convert::ToObj(uObj);

results in a compilation error C3763: 'foo::Convert::ToObj': candidate
function(s) not accessible.

This worked fine in VS2003 and VS2005Beta1, any idea what's going on here?

Thanks,
Steve


The problem is with your native type in the managed function signature. From
what it looks like, that type is private and you must explicitly declare
public accessiblity for it.

Look at the previous thread on the same topic by searching for C3767 on
msdn.microsoft.com/visualc,

Thanks,
Kapil

Nov 17 '05 #2
Steve Jaworski wrote:
results in a compilation error C3763: 'foo::Convert::ToObj': candidate
function(s) not accessible.


I had the same problem before. I think this link is extremely helpful:
http://tinyurl.com/7fw59

If I understand it correctly, when you want to use native types in the
signature of public managed methods in an assembly, you have to make the
unmanaged class public for the assembly.

Try to add this line to your code:
public class __declspec(dllexport) UnmanagedObj {};

Let us know if this solves your problem.

Tom
Nov 17 '05 #3
I've been doing an experiment to see if I can design a simple managed
wrapper around an unmanaged class, but faced a small problem that may be
a compiler bug.

I created an unmanaged DLL first:

// unmanaged.h
#ifdef UNMANAGED_EXPORTS
#define UNMANAGED_IMPORT __declspec(dllexport)
#else
#define UNMANAGED_IMPORT __declspec(dllimport)
#endif
#ifdef _MANAGED
public
#endif
class UNMANAGED_IMPORT UnClass
{
public:
int Square(int x) { return x * x; }
};

Then I created a managed assembly wrapper:

//managed.h
#pragma once
#include "unmanaged.h"
public ref class Class1
{
public:
Class1() : p(new UnClass) { }
~Class1() { delete p;}
UnClass* get() { return p; }
private:
UnClass* p;
};

And finally a managed test application:

// test.cpp
#include "unmanaged.h"
#using "managed.dll"
using namespace System;
int main(array<System::String^>^ args)
{
Class1 c;
UnClass* p = c.get();
p->Square(10); // this works
// c.get()->Square(10); // ERROR!!! why?
return 0;
}

I used the
#ifdef _MANAGED
public
#endif
trick to make my unmanaged class public, to avoid the "C3767: candidate
function not available" error, which the original poster had. It works
nicely.

However, there's one glitch. The following doesn't work in test.cpp:

c.get()->Square(10);

I get a compiler error C2039: 'Square': is not a member of 'UnClass'. I
don't understand why, it obviously is a member. I'm forced to assign the
output of the c.get() call to temporary variable 'p', or explicitly
cast, like this:

static_cast<UnClass*>(c.get())->Square(10);

Since c.get() returns UnClass*, the cast is not necessary, and I
shouldn't be getting a compiler error. Is this expected behavior, or is
it a bug in Beta 2?

Tom
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: deko | last post by:
After developing an MDB in Access 2003 on WS03, then making it into an MDE and deploying it on a WinXP box with Access 2003 installed, I get this error: Function is not available in expressions...
18
by: Steve | last post by:
Hi I have a really weird problem and any assistance would be welcome. I have developed an app in Access 2002. The app runs perfectly on the development machine. I have packaged the app using...
3
by: pw | last post by:
Hi, I created and distributed an Access 2003 MDE. When the user opens up a form he get's an error message :Function is not available in expressions in query expression 'Trim( & ", " & )'. ...
5
by: Martin Jørgensen | last post by:
Hello again, Sorry to bother but I guess my C++ book isn't very good since it obviously contains errors so the program code doesn't work with g++. However I don't understand what the problem...
4
by: Cantell | last post by:
Hi everyone I have created a small db, in access 2000, on my own test machines it works excellent, however, upon transferring it to my colleague, I expierience a strange error code Function is...
1
by: Rymfax | last post by:
Hello, I was hoping someone could help me with a compile issue I'm having in Visual Studio 2005 using the v6.0 Microsoft SDK. I apologize in advance if I'm posting to any groups that don't relate...
8
by: Jess | last post by:
Hi, I have a template function that triggered some compiler error. The abridged version of the class and function is: #include<memory> using namespace std; template <class T>
5
by: elie.constantine | last post by:
Hello A person developed a Microsoft Access Solution and gave me the MDE file. When I tried to run it, I got "Function is not available in expressions in query expression 'Trim([......" Error. ...
1
by: Alberto Menchen | last post by:
Hi, I'm Alberto. I am trying to compile a program but I have an error that I don't know to solve. This program was built some years ago. Two mains problems, I think is in: doc/Makefile.am:24:...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.