G
Guest
Hello,
I want to give multiple native classes (in different mixed mode dlls) access
to a managed output window (for error messages). Therefore I wrote a native
singleton with __declspec (dllexport). I get the following compiler errors:
Error 224 error C3389: __declspec(dllexport) cannot be used with /clrure
or /clr:safe
Error 225 error C4394: 'ErrorHandler::instance' : per-appdomain symbol
should not be marked with __declspec(dllexport)
Error 226 error C4394: 'private: static ErrorHandler *
ErrorHandler::instance' : per-appdomain symbol should not be marked with
__declspec(dllexport)
Error 228 error C3395: 'ErrorHandler::GetInstance' : __declspec(dllexport)
cannot be applied to a function with the __clrcall calling convention
and the same with the other methods of the class. The dll is definitely not
set to /clrure or /clr:safe.
I could not reproduce resp. localize the problem with a test program.
I will attach my class below.
Thanks for your help,
Fabian
<SNIP>
#include <stdlib.h>
#include "vcclr.h"
using namespace DebugTools;
#using <System.Windows.Forms.dll>
#pragma once
class __declspec( dllexport ) ErrorHandler
{
private:
static ErrorHandler* instance;
gcroot<FormDebugOutput^> formDebugOutput;
public:
static ErrorHandler* GetInstance()
{
if (instance == NULL)
{
instance = new ErrorHandler();
_onexit(destroyInstance); // A _onexit function is called when the
process exits normally.
}
return instance;
}
void PrintMessage(char* Source, char* Message)
{
if (!formDebugOutput)
{
formDebugOutput->PrintMessage((signed char*)Source, (signed char*)Message);
}
}
void SetDebugForm(gcroot<FormDebugOutput^> FormDebugOutput)
{
formDebugOutput = FormDebugOutput;
}
private:
ErrorHandler()
{
formDebugOutput = nullptr;
}
static int destroyInstance()
{
delete instance;
instance = NULL;
return 0;
}
};
</SNIP>
FormDebugOutput is a form in a C#-DLL derived from Windows.Forms.Form.
I want to give multiple native classes (in different mixed mode dlls) access
to a managed output window (for error messages). Therefore I wrote a native
singleton with __declspec (dllexport). I get the following compiler errors:
Error 224 error C3389: __declspec(dllexport) cannot be used with /clrure
or /clr:safe
Error 225 error C4394: 'ErrorHandler::instance' : per-appdomain symbol
should not be marked with __declspec(dllexport)
Error 226 error C4394: 'private: static ErrorHandler *
ErrorHandler::instance' : per-appdomain symbol should not be marked with
__declspec(dllexport)
Error 228 error C3395: 'ErrorHandler::GetInstance' : __declspec(dllexport)
cannot be applied to a function with the __clrcall calling convention
and the same with the other methods of the class. The dll is definitely not
set to /clrure or /clr:safe.
I could not reproduce resp. localize the problem with a test program.
I will attach my class below.
Thanks for your help,
Fabian
<SNIP>
#include <stdlib.h>
#include "vcclr.h"
using namespace DebugTools;
#using <System.Windows.Forms.dll>
#pragma once
class __declspec( dllexport ) ErrorHandler
{
private:
static ErrorHandler* instance;
gcroot<FormDebugOutput^> formDebugOutput;
public:
static ErrorHandler* GetInstance()
{
if (instance == NULL)
{
instance = new ErrorHandler();
_onexit(destroyInstance); // A _onexit function is called when the
process exits normally.
}
return instance;
}
void PrintMessage(char* Source, char* Message)
{
if (!formDebugOutput)
{
formDebugOutput->PrintMessage((signed char*)Source, (signed char*)Message);
}
}
void SetDebugForm(gcroot<FormDebugOutput^> FormDebugOutput)
{
formDebugOutput = FormDebugOutput;
}
private:
ErrorHandler()
{
formDebugOutput = nullptr;
}
static int destroyInstance()
{
delete instance;
instance = NULL;
return 0;
}
};
</SNIP>
FormDebugOutput is a form in a C#-DLL derived from Windows.Forms.Form.