« October 2002 | Main | December 2002 »

November 30, 2002

XmlTextWriter, Console.Out

Text output to Console.Out is enormously slower than output to a text file or to an in-memory string.

Outputting 1000 XML nodes to file or string takes < 10 msecs. Outputting directly to Console.Out can take over a minute.

Outputting XmlTextWriter->StringWriter->Console.Out is again < 10 msecs.

Is there any way to control buffering when go directly XmlTextWriter->Console. Yes there is, you can re-open it with a buffered output stream.

Debugging Properties with Getter Side-Effects, Timers

Spent much too much time (2+ hours) discovering how badly the Visual Studio Debugger behaves if there are objects with properties which have getter side-effects. The locals window evaluates displayed properties roughly 20 times per step.

There don’t appear to be usable attributes that might be assigned to these properties to keep the debugger from evaluating them. So the moral of the morning is: AVOID PROPERTIES WITH STATE ALTERING GETTER SIDE-EFFECTS.

Still unexplained is why the locals window sometimes displays private members and sometimes doesn’t. And why the DebuggerHiddenAttribute and DebuggerStepThroughAttribute have identically described function.

November 26, 2002

XMLNodeList lacks any public constructor, XmlDocument.Create*() factory methods

The lack of a public constructor for XmlNodeList is a pain. It has a protected constructor. Would like NOT to always have to go through XPath to create a list. Its an abstract type, what are the concrete derived types? The answer is…

To create XmlNode, XmlElement, XmlAttribute objects, use the Create*() methods of XmlDocument.

Uset the OwnerDocument property to get at the document starting with a node.

XmlNode.Clone() makes a deep copy. How can the nodes be moved to a new document?

System.Web.HttpUtility.UrlEncode

Use System.Web.HttpUtility.UrlEncode to encode a query string argument value.

November 21, 2002

Sending Mail As Anyone

telnet smtp.myserver.com 25

helo

mail from: whoever_can_be_quoted

rcpt to: recipient_e-mail

data

Message…..

.

quit

 

 

System.Environment.UserInteractive & WebService

System.Environment.UserInteractive is false in WebService context. Use in diagnostics to inhibit Console access.

November 19, 2002

Execution Timing, DateTime Ticks Resolution

The Ticks property of a TimeSpan produced by subtracting two DateTime.Now value has a resolution of 156247.

There are 10,000,000 ticks per second (TimeSpan.TicksPerSecond), so the resolution is 15.6247 milliseconds.

The Environment.TickCount property counts millisecond ticks and has a resolution of between 15 and 16 milliseconds.

Modified an example of using QueryPerformanceCounter Win32 API to create a high resolution timer for use in C#.

Lessons from Simple Web Service Accessing SQL

1.       WebMethod signature of void(string, out double, out double) turned into double(string, out double) on the client. Why?

2.       “finally” works fine after a return and/or a catch, use it to close sql connection.

3.       Testing a web service via Internet Explorer displays 500 errors if the service throws an exception.

4.       Use FrontPage mode to copy the web service project to a public web server if different account credentials will be needed for access.

5.       Overloaded methods need to use the MessageName property in the WebMethodAttribute i.e. [WebMethod(MessageName=”foo2”)].

6.       Simplest SQL data retrieval requires at least these steps:

a.       Create and open a connection object with a connection string.

b.       Create a command object with a comman string and connection object.

c.       Execute the command, returning a reader object.

d.       Issue a read method call on the reader object to advance to the first result row.

e.       Use the Get* methods to retrieve column values from the current row.

f.         Close the connection.

7.       Setting up a SQL database for use by a web service:

a.       Add the host\ASPNET Windows User to the SQL->Security->Logins. “host” is the name of the web service server.

b.       Giving localhost/ASPNET db_datareader access is sufficient for SELECT commands returning data.

c.       Only a single ASPNET user can be given db_datareader access to an individual database. KIZMET\ASPNET and PELL\ASPNET can’t both have access simultaneously since both would be user “ASPNET”.
So it’s a “good thing” that a web server (YAM) accessing a remote sql server (PELL) comes in as user KIZMET\YAM$.

d.       Install MDAC on web server if needed. http://www.microsoft.com/data/download_270RTM.htm

8.       Setting up a NUnit test project to test a web service:

a.       Name the project “Test”.

b.       Project properties settings:

                                                               i.      assembly & startup object names to Kizmet.foo.Test.

                                                             ii.      Debug Mode to program

                                                            iii.      Start Application to C:\Program Files\NUnit V2.0\bin\nunit-gui.exe

                                                            iv.      Command Line Arguments to /assembly:Kizmet.foo.Test.dll

c.       Add a reference to nunit.framework

d.       Add a web reference to http://..../foo.asmx?wsdl

e.       Add a “using localhost” or “using org.kizmet.www”

 

November 15, 2002

Automaticall removing old version during Setup & Installation

To avoid having to manually remove previous versions:

1.       RemovePreviousVersions property of the Setup project must be true.

2.       The UpgradeCode must stay the same.

3.       The ProductCode and PackageCode must both change. An easy way to get this done is to increment the Version property of the Setup project.

4.       It is bizarre that the ProductCode appears on the Setup project property list by the PackageCode does not…

November 13, 2002

DataGrid behavior

Form.Controls.Add of the DataGrid control (or of a control containing it) causes:

a.                   ListManager initialized.

b.                   Bound set to true.

c.                   BindingContext initialized to Form’s BindingContext.

d.                   IsHandleCreated still false.

e.                   DataBindings.Count still zero, this is independent of the BindingContext.

f.                     BindingContext collection has entries which are System.WeakReference’s to CurrencyManager or RelatedCurrencyManager objects. RCM’s extend CM’s. RCM’s have a parent reference to a CM.

a.       “” is CurrencyManager for entire data set.

b.        “job” is RelatedCurrencyManager.

g.                   grid.ListManager.GetHashCode() == grid.BindingContext[grid.DataSource, grid.DataMember].GetHashCode()
but
grid.ListManager != grid.BindingContext[grid.DataSource, grid.DataMember]

h.                   Form’s BindingContext == DataGrid.BindingContext

So far:

1.       The AllowNew DataView property must be set true prior to a Clear-Fill load dataset operation. Failing to do so will cause the Grid to stop accepting new values for existing cells.

 

debugging DataGrid behavior

Problem: After re-loading a DataGrid via a context menu pick, edited cells revert to their pre-edit state as soon as new cell is selected.

Diagnosing:

1.       Loading multiple times before first display of Form doesn’t fail.

2.       Removing relation from schema doesn’t change behavior.

3.       Removing LinkLabel columns & sorting and AllowNew = false eliminates problem.

4.       It’s the AllowNew = false.

5.       Switching to Merge instead of direct Fill data set load pattern eliminates problem.

6.       Inserting a AllowNew = true & AllowNew = false around the clear/fill also eliminates the problem.

 

November 11, 2002

DataSet load patterns

When using a remote data source that delivers a dataset, it may be necessary to maintain a second DataSet into which new DataSets are merged in the LoadData function. This enables – among other things – data bindings that don’t need to be rebound.

 

The downside is that merging is a very slow (human scale) operation for DataSets with hundreds of rows.

 

If DataAdapters are used to fill a persistent local DataSet, there’s no need to use the merge pattern.

See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxconDataFormWizardGeneratedCode.asp

 

Still chasing the bug that prevents editing grid cells after a load.

November 09, 2002

reverse engineering, MSIL spec, salamander

www.remotesoft.com salamander

 

MSIL specification is found at file://c:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Tool Developers Guide\docs\Partition III CIL.doc

 

Partition III CIL.doc

 

Google API

Added calls to the google API to Job Blaster.

Make a note of the wsdl files url and how to add it to a project!

http://api.google.com/search/beta2/GoogleSearch.wsdl

 

November 05, 2002

JIT Configuration, Removing Visual Studio 6.0

See also, ms-help://MS.VSCC/MS.MSDNQTR.2002OCT.1033/cpguide/html/cpconenablingjit-attachdebugging.htm

After installing Visual Studio 6.0, script errors in html pages displayed with VWShowDoc triggered a JIT debugger selection dialog (even though the object was configured to ignore errors). The setting to correct this turned out to be:

HKEY_CURRENT_USER/software/Microsoft/internet explorer/Main/Disable Script Debugger -> YES