473,503 Members | 972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

c++ and custom section

GOE
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_DEFA ULT);
eventLogEnabled = EVENTLOG_ENABLED_DEFAULT;
eventLogMachineName =
const_cast<String*>(EVENTLOG_MACHINENAME_DEFAULT);
eventLogSourceName =
const_cast<String*>(EVENTLOG_SOURCENAME_DEFAULT);
eventLogTraceLevel =
static_cast<TraceLevel>(EVENTLOG_TRACELEVEL_DEFAUL T);
}
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_DEFA ULT));
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_DEFAUL T));
}

return 0;
}
........
};
}
Nov 19 '05 #1
0 1016

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2132
by: Hazzard | last post by:
I am trying to create a custom section and section handler in my config file. The custom section should be something like; <appSecurity> <method name = "Protect the Ice Cream"> <allow group =...
3
1491
by: Mauricio | last post by:
Hí! I´m implementing a web application using the Front Controller pattern described in the Enterprice Solutions Patters using Microsoft .NET v 1.0 In order to map an absolute path to...
0
1826
by: Søren Lund | last post by:
Hello, I have implemented a custom config section handler by implementing the IConfigurationSectionHandler interface. I have registered this handler in web.config and everything works fine ......
4
1901
by: Nick Gilbert | last post by:
Hi, I would like the ability to store the configuration settings for all versions of my site in a single web.config file by using different sections. Eg: <siteConfig> <machine name="XENON">...
6
3787
by: Tabi | last post by:
Hi, I want to create a custom section in my web.config that can hold my custom values. I created a section in web.config as written below. <configSections> <section name="myCustomSection"...
19
4890
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
2
1525
by: Laurent Bugnion | last post by:
Hi, I like to develop custom controls for a number of webpages. These controls are often customizable, so that they can be reused in a number of situations. My question is: What is the best...
0
1232
by: mnowosad | last post by:
This problem has become a "show-stopper" for us. I have defined a custom section for my web application that contains sensitive data. Because of that, I want to have it encrypted in the same way I...
7
10808
by: =?Utf-8?B?RG91Z2llIEJyb3du?= | last post by:
Hi I've written custom configuration section (inherits from System.Configuration.ConfigurationSection) to simplify the contents of the config file and to make life easier when accessing them in...
2
5088
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7463
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.