I wrote the C++ project which impersonate Duwamish sample,when I wrote some
code about custom section,it don't work and show the exception:
"System.TypeLoa dException: accemble SystemFramework , Version=1.0.187 3.4208,
Culture=neutral , PublicKeyToken= null" type
"SystemFramewor k.ApplicationCo nfiguration" method of "Create" didn't
implement.
I rewrote the code by C#,and the web.config file was the same one, it work
very well. I can't find what's the matter.Who can tell me why?
thank you.
My C++ code like this:
using namespace System;
using namespace System::Configu ration;
using namespace System::Diagnos tics;
using namespace System::Xml;
using namespace System::Collect ions;
using namespace System::Collect ions::Specializ ed;
namespace SystemFramework
{
__gc public class ApplicationConf iguration : public
IConfigurationS ectionHandler
{
public:
ApplicationConf iguration(){};
private:
static String* appRoot;
static const String* TRACING_ENABLED = "SystemFramewor k.Tracing.Enabl ed";
static const String* TRACING_TRACEFI LE =
"SystemFramewor k.Tracing.Trace File";
static const String* TRACING_TRACELE VEL =
"SystemFramewor k.Tracing.Trace Level";
static const String* TRACING_SWITCHN AME =
"SystemFramewor k.Tracing.Switc hName";
static const String* TRACING_SWITCHD ESCRIPTION =
"SystemFramewor k.Tracing.Switc hDescription";
static const String* EVENTLOG_ENABLE D = "SystemFramewor k.EventLog.Enab led";
static const String* EVENTLOG_MACHIN ENAME =
"SystemFramewor k.EventLog.Mach ine";
static const String* EVENTLOG_SOURCE NAME =
"SystemFramewor k.EventLog.Sour ceName";
static const String* EVENTLOG_TRACEL EVEL =
"SystemFramewor k.EventLog.LogL evel";
static const bool TRACING_ENABLED _DEFAULT = true;
static const String* TRACING_TRACEFI LE_DEFAULT =
"ApplicationTra ce.txt";
static const TraceLevel TRACING_TRACELE VEL_DEFAULT = TraceLevel::Ver bose;
static const String* TRACING_SWITCHN AME_DEFAULT =
"ApplicationTra ceSwitch";
static const String* TRACING_SWITCHD ESCRIPTION_DEFA ULT =
"Applicatio n error and tracing information";
static const bool EVENTLOG_ENABLE D_DEFAULT = true;
static const String* EVENTLOG_MACHIN ENAME_DEFAULT = ".";
static const String* EVENTLOG_SOURCE NAME_DEFAULT = "WebApplication ";
static const TraceLevel EVENTLOG_TRACEL EVEL_DEFAULT = TraceLevel::Err or;
public:
Object* Create(Object* parent, Object* configContext,
System::Xml::Xm lNode* section)
{
NameValueCollec tion* settings = new NameValueCollec tion();
try
{
NameValueSectio nHandler* baseHandler = new
NameValueSectio nHandler();
settings =
__try_cast<Name ValueCollection *>(baseHandler->Create(paren t, configContext,
section));
}
catch(System::E xception*)
{
settings = 0;
}
if (settings == 0)
{
tracingEnabled = TRACING_ENABLED _DEFAULT;
tracingTraceFil e =
const_cast<Stri ng*>(TRACING_TR ACEFILE_DEFAULT );
tracingTraceLev el =
static_cast<Tra ceLevel>(TRACIN G_TRACELEVEL_DE FAULT);
tracingSwitchNa me =
const_cast<Stri ng*>(TRACING_SW ITCHNAME_DEFAUL T);
tracingSwitchDe scription =
const_cast<Stri ng*>(TRACING_SW ITCHDESCRIPTION _DEFAULT);
eventLogEnabled = EVENTLOG_ENABLE D_DEFAULT;
eventLogMachine Name =
const_cast<Stri ng*>(EVENTLOG_M ACHINENAME_DEFA ULT);
eventLogSourceN ame =
const_cast<Stri ng*>(EVENTLOG_S OURCENAME_DEFAU LT);
eventLogTraceLe vel =
static_cast<Tra ceLevel>(EVENTL OG_TRACELEVEL_D EFAULT);
}
else
{
tracingEnabled = ReadSetting(set tings,
const_cast<Stri ng*>(TRACING_EN ABLED), TRACING_ENABLED _DEFAULT);
tracingTraceFil e = ReadSetting(set tings,
const_cast<Stri ng*>(TRACING_TR ACEFILE),
const_cast<Stri ng*>(TRACING_TR ACEFILE_DEFAULT ));
tracingTraceLev el = ReadSetting(set tings,
const_cast<Stri ng*>(TRACING_TR ACELEVEL),
static_cast<Tra ceLevel>(TRACIN G_TRACELEVEL_DE FAULT));
tracingSwitchNa me = ReadSetting(set tings,
const_cast<Stri ng*>(TRACING_SW ITCHNAME),
const_cast<Stri ng*>(TRACING_SW ITCHNAME_DEFAUL T));
tracingSwitchDe scription = ReadSetting(set tings,
const_cast<Stri ng*>(TRACING_SW ITCHDESCRIPTION ),
const_cast<Stri ng*>(TRACING_SW ITCHDESCRIPTION _DEFAULT));
eventLogEnabled = ReadSetting(set tings,
const_cast<Stri ng*>(EVENTLOG_E NABLED), EVENTLOG_ENABLE D_DEFAULT);
eventLogMachine Name = ReadSetting(set tings,
const_cast<Stri ng*>(EVENTLOG_M ACHINENAME),
const_cast<Stri ng*>(EVENTLOG_M ACHINENAME_DEFA ULT));
eventLogSourceN ame = ReadSetting(set tings,
const_cast<Stri ng*>(EVENTLOG_S OURCENAME),
const_cast<Stri ng*>(EVENTLOG_S OURCENAME_DEFAU LT));
eventLogTraceLe vel = ReadSetting(set tings,
const_cast<Stri ng*>(EVENTLOG_T RACELEVEL),
static_cast<Tra ceLevel>(EVENTL OG_TRACELEVEL_D EFAULT));
}
return 0;
}
........
};
}