473,729 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Candidate function(s) not accessible [?]

Hello,

Sorry another question on mixed code assemblys.

I have a static class library containing a lot of unmanged code.

I have created a mixed code assembly which I am attempting to use in a
forms project.

Thus,

Class Library:

"Types.h"

class someType
{
public:
someType(double val);
//load of unmanaged stuff
};

//////////////////////////////////////////////////

CLR Library:

#include "Types.h"

using namespace System;

namespace CLRLibrary {

public ref class MyAssembly
{
public:
MyAssembly(cons t someType& val);

private:
someType m_value;
};
}

//////////////////////////////////////////////////
Forms project:
#include "Types.h"
double val = System::Convert ::ToDouble(text Box1->Text);
CLRLibrary ::MyAssembly^ ass = gcnew CLRLibrary
::MyAssembly(so meType(val));

//////////////////////////////////////////////////

Now, I cant see any reason why this wouldnt work - indeed this seems
like a perfectly reasonable thing to want to do.

Problem is when I build the solution I get:-

Form1.h(100) : error C3767: 'CLRLibrary::My Assembly::MyAss embly':
candidate function(s) not accessible

Can anyone point me in the correct direction please? I have to admit to
getting a bit frustrated with C++/CLI

Aug 31 '06 #1
2 7881
<aj******@hushm ail.comwrote
class someType
{
public:
someType(double val);
//load of unmanaged stuff
};

//////////////////////////////////////////////////

CLR Library:

#include "Types.h"
It's important to understand that in the CLR type
identity is comprised of the definining assembly and its full
name.

The C++ compiler translates native types (such as someType)
to CLR value types.

When you share an include file between two different projects
(or actually between two projects generating different PE modules),
you end up with two distinct value type definitions.
using namespace System;

namespace CLRLibrary {

public ref class MyAssembly
{
public:
MyAssembly(cons t someType& val);
By default, CLR value types emitted for native types are not exported.
That means there is no way (well, sort of) to refer to these from outside
the assembly.
Forms project:
#include "Types.h"
double val = System::Convert ::ToDouble(text Box1->Text);
CLRLibrary ::MyAssembly^ ass = gcnew CLRLibrary
::MyAssembly(so meType(val));
Form1.h(100) : error C3767: 'CLRLibrary::My Assembly::MyAss embly':
candidate function(s) not accessible
I believe, the diagnostic tries to tell you that the ctor
is not accessible because on type in the signature is not visible
outside the assembly.

Consider the following example:

//t.cpp
struct N{};
public ref struct R { R( N* ){} };
// u.cpp
int main() { R r(0); }

// /clr:safe suppress a lot of metadata - you'll better understand ILDASM
cl /clr:safe /LD /wd4956 /wd4959 t.cpp
cl /clr /FUt.dll u.cpp
Can anyone point me in the correct direction please? I have to admit to
getting a bit frustrated with C++/CLI
You should try to avoid native types in managed signatures. Just use
standard C++ techniques (i.e. static libraries & header files) or
create wrappers for your types.

You can still use some hack to make the C++ compiler-generated
value type public (i.e. visible outside the assembly). But then you
shouldn't use #include to introduce your interface.

You can use a visibility specifier on your native types (i.e.:
public class someType{..}; )
and there's the make_public pragma.

-hg
Sep 1 '06 #2
Holger Grund wrote:
You should try to avoid native types in managed signatures. Just use
standard C++ techniques (i.e. static libraries & header files) or
create wrappers for your types.

You can still use some hack to make the C++ compiler-generated
value type public (i.e. visible outside the assembly). But then you
shouldn't use #include to introduce your interface.

You can use a visibility specifier on your native types (i.e.:
public class someType{..}; )
and there's the make_public pragma.

-hg
Many thanks for your reply.

I am having problems getting my head around how one would "properly"
design something using C++/CLI when using libraries of unmanaged code.

As I saw it I can create my static libraries of unmanaged code and then
create a series of assemblies that use this code but provide a managed
interface to this that refer to unmanged types.

I really dont want to provide a C++/CLI mapping class for each of the
unmanged types nor make these types managed.

For example I have a unmanaged struct that is used a lot in my
unmanaged library that contains a large number of ints/doubles that
seems a perfect candidate to be used in a managed function signature as
it isnt too complicated and to duplicate this structure in managed code
just so it can be used in a function signature seems *wrong*.

I have used make_public and my code compiles and links ok. But I am
concerned that this isnt a proper design solution.

Sep 4 '06 #3

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

Similar topics

4
1472
by: Anthony Baxter | last post by:
On behalf of the Python development team and the Python community, I'm happy to announce the first release candidate of Python 2.4. Python 2.4c1 is a release candidate - we'd greatly appreciate it if you could download it, kick the tires and let us know of any problems you find, but it is probably not suitable for production usage. At this point, we're particularly interested in build bugs. If you could grab the source archive, build it...
6
4409
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the same invocation from a DistantlyRelated class. What actually happened was that the compiler produced: error C2247: 'A::function' not accessible because 'CloselyRelated' uses 'private' to inherit from 'A' I'm guessing that the above compiler...
4
4521
by: Adriano Coser | last post by:
I'm getting the following error: error C3767: PictureSource - candidate function(s) not accessible when accessing a public member function of a managed class, either from managed or unmanaged code. The class is an owner draw control implemented into a Control Library. The access is on a DLLs that support CLR with old syntax. The code compiled OK on Beta-1.
3
5475
by: Steve Jaworski | last post by:
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);
0
1276
by: quortex | last post by:
Hey, I have a problem which I have no clue how to fix. I am using the CLI and some of the ref class constructors require a native type to be passed in. Obviously because the 2005 CLI now imports types by default as private rather than public we need to specify these types as public in the appropriate source files with
0
1064
by: Edward Diener | last post by:
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
2
3477
by: Iwanow | last post by:
Hello! I have a single class without any inheritance over there, and I get that error on its constructor which is an empty function: LabelProcessor::LabelProcessor() { } The full error message is as follows:
9
1775
by: Gilbert | last post by:
Hi, In the code-behind, i have this function: Public Function myfunction(ByVal myvar As Object) As String dim x as string = myvar ..... Return x End Function
16
1703
by: =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= | last post by:
On behalf of the Python development team and the Python community, I'm happy to announce the release of Python 2.5.2 (release candidate 1). This is the second bugfix release of Python 2.5. Python 2.5 is now in bugfix-only mode; no new features are being added. According to the release notes, over 100 bugs and patches have been addressed since Python 2.5.1, many of them improving the stability of the interpreter, and improving its...
0
8917
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9426
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8148
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.