c++ and custom section

G

Guest

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.TypeLoadException: accemble SystemFramework, Version=1.0.1873.4208,
Culture=neutral, PublicKeyToken=null" type
"SystemFramework.ApplicationConfiguration" 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::Configuration;
using namespace System::Diagnostics;
using namespace System::Xml;
using namespace System::Collections;
using namespace System::Collections::Specialized;


namespace SystemFramework
{
__gc public class ApplicationConfiguration : public
IConfigurationSectionHandler
{

public:
ApplicationConfiguration(){};

private:
static String* appRoot;

static const String* TRACING_ENABLED = "SystemFramework.Tracing.Enabled";
static const String* TRACING_TRACEFILE =
"SystemFramework.Tracing.TraceFile";
static const String* TRACING_TRACELEVEL =
"SystemFramework.Tracing.TraceLevel";
static const String* TRACING_SWITCHNAME =
"SystemFramework.Tracing.SwitchName";
static const String* TRACING_SWITCHDESCRIPTION =
"SystemFramework.Tracing.SwitchDescription";
static const String* EVENTLOG_ENABLED = "SystemFramework.EventLog.Enabled";
static const String* EVENTLOG_MACHINENAME =
"SystemFramework.EventLog.Machine";
static const String* EVENTLOG_SOURCENAME =
"SystemFramework.EventLog.SourceName";
static const String* EVENTLOG_TRACELEVEL =
"SystemFramework.EventLog.LogLevel";

static const bool TRACING_ENABLED_DEFAULT = true;
static const String* TRACING_TRACEFILE_DEFAULT =
"ApplicationTrace.txt";
static const TraceLevel TRACING_TRACELEVEL_DEFAULT = TraceLevel::Verbose;
static const String* TRACING_SWITCHNAME_DEFAULT =
"ApplicationTraceSwitch";
static const String* TRACING_SWITCHDESCRIPTION_DEFAULT =
"Application error and tracing information";
static const bool EVENTLOG_ENABLED_DEFAULT = true;
static const String* EVENTLOG_MACHINENAME_DEFAULT = ".";
static const String* EVENTLOG_SOURCENAME_DEFAULT = "WebApplication";
static const TraceLevel EVENTLOG_TRACELEVEL_DEFAULT = TraceLevel::Error;

public:
Object* Create(Object* parent, Object* configContext,
System::Xml::XmlNode* section)
{

NameValueCollection* settings = new NameValueCollection();

try
{
NameValueSectionHandler* baseHandler = new
NameValueSectionHandler();
settings =
__try_cast<NameValueCollection*>(baseHandler->Create(parent, configContext,
section));
}
catch(System::Exception*)
{
settings = 0;
}

if (settings == 0)
{
tracingEnabled = TRACING_ENABLED_DEFAULT;
tracingTraceFile =
const_cast<String*>(TRACING_TRACEFILE_DEFAULT);
tracingTraceLevel =
static_cast<TraceLevel>(TRACING_TRACELEVEL_DEFAULT);
tracingSwitchName =
const_cast<String*>(TRACING_SWITCHNAME_DEFAULT);
tracingSwitchDescription =
const_cast<String*>(TRACING_SWITCHDESCRIPTION_DEFAULT);
eventLogEnabled = EVENTLOG_ENABLED_DEFAULT;
eventLogMachineName =
const_cast<String*>(EVENTLOG_MACHINENAME_DEFAULT);
eventLogSourceName =
const_cast<String*>(EVENTLOG_SOURCENAME_DEFAULT);
eventLogTraceLevel =
static_cast<TraceLevel>(EVENTLOG_TRACELEVEL_DEFAULT);
}
else
{
tracingEnabled = ReadSetting(settings,
const_cast<String*>(TRACING_ENABLED), TRACING_ENABLED_DEFAULT);
tracingTraceFile = ReadSetting(settings,
const_cast<String*>(TRACING_TRACEFILE),
const_cast<String*>(TRACING_TRACEFILE_DEFAULT));
tracingTraceLevel = ReadSetting(settings,
const_cast<String*>(TRACING_TRACELEVEL),
static_cast<TraceLevel>(TRACING_TRACELEVEL_DEFAULT));
tracingSwitchName = ReadSetting(settings,
const_cast<String*>(TRACING_SWITCHNAME),
const_cast<String*>(TRACING_SWITCHNAME_DEFAULT));
tracingSwitchDescription = ReadSetting(settings,
const_cast<String*>(TRACING_SWITCHDESCRIPTION),
const_cast<String*>(TRACING_SWITCHDESCRIPTION_DEFAULT));
eventLogEnabled = ReadSetting(settings,
const_cast<String*>(EVENTLOG_ENABLED), EVENTLOG_ENABLED_DEFAULT);
eventLogMachineName = ReadSetting(settings,
const_cast<String*>(EVENTLOG_MACHINENAME),
const_cast<String*>(EVENTLOG_MACHINENAME_DEFAULT));
eventLogSourceName = ReadSetting(settings,
const_cast<String*>(EVENTLOG_SOURCENAME),
const_cast<String*>(EVENTLOG_SOURCENAME_DEFAULT));
eventLogTraceLevel = ReadSetting(settings,
const_cast<String*>(EVENTLOG_TRACELEVEL),
static_cast<TraceLevel>(EVENTLOG_TRACELEVEL_DEFAULT));
}

return 0;
}
........
};
}
 

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

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top