473,698 Members | 2,404 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 7877
<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
1469
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
4406
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
4520
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
5474
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
1274
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
1063
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
3473
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
1771
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
1697
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
9160
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
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6521
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
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
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
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2002
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.