472,371 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 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 5330

--
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
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.