If I install .Net SDK and uses Sample Code, VS says: Cannot resolve symbol 'Configuration' at this line:
var apiContext = Configuration.GetAPIContext();
So, what DLL or namespaces did I missed?
It is a wrapper class around the configuration section.
Please look into \PayPal-NET-SDK-develop\Samples\Source\Utilities\Configuration.cs and create it to suit your configuration.
Don't forget to modify your web.config or app.config
<configSections>
<section name="paypal" type="PayPal.SDKConfigHandler, PayPal" />
</configSections>
<!-- PayPal SDK settings -->
<paypal>
<settings>
<add name="mode" value="sandbox" />
<add name="clientId" value="youclientid" />
<add name="clientSecret" value="yoursecret" />
</settings>
</paypal>
Related
We need to setup following properties in config file to enable native encryption of oracle
SQLNET.CRYPTO_CHECKSUM_TYPES_CLIENT = (MD5)
SQLNET.ENCRYPTION_TYPES_CLIENT = (AES256)
SQLNET.ENCRYPTION_CLIENT = required
SQLNET.CRYPTO_CHECKSUM_CLIENT = required
Below is the link where I found out it can be done through config file (search for the above properties in link page e.g. ENCRYPTION_CLIENT)
https://docs.oracle.com/cd/E63277_01/win.121/e63268/InstallManagedConfig.htm#ODPNT8164
I was not able to find any good example till now.
Can anyone provide an example or link to see how to enable encryption from config file.
In Configuration section add the below lines.
<configSections>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
Connection String:
<add key="ConnectionString" value="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server name)(PORT=XXXX))(CONNECT_DATA=(SERVICE_NAME=service name)));" />
Add the below section under runtime section:
<oracle.manageddataaccess.client>
<version number="*">
<settings>
<setting name="sqlnet.encryption_types_client" value="aes256" />
<setting name="sqlnet.encryption_client" value="required" />
</settings>
</version>
</oracle.manageddataaccess.client>
I have XML looking like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="profile">
<section name="server1" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=a1a1a1a1a1a1a1a1, Custom=null" />
<section name="server2" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=a1a1a1a1a1a1a1a1, Custom=null" />
<section name="server3" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=a1a1a1a1a1a1a1a1, Custom=null" />
</sectionGroup>
</configSections>
<profile>
<server1>
<add key="server" value="serverName1" />
<add key="check" value="0" />
<add key="user" value="sa" />
<add key="psw" value="secret" />
<add key="show" value="1" />
</server1>
<server2>
<add key="server" value="serverName2" />
<add key="check" value="0" />
<add key="user" value="sa" />
<add key="psw" value="secret" />
<add key="show" value="1" />
</server2>
<server3>
<add key="server" value="serverName3" />
<add key="check" value="0" />
<add key="user" value="sa" />
<add key="psw" value="secret" />
<add key="show" value="1" />
</server3>
</profile>
</configuration>
and I would like to create XSD schema for its validation. I have tried it with online XSD generators like https://www.freeformatter.com/xsd-generator.html with any of 3 types of XSD Design but the problem is that validation will not pass if there is any other number of servers in XML beside 3.
Any help or advice for software or other online XSD generators which can account for this randomness is very much appreciated?
There is no way in XSD (other than XSD 1.1 assertions) to say 'the children of this element must be named "server1", "server2", ... "serverN" in order'. XSD is a bit paternalistic like this: it's not designed to describe any XML you might dream up, it's designed to describe well-designed XML. You should drop the digit and call all the elements "server"; or if the digit serves some purpose (e.g. if it's retained after some server elements are deleted from the XML), then make it an attribute value: <server id="server1".../>
I've always found that XSD.exe does a pretty good job. This validator is also pretty good too. On top of that you could try the XML Tools plugin in Notepad++.
With complex XML documents it's often easier to build them up slowly, so start with a simplified version and then gradually add other parts.
This tutorial and this one are both very good and are definitely worth looking at if you're struggling with xsds.
I suggest you have a look at the tutorials and then maybe rethink what you want and restructure your xml accordingly. An obvious first question might be how do server1, server2, and server3 differ? If they're all the same you want three instances of server; if they're different you probably want to capture that somehow in your xml.
How to fetch the corresponding value of a key that I would get dynamically. I wish to use the system defined DictionarySectionHandler to do the job, of fetching the data from my custom built config section in the Web.config file
Code block in Web.Config
<section name="domainsource" type="System.Configuration.DictionarySectionHandler"/>
<domainSource>
<add key="0" value="170" />
<add key="1" value="171" />
<add key="2" value="172" />
<add key="3" value="173" />
<add key="12" value="174" />
</domainSource>
Sourcecode in the main cs file from where I wish to retrieve the data from the Web.Config
Hashtable statusCodes = ConfigurationManager.GetSection("domainSource") as Hashtable;
vDomainSource = statusCodes[vDomainID];
This is where I am stuck vDomainID would be a value 0/1/2/3/12, based on this value I need to fetch its respective Source from the Web.Config. Any help on this aspect would be really appreciated.
You have a missspelling in the defintion of the section domainsource -> domainSource. Further ensure that the elemnt is defined in an element. Then it should work.
<configuration>
<configSections>
<section name="domainSource" type="System.Configuration.DictionarySectionHandler"/>
</configSections>
<domainSource>
<add key="0" value="170" />
<add key="1" value="171" />
<add key="2" value="172" />
<add key="3" value="173" />
<add key="12" value="174" />
</domainSource>
</configuration>
When i add this code to app.config in Windows service program:
<quartz>
<add key="quartz.scheduler.instanceName" value="ExampleDefaultQuartzScheduler"/>
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz"/>
<add key="quartz.threadPool.threadCount" value="10"/>
<add key="quartz.threadPool.threadPriority" value="2"/>
<add key="quartz.jobStore.misfireThreshold" value="60000"/>
<add key="quartz.jobStore.type" value="Quartz.Simpl.RAMJobStore, Quartz"/>
</quartz>
it tips:
Could not find schema information for the element `key`.
Could not find schema information for the attribute `quartz`.
Could not find schema information for the element `value`.
I am sure i have using job_scheduling_data_2_0.xsd file in background.
And predefine the quartz:
<configSections>
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
Where is the problem?And where to find the schema info?
And when is the label <quartz> namespace?
Where should i find the xsd file of quartz.net?
Normal reason is your config file lack of schema file like *.xsd in:..\Microsoft Visual Studio\Xml\Schemas folder.
You can omit these tips,it could not affect your program running.
Or you can write the xsd schema file by yourself.
I need to get "http://example.com" from using App.config file.
But at the moment I am using:
string peopleXMLPath = ConfigurationManager.AppSettings["server"];
I cannot get the value.
Could you point out what I am doing wrong?
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<section name="device" type="System.Configuration.SingleTagSectionHandler" />
<section name="server" type="System.Configuration.SingleTagSectionHandler" />
</configSections>
<device id="1" description="petras room" location="" mall="" />
<server url="http://example.com" />
</configuration>
I think you need to get the config section, and access that:
var section = ConfigurationManager.GetSection("server") as NameValueCollection;
var value = section["url"];
And you also need to update your config file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<section name="device" type="System.Configuration.NameValueSectionHandler" />
<section name="server" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<device>
<add key="id" value="1" />
<add key="description" value="petras room" />
<add key="location" value="" />
<add key="mall" value="" />
</device>
<server>
<add key="url" value="http://example.com" />
</server>
</configuration>
Edit: As CodeCaster mentioned in his answer, SingleTagSectionHandler is for internal use only. I think NameValueSectionHandler is the preferred way to define config sections.
The SingleTagSectionHandler documentation says:
This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.
You can retrieve it as a HashTable and access its entries using Configuration.GetSection():
Hashtable serverTag = (Hashtable)ConfigurationManager.GetSection("server");
string serverUrl = (string)serverTag["url"];
string peopleXMLPath = ConfigurationManager.AppSettings["server"];
gets the value from the appSettings part of the app.config file but you are storing your value in
<server url="http://example.com" />
Either put the value in the appSettings section as below or retrieve the value from its current location.
You need to add a key value pair to your config's appSettings section. As below:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="server" value="http://example.com" />
</appSettings>
</configuration>
Your reading code is correct but you should probably check for null. If the code fails to read the config value the string variable will be null.
You're defining a configuration section instead of a value in AppSettings. You can simply add your setting to AppSettings:
<appSettings>
... may be some settings here already
<add key="server" value="http://example.com" />
</appSettings>
Custom config sections are typically used for more complicated configurations (e.g. multiple values per key, non-string values, etc.
If you want to get the value from the app settings your appsetting element in configuration file must have a key.
define your sever value as mentioned below under configuration section:
<configuration>
<appSettings>
<add key="server" value="http://example.com" />
</appSettings>
...
...
...
</configuration>
Now execute below code line to get the server url:
string peopleXMLPath = ConfigurationManager.AppSettings["server"].ToString();