I get an error when I use CyberSource's tutorial/demo code from their documentation.
http://apps.cybersource.com/library/documentation/dev_guides/Simple_Order_API_Clients/Client_SDK_SO_API.pdf Page: 220
Any help here? I have no clue what keysDirectory is
hi all you have to do is add the key in config file like so...
<add key="cybs.keysDirectory" value="c:\keys\"/>
<add key="cybs.keyFilename" value="????"/>
Related
I've got an application that runs without problem with the File and Console Sinks and now I'm trying to add the MSSqlServer Sink.
Looking at the documentation on Github I've got my application to write to the SQL Database as well as the other sinks.
<add key="serilog:write-to:MSSqlServer.connectionString" value="Server=servername;Database=databasename;User Id=userid;Password=password;"/>
<add key="serilog:write-to:MSSqlServer.tableName" value="Logs"/>
<add key="serilog:write-to:MSSqlServer.autoCreateSqlTable" value="true"/>
One improvement is I'd like to add a custom column to the Logs table that Serilog uses to store a number indicating a unique RunId for my application. The idea being that a simple query would allow grouping by RunId to see all messages for that one run.
So I added the following, based on the documentation (and I haven't been able to find any other examples) as it seemed logical:
<add key="serilog:write-to:MSSqlServer.columnOptions.ColumnName" value="RunId"/>
<add key="serilog:write-to:MSSqlServer.columnOptions.PropertyName" value="RunId"/>
<add key="serilog:write-to:MSSqlServer.columnOptions.DataType" value="SqlDbType.Int"/>
<add key="serilog:write-to:MSSqlServer.columnOptions.DataLength" value="32"/>
and then in my code all I need to do is:
Log.Information("{RunId}{Message}", RunId, Message);
to see a new entry with {RunId} in the RunId column and {Message} in the Message column... however everytime I do this nothing is written to the RunId column, it remains as NULL whereas every log message the console/file has is also duplicated in the Table.
So it seems logging is working, it must be the keys wrong and I'm really not sure what should be used.
Would anyone be able to point me in the direction I need to be going or where I've gone wrong?
Thank you.
Logging definitely was working but some digging and finally I found out I had two issues:
Permissions on database where insuffident for the user serilog was using, and
AppSettings settings I was using were wrong
#1 was easy enough to fix, I created a dedicated Serilog account for this database and fixed the permissions as per documentation.
#2 however was very frustrating but eventually I was able to get the following to work:
<configSections>
<section name="MSSqlServerSettingsSection" type="Serilog.Configuration.MSSqlServerConfigurationSection, Serilog.Sinks.MSSqlServer"/>
</configSections>
<MSSqlServerSettingsSection DisableTriggers="false" ClusteredColumnstoreIndex="false" PrimaryKeyColumnName="Id">
<!-- SinkOptions parameters -->
<TableName Value="Logs"/>
<Columns>
<add ColumnName="RunId" DataType="int"/>
</Columns>
</MSSqlServerSettingsSection>
On compile and execution my program will now create the Logs table in the database and then create a RunId column which I have been able to populate with a {RunId} expression in my Log.Debug() calls.
FWIW: I hope this will be helpful and if I can work out how I'll see if I can add this to documentation as an example of using AppSettings for this use case. Searching this question most people seem to be using JSON and not AppSettings.
I am trying to access a key value into the another key in app.config but it does not work.
<appSettings>
<add key="KEY1" value="dev.cloud" />
<add key="url" value="https://www.[KEY1].com"/>
</appSettings>
I tried ${KEY1} like valumanifest.xml but this does not work in app.config.
am I missing something here ?
You have to use ConfigurationManager to read settings in the appSettings section.
For example:
var key1Val = ConfigurationManager.AppSettings["KEY1"] // returns the value of KEY1 from appSettings.
You need to add the using, then this should work.
var Key1 = Settings.Default.KEY1;
If you want to know more about the Setting.Default, check this out.
I am trying to use the Wiktionary's API trying to know if some words are defined or not.
I have seen the open source's WiktionaryNET and they use this code:
In my console code:
var word = Wiktionary.Define("clean");
foreach (var def in word.Definition)
Console.WriteLine(def);
In the app.config:
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>
I use the same things but the result is always "Definition.Count = 0"
Someone know, how can I use or set up to get results?
Thanks in advance for your help.
I'm the implementer of this library. Thanks for pointing this out. I'll try to explain what happened and what can you do if you really need this fixed right now.
The wiktionary response is in JSON format but it's terrible to parse. It's actually one single blub of text. What happened is that the JSON response from wiktionary was modified since the wiktionaryNET was implemented. It now contains an additional field. The wiktionaryNET parser mistakenly interprets this as the content it was supposed to parse in the first place. The result is an empty response from the library.
You can download the project from GitHub. Then go to WiktionaryJsonQuery.cs and modify the AddQuery statements to include the rawcontinue:
AddQuery("format=json");
AddQuery("rawcontinue"); // <-- add this line
AddQuery("action=query");
AddQuery("prop=revisions");
AddQuery("rvprop=content");
AddQuery("titles=" + word);
Build the project and add the resulting dll to your project.
Please note this is only in beta.
I am making a Windows Service. The Service has to donwload something every night, and therefor I want to place the URI in the App.Config in case I later need to change it.
I want to write an URI in my App.Config. What makes it invalid and how should i approach this?
<appSettings>
<add key="fooUriString"
value="https://foo.bar.baz/download/DownloadStream?id=5486cfb8c50c9f9a2c1bc43daf7ddeed&login=null&password=null"/>
</appSettings>
My errors:
- Entity 'login' not defined
- Expecting ';'
- Entity 'password' not defined
- Application Configuration file "App.config" is invalid. An error occurred
You haven't properly encoded the ampersands in your URI. Remember that app.config is an XML file, so you must conform to XML's requirements for escaping (e.g. & should be &, < should be < and > should be >).
In your case, it should look like this:
<appSettings>
<add
key="fooUriString"
value="https://foo.bar.baz/download/DownloadStream?id=5486cfb8c50c9f9a2c1bc43daf7ddeed&login=null&password=null"
/>
</appSettings>
But in general, if you wanted to store a string that looked like "I <3 angle bra<kets & ampersands >>>" then do this:
<appSettings>
<add
key="someString"
value="I <3 angle bra<kets & ampersands >>>"
/>
</appSettings>
void StringEncodingTest() {
String expected = "I <3 angle bra<kets & ampersands >>>";
String actual = ConfigurationManager.AppSettings["someString"];
Debug.Assert.AreEqual( expected, actual );
}
& should work just fine, Wikipedia has a List of predefined entities in XML.
Try using: & in place of & in the url
Wanted to let you know that I've tried to solve my problem before turning to the community for help.
I need to send a request with a couple of query parameters to a web service from which I should get an XML in the response which I need to parse and populate image source and image link with the values.
let's assume the the url for the website is:
domain.com/user=1&passwd=2¶m=u
When i type this in a browser I could see the XML i should get as a response.
I place the value in appSettings in a web.Config file like so:
<appSettings>
<add key="GetImageUrl" value="http://domain.com/user=1&passwd=2¶m=u"/>
</appSettings>
However, this would not compile because the compiler cannot understand '&' so I used the encoded version like this:
<appSettings>
<add key="GetImageUrl" value="http://domain.com/user=1&passwd=2¶m=u"/>
</appSettings>
However, when I type this I see the XML with "Error" values which is one of the expected values to be returned if wrong parameters are sent.
How should I proceed?
Thank you very much!
Edit:
Wanted to let you know that I've also tried "&;amp;" and "%26"
The web.config file is an XML file, so you must encode & as &.
When reading the value in your program, you will get a &.
I don't know wha tyou mean by:
when I type this I see the XML with "Error" values which is one of the expected values to be returned if wrong parameters are sent
Where is this happening? Sending where?