내 상황은 이렇습니다."보호 수준으로 인해"C# 컴파일에 실패했습니다.
3 개의 프로젝트가 있습니다.
PrivacyDetectorDLL PDWrapper WindowsFormsApplication1 (C#을)
내 목표는 C#으로 네이티브 C++ 클래스를 사용하는 것입니다. 그래서 C++/Cli 래퍼 클래스를 사용했습니다. 그러나 보호 수준에 오류가 발생합니다. 나는 그것을 얻지 않는다.
이 오류가 발생합니다.
Error 1 'PDWrapper.PDWrapperClass.m_pCPrivacyDetectEngine' is inaccessible due to its protection level K:\Visual Studio 2010 Project\PrivacyDetecter\WindowsFormsApplication1\Form1.cs 23
WindowsFormsApplication1 프로젝트의 C# 코드는 다음과 같습니다.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public PDWrapper.PDWrapperClass m_PDWrapper = null;
public Form1()
{
m_PDWrapper = new PDWrapper.PDWrapperClass();
unsafe
{
m_PDWrapper.m_pCPrivacyDetectEngine->initEngine();
}
InitializeComponent();
}
}
}
내 PDWrapper 클래스는 다음과 같습니다.
// PDWrapper.h
#pragma once
using namespace System;
namespace PDWrapper {
public ref class PDWrapperClass
{
// TODO: Add your methods for this class here.
public :
PDWrapperClass();
~PDWrapperClass();
public :
CPrivacyDetectEngine* m_pCPrivacyDetectEngine;
};
}
그리고 이것은 내 PrivacyDetectEngine 헤더 (PDWrapper 프로젝트에서 헤더)입니다
#pragma once
class CPrivacyDetectEngine
{
public: // my func
CPrivacyDetectEngine(void);
~CPrivacyDetectEngine(void);
void CPrivacyDetectEngine::initEngine();
void CPrivacyDetectEngine::startEngine(char* currentPath, size_t length);
public: // my util func
int CPrivacyDetectEngine::bytecmp(unsigned char *a, unsigned char *b, int length);
void CPrivacyDetectEngine::extToNum(char* fileName, unsigned int* extNum);
int CPrivacyDetectEngine::checkFileSig(unsigned char* fileSig, int sigLength, char* filePath, char** pFileInternal);
void CPrivacyDetectEngine::parseMSDocText(char** pFileInternal, unsigned int* compSize, unsigned int* decompSize);
char* CPrivacyDetectEngine::infData(char* pFileData, int compSize, int decompSize);
void CPrivacyDetectEngine::privacyDetectXML(char* text, int textLength, int* pItemIndex, char* filePath);
void CPrivacyDetectEngine::checkSocialNum(char* text);
public: // my var
int driverCount;
char driverName[256];
unsigned int parseFileList;
};
PrivacyDetectorDLL에서 내 PrivacyDetectEngine 헤더가 동일하지만
class __declspec(dllexport) CPrivacyDetectEngine
같은 클래스 CPrivacyDetectEngine 사이 __declspec (dllexport)를 가지고있다
나는 무엇이 문제인지 잘 모른다. ... 누군가 나를 도와주세요.
모든 프로젝트를 재구성 했습니까? – SLaks
'class CPrivacyDetectEngine'을'public class CPrivacyDetectEngine'으로 표시하십시오. – Saravanan