VS 2005 Beta 2 - error C3767: candidate function(s) not accessible

A

Adriano Coser

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.

Bellow is the hearder file for the accessed class. The error occours
accessing PictureSource function. TPictureSource is an unmanaged
class, but I don't think that could be the problem.

Does anyone have a clue?

Thanks in advance for any help.

Regards,
Adriano.

#pragma once

#include "PictureSource.h"

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Diagnostics;
using namespace System::Drawing;

namespace QiVControls
{
/// <summary>
/// Summary for PictureListBox
/// </summary>
[ToolboxBitmap(__typeof(Windows::Forms::ListBox))]
__gc public class PictureListBox : public Windows::Forms::ListBox
{
public:
PictureListBox(void)
{
InitializeComponent();
InitializeWindow();
}
PictureListBox(System::ComponentModel::IContainer *container) :
components(0)
{
/// <summary>
/// Required for Windows.Forms Class Composition Designer support
/// </summary>
container->Add(this);
InitializeComponent();
InitializeWindow();
}

TPictureSource* PictureSource();

void PictureSource(TPictureSource* _pictureSource);

protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}

private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container *components;

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
//
// PictureListBox
//
this->DrawMode = System::Windows::Forms::DrawMode::OwnerDrawFixed;
this->DrawItem += new
System::Windows::Forms::DrawItemEventHandler(this,
&PictureListBox::DrawItemPictureListBox);
}

TPictureSource* pictureSource;

private:
System::Void DrawItemPictureListBox(
System::Object * sender,
System::Windows::Forms::DrawItemEventArgs * e);

void InitializeWindow();

};
}
 
K

Kapil Khosla [MSFT]

--
This posting is provided "AS IS" with no warranties, and confers no
rights."Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"

Adriano Coser said:
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.

Bellow is the hearder file for the accessed class. The error occours
accessing PictureSource function. TPictureSource is an unmanaged
class, but I don't think that could be the problem.

Does anyone have a clue?

Thanks in advance for any help.

Regards,
Adriano.

#pragma once

#include "PictureSource.h"

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Diagnostics;
using namespace System::Drawing;

namespace QiVControls
{
/// <summary>
/// Summary for PictureListBox
/// </summary>
[ToolboxBitmap(__typeof(Windows::Forms::ListBox))]
__gc public class PictureListBox : public Windows::Forms::ListBox
{
public:
PictureListBox(void)
{
InitializeComponent();
InitializeWindow();
}
PictureListBox(System::ComponentModel::IContainer *container) :
components(0)
{
/// <summary>
/// Required for Windows.Forms Class Composition Designer support
/// </summary>
container->Add(this);
InitializeComponent();
InitializeWindow();
}

TPictureSource* PictureSource();

void PictureSource(TPictureSource* _pictureSource);

protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}

private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container *components;

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
//
// PictureListBox
//
this->DrawMode = System::Windows::Forms::DrawMode::OwnerDrawFixed;
this->DrawItem += new
System::Windows::Forms::DrawItemEventHandler(this,
&PictureListBox::DrawItemPictureListBox);
}

TPictureSource* pictureSource;

private:
System::Void DrawItemPictureListBox(
System::Object * sender,
System::Windows::Forms::DrawItemEventArgs * e);

void InitializeWindow();

};
}


The error message is issued if you try to access a member function which
does not have the required access level. In your case the function
declaration is public so we should not issue this error. Could you also post
some code which will help us repro the problem ? Like the C++ file where the
function is being called from?
Thanks,
Kapil
 
A

Adriano Coser

Thanks for answering Kapil.

I made a new app and tried to use my component (PictureListBox) and I
got the error. It must be something wrong with my control dll, but I
can't see what it is, as it works fine on VC 2005 Beta 1.

Bellow is the source code for the main form. See Form1_Load method.

Thanks for your help.
Regards,
Adriano.

The compiler output:
------ Build started: Project: C3767App, Configuration: Debug Win32
------
Compiling...
C3767App.cpp
c:\temp\c3767app\Form1.h(91) : error C3767:
'QiVControls::pictureListBox::pictureSource': candidate function(s)
not accessible
Build log was saved at "file://c:\Temp\C3767App\Debug\BuildLog.htm"
C3767App - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========


#pragma once


namespace C3767App
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to
change the
/// 'Resource File Name' property for the managed resource
compiler tool
/// associated with all .resx files this class depends on.
Otherwise,
/// the designers will not be able to interact properly with
localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">"description of the parameter"</param>
virtual void Dispose(Boolean disposing) override
{
if (disposing && components)
{
delete components;
}
__super::Dispose(disposing);
}
private: QiVControls::pictureListBox^ pictureListBox1;
protected:
private: System::ComponentModel::IContainer^ components;

private:
/// <summary>
/// Required designer variable.
/// </summary>


#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
this->pictureListBox1 = (gcnew
QiVControls::pictureListBox(this->components));
this->SuspendLayout();
//
// pictureListBox1
//
this->pictureListBox1->DrawMode =
System::Windows::Forms::DrawMode::OwnerDrawFixed;
this->pictureListBox1->FormattingEnabled = true;
this->pictureListBox1->Location = System::Drawing::point(49,
51);
this->pictureListBox1->Name = L"pictureListBox1";
this->pictureListBox1->Size = System::Drawing::Size(120, 95);
this->pictureListBox1->TabIndex = 0;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode =
System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 266);
this->Controls->Add(this->pictureListBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this,
&Form1::Form1_Load);
this->ResumeLayout(false);

}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
pictureListBox1->PictureSource(0);
}
};
}
 
K

Kapil Khosla [MSFT]

Allright, I figured out what was going on here. 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.
I have copied some code below which reproduces the problem if you remove the
public keyword from the native type.

//n.cpp

#pragma once
#using "system.dll"
#using "system.windows.forms.dll"
#using "system.drawing.dll"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Diagnostics;
using namespace System::Drawing;


public class __declspec(dllexport) TPictureSource {}; // Use public infront
of your native type !!


public ref class R{};

public ref class PictureListBox
{
public:
void PictureSource(TPictureSource* _pictureSource){}
};



#using "system.dll"
#using "system.data.dll"
#using "system.drawing.dll"
#using "System.Windows.Forms.dll"
#using "n.dll"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Windows::Forms;

class __declspec(dllimport) TPictureSource
{

};

public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
}

private: PictureListBox^ pictureListBox1;
System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
TPictureSource *obj;
pictureListBox1->PictureSource(obj);
}
};


Please let me know if this fixes your problem.
Thanks,
Kapil
 
A

Adriano Coser

Kapil.

This is exactly the problem, I put 'public' before TPictureSource definition
and it's compiling OK now.
Thank you very much for your help.

Adriano.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top