Applied NET Attributes 1st Edition Tom Barnaby pdf download
Applied NET Attributes 1st Edition Tom Barnaby pdf download
download
https://ebookultra.com/download/applied-net-attributes-1st-
edition-tom-barnaby/
https://ebookultra.com/download/cybernation-tom-clancy-s-net-force-
no-6-first-edition-tom-clancy/
https://ebookultra.com/download/applied-xml-programming-for-microsoft-
net-1st-edition-dino-esposito/
https://ebookultra.com/download/green-schools-attributes-for-health-
and-learning-national-research-council/
https://ebookultra.com/download/carving-bottlestoppers-with-tom-
wolfe-1st-edition-tom-wolfe/
Build Your Own ASP NET Website Using C VB NET 1st Edition
Zak Ruvalcaba
https://ebookultra.com/download/build-your-own-asp-net-website-using-
c-vb-net-1st-edition-zak-ruvalcaba/
https://ebookultra.com/download/the-heirs-of-the-prophet-muhammad-and-
the-roots-of-the-sunni-shia-schism-barnaby-rogerson/
https://ebookultra.com/download/restful-net-1st-edition-jon-flanders/
https://ebookultra.com/download/asp-net-ajax-programmer-s-reference-
with-asp-net-2-0-or-asp-net-3-5-dr-shahram-khosravi/
https://ebookultra.com/download/the-necessary-nature-of-future-firms-
attributes-of-survivors-in-a-changing-world-1st-edition-george-p-
huber/
Applied NET Attributes 1st Edition Tom Barnaby Digital
Instant Download
Author(s): Tom Barnaby, Jason Bock (auth.)
ISBN(s): 9781590591369, 1590591364
Edition: 1
File Details: PDF, 4.16 MB
Year: 2003
Language: english
Applied .NET Attributes
TOM BARNABY AND JASON BOCK
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any
means, electronic or mechanical, including photocopying, recording, or by any information
storage or retrieval system, without the prior written permission of the copyright owner and the
publisher.
ISBN 978-1-59059-136-9
ISBN 978-1-59059-136-9 ISBN 978-1-4302-0782-5 (eBook)
978-1-4302-0782-5 (eBook)
DOI 10.1007/978-1-4302-0782-5
10.1007/978-1-4302-0782-5
Trademarked names may appear in this book. Rather than use a trademark symbol with every
occurrence of a trademarked name, we use the names only in an editorial fashion and to the
benefit of the trademark owner, with no intention of infringement of the trademark.
Editorial Board: Dan Appleman, Craig Berry, Gary Cornell, Tony Davis, Steven Rycroft, Julian
Skinner, Martin Streicher, Jim Sumser, Karen Watterson, Gavin Wray, John Zukowski
The information in this book is distributed on an “as is” basis, without warranty. Although every
precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall
have any liability to any person or entity with respect to any loss or damage caused or alleged to
be caused directly or indirectly by the information contained in this work.
The source code for this book is available to readers at http://www.apress.com in the Source Code
section. You will need to answer questions pertaining to this book in order to successfully
download the code.
Contents at a Glance
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
iii
Contents
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Applications of Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Attributes in .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Compiler Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
COM Interoperability Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Design-time Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Securing Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Platform Invoke Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Serialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Remoting and Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Enterprise Services Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
v
Contents
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
vi
About the Authors
J ASON B OCK is a Senior Consultant for Magenic Technologies (http://www.magenic.com).
He has worked on a number of business applications using a diverse set of substrates
and languages such as C#, .NET, and Java. He is the author of CIL Programming:
Under the Hood of .NET and .NET Security, both published by Apress, and Visual Basic
6 Win32 API Tutorial, published by Wrox. He has also written numerous articles on
technical development issues. Jason holds both a Bachelor’s degree and Master’s
degree in Electrical Engineering from Marquette University. You can find out more
about him at http://www.jasonbock.net.
vii
Acknowledgments
Jason Bock
First and foremost, I must thank my wife, Liz, for her support and patience as
I worked on my material for this book. You’re the best. I love you.
I’d like to thank Tom for contributing his clear and concise approach to his
sections. I’d also like to thank the wonderful staff at Apress for their support and
assistance with this book. People like Gary Cornell, Dan Appleman, Grace Wong,
Marilyn Smith, and Laura Cheu (among many others) add a ton of value to their
products, and I know that through their help, the content of this book is stronger.
Thanks also to Dan Fergus for handling the technical reviews.
Thanks to everyone at Magenic Technologies for letting me work at a place
(again!) with talented individuals who really know their stuff. There are a lot of
reasons why Magenic is known as one of the top Microsoft-based consulting
companies, and I’m glad I work there and can be a part of it. (And the HaloFests
are fantastic, although winning the majority of campaigns is getting a bit old . . .)
Finally, to my family and friends, thanks for being there.
Tom Barnaby
As always, I am awed by the amount of work and coordination required to pro-
duce a book, even a relatively small one like this. And, once again, I am grateful
for the folks at Apress who somehow orchestrate this task. Thanks to Gary Cornell
for offering this opportunity and Dan Appleman for his insight and assistance as
the project was getting started. Thanks to Marilyn Smith and Dan Fergus for dili-
gently correcting my grammatical and technical lapses, and Laura Cheu for
cheerfully leading us through the production cycle. Finally, thanks to Grace
Wong for pulling us all together and basically just making things happen.
Thanks to Jason Bock for being the dependable guy he is and driving the
process forward in the face of delays.
Thanks to everyone at Intertech Training for providing a challenging and
rewarding work environment. Thanks to Tom Salonek and Andrew Troelsen for
fostering a culture that encourages both exploration and having fun.
Finally, and most importantly, I’d like to thank my wife, Tammy, and son,
Max. The sacrifices I made for this book pale in comparison to yours. Thank you
for your patience, love, and support.
ix
Introduction
ATTRIBUTES—WHAT A STRANGE topic to write a book about. We can’t tell you how
many times we’ve tried and failed to explain this book. Past books were difficult
to describe to relatives and others not in the industry, but this book is unique in
that we have trouble explaining it to other developers. To many developers,
a .NET attribute is just some funny COM IDL-like syntax that you apply to
a method to make it a Web method or to expose it to a COM client. “Why?” and
“How long is it going to be, 20 pages?” were just a couple of responses we
received when disclosing that we were writing a book about .NET attributes.
Joking aside, we believe .NET’s attribute concept is one of the most, if not
the most, significant feature in .NET. Just look at how Microsoft itself applied
attributes within .NET. You will find attributes are key components in COM
interoperability, enterprise services, security, serialization, Web services, remot-
ing, and so on. Clearly, Microsoft’s developers regard attributes as an extremely
useful tool. After reading this book, you will have a solid understanding of how
attributes work and why you might want to apply them in your own projects.
What Is Covered
The purpose of this book is to show you how to harness the power of attributes
as effectively as Microsoft has. To this end, the book covers not only using the
built-in .NET attributes, but also creating custom attributes for your own appli-
cations.
Chapters 1 through 3 focus on the basics of attributes and their application
within the .NET Framework. These chapters will show you the underlying
mechanics of attributes, including how they encapsulate metadata within the
CIL code. You will also see how to apply numerous .NET Framework attributes
to configure several framework services and to gain an appreciation for the
potential of attributes. Because attributes permeate so many aspects of the
.NET Framework, these chapters are practically an overview of .NET itself! You
will learn about designing custom controls, interoperating with COM and API
functions, using code access security, hooking into COM+, serializing objects,
and much more.
Chapters 4 and 5 focus on creating and applying custom attributes. These
chapters demonstrate how to write your own attributes and how to discover
them at runtime using Reflection. You will also learn about a new development
philosophy called Aspect Oriented Programming (AOP) and how you can imple-
ment AOP using context attributes. The final chapter presents a case study of
using custom attributes.
xi
Introduction
Intended Audience
All of the source code is available for download from the Downloads section of
the Apress Web site (http://www.apress.com). The code was compiled and tested
using version 1.1 of the .NET Framework, but everything should also work under
version 1.0. You can follow most examples using nothing more than the compil-
ers and tools provided in the .NET Framework and a text editor like Notepad.
However, we assume Visual Studio .NET is the preferred development tool, and
the online code includes Visual Studio .NET project files.
Chapter-by-Chapter Overview
For a more detailed look at the structure and content of this book, let’s go over
each of the chapters.
This chapter covers several .NET Framework attributes that affect the behavior
of the compiler and other .NET tools. You will learn how compile-time attributes
can be applied to create conditional method calls, verify CLS or ignore CLS com-
pliance issues, and expose .NET classes to COM components. You will also learn
about several design-time attributes, which affect the way Visual Studio .NET
displays custom control settings and information.
xii
Introduction
This chapter surveys several .NET Framework attributes that affect the behavior
of the runtime as it executes your code. Ultimately, these attributes allow you to
apply .NET code access security, interoperate with COM components and API
functions, control the way an object is serialized, and consume COM+ services
like automatic transactions.
xiii
CHAPTER 1
Attribute Fundamentals
IN THE COURSE OF DEVELOPING an application, it is quite typical to have core func-
tionality contained in methods that are invoked by other specialized methods.
This reduces the spread of code and improves the maintainability of the code
base. Similarly, it is routine to move commonly used data to other generalized
levels. However, sometimes it becomes apparent that the shared implementa-
tions or the data should be published to a level where the implementations or
data can be used across other class definitions. This is where metadata comes
into play, as object-related services consume this information to provide
reusable implementations.
In this chapter, you’ll get a tour of the fundamentals of attributes. You’ll see
how code is dissected to determine when attributes should be used and when
other techniques are more applicable. Then you’ll be provided with the essen-
tials of attribute-based programming in .NET. You’ll understand how attributes
are defined and where they can be applied in an assembly. Finally, you’ll get
a detailed look at where the attribute’s information is stored in an assembly.
Applications of Metadata
Attributes are just like any other tool in the developer’s proverbial toolkit. They
are useful in some situations; in other cases, they can make the solution much
more complex than it needs to be. In the following sections, we’ll describe how
data is used within code and when data is used to define and describe the code
base itself.
Let’s start our journey into metadata by looking at some rather simplistic models
of a country. The intent is not to have a class that completely describes a coun-
try, but to focus on what the code does. Listing 1-1 shows an initial attempt at
coding a class that defines a country. As you’ll see in a moment, it’s not the finest
example of writing code.
1
Chapter 1
namespace Apress.NetAttributes
{
public class BadCountry
{
public string mName;
public long mPopulation;
this.mPopulation = value;
}
}
2
Attribute Fundamentals
• The mName field is never initialized. If you create an instance of the BadCountry
class and get the Name property, you will have a null reference, which may
cause a NullReferenceException.
• The fields are declared as public, so any data validation that exists (such as
the Population setter) can be circumvented with ease.
namespace Apress.NetAttributes
{
public class ImprovedCountry
{
private const string ERROR_ARGUMENT_NAME = "name";
private const string ERROR_ARGUMENT_POPULATION = "population";
private const string ERROR_MESSAGE_NULL_VALUE =
"The given value should not be null.";
private const string ERROR_MESSAGE_OUT_OF_RANGE =
"The given value is out of range.";
public const long MINIMUM_POPULATION = 0;
public const long MAXIMUM_POPULATION = 5000000000000;
3
Chapter 1
this.mName = name;
this.mPopulation = population;
}
4
Random documents with unrelated
content Scribd suggests to you:
was made by those who led or those who followed. In my judgment
no other course was left open to the community.
“Not less than 500 men were driven out of Kansas on the charge
of disloyalty in 1861 and 1862, with the approval of men of excellent
character, by thugs and scoundrels, who made no concealment of the
fact that they lived by horse stealing and house breaking. From the
beginning of the Civil war until peace was declared, the Kansas
border from the Nebraska State line to the Indian Territory, was a
scene of lawlessness and disorder. In the earlier years of the war,
thieves regularly organized into companies, with captains whose
authority was recognized by the rank and file, with headquarters in
the towns and cities of eastern Kansas, masqueraded as saviors of the
Union, and upon the pretense that they were serving the cause,
thrived amazingly by pillaging the farm houses and barns of
neighboring counties in Missouri. Atchison was the headquarters of
the Cleveland gang—the most active and the boldest of the banditti.
The gang did not hesitate to cross over to Missouri and steal horses,
and returning to Atchison sell them in broad daylight. Usually these
raids were made at night, but there was no concealment of the
business they were engaged in, nor of the fact that hundreds of the
horses sold by them were stolen from farmers of Buchanan, Platte
and Clinton counties. In the capacity of saviors of the Union, they
took upon themselves the task of driving all persons suspected of
sympathy for ‘the lost cause’ out of Kansas. P. T. Abell, J. T.
Hereford, Headley & Carr, prominent lawyers, were notified to leave
or they would be killed. They departed. Headley, Carr and Hereford
served in the Confederate army. Abell lived in exile until after the
war was over, and then returned to Atchison. He was one of the
founders of the town, and before the war was the partner of Gen. B.
F. Stringfellow. Tom Ray, proprietor of an extensive blacksmithing
and wagon shop, was banished. In a month or two he returned, but
not until after he had halted at Winthrop, a village opposite Atchison
and opened up negotiations which resulted in a grant of permission
to remain in Atchison long enough to settle up his business and
collect considerable sums due from his customers. He registered at
the old Massasoit House, but did not tarry long. Maj. R. H.
Weightman, an early settler, who left Atchison in 1861, and accepted
a colonel’s commission in the Confederate army, had been killed at
Wilson’s Creek. While sitting in the Massasoit House barroom, Ray
was approached by Sandy Corbin, a somewhat notorious character,
who handled most of the horses stolen by Cleveland’s thieves. Corbin
mentioned Weightman’s death, expressing satisfaction at his
untimely end, and applying all the epithets known to the abandoned,
to the dead man. Ray expostulated, and finally warned Corbin to
desist or expect a thrashing. Corbin rushed to his room and returned
with two revolvers, so adjusted upon his belt that Ray could not help
seeing them. Ray, who was a giant in size, seized Corbin, threw him
face downward upon a billiard table, and with a blacksmith’s hand as
large as a ham, spanked him until he was almost insensible. Then he
hurriedly boarded the ferry boat, crossed the river and made his way
to Montana, where he lived until his death, twenty years ago.
“Cleveland’s lieutenant, a fellow named Hartman, was the worst
of the gang, and was guilty of so many and such flagrant outrages
upon the prominent citizens that in sheer desperation, four men, all
of whom are now dead, met and drew straws to see who would kill
Hartman—(1) Jesse C. Crall, during his life prominent in politics and
business; (2) George T. Challiss, for thirty years a deacon in the
Baptist church and a prominent wholesale merchant and identified
prominently with Atchison affairs; (3) James McEwen, a cattle buyer
and butcher; (4) The fourth man was a prominent physician. Each of
these had suffered intolerable outrages at the hands of Hartman. He
had visited their houses and terrified their wives by notifying them
that unless their husbands left Atchison within a specified period
they would be mobbed. Even the children of two of the victims of
persecution had been abused. They met at the physician’s office, and
after a prolonged conference, at which it was agreed that neither
would leave until Hartman had been killed, proceeded to draw
straws to see which would undertake the work. Crall held the straws,
McEwen drew the short straw and the job fell to his lot. Atchison is
bisected by two or three brooks, one of which traverses the northwest
section of the town and runs into White Clay creek. This ravine has
very precipitous banks, and was crossed by several foot bridges. At
the east approach of the bridge was a tall elm tree. McEwen took his
position under this tree, and awaited the appearance of Hartman,
who necessarily passed that way in going home at night. When
Hartman was half-way across the bridge, McEwen stepped out,
dropped to his knee, leveled a double-barreled shotgun and turned
loose. He filled Hartman with buckshot from his head to his heels,
but strange to say, the fellow did not die for months afterward. Had
either of the others drawn the fatal straw, no doubt Hartman would
have been killed in broad daylight, on the streets, but McEwen
concluded to give the fellow no chance for his life.”
The First Kansas volunteer cavalry was the first regiment to be
raised under the call of President Lincoln May 8, 1861. It was
mustered into the service at Ft. Leavenworth June 3, 1861. George
W. Deitzler, of Lawrence, was colonel, and the following men from
Atchison were officers: George H. Faicheled, captain, Company C;
Camille Aguiel, first lieutenant: Rinaldo A. Barker, second
lieutenant; James W. Martin, second lieutenant of Company B.
Within ten days of the date this regiment was mustered in, they
received orders for active service. The regiment joined the army of
General Lyon at Grand River, Mo., and on July 10 arrived at
Springfield, where the force of General Sigel was gathered. The
united forces of the rebels, under Price and McCullouch, was
concentrated at Wilson’s Creek, twelve miles from Springfield, and
was strongly entrenched there, where the initial engagement of the
First Kansas regiment took place. This regiment went into the
engagement with 644 men and officers, and lost seventy-seven killed
and 333 wounded. The rebel forces were estimated to be 5,300
infantry, fifteen pieces of artillery, and 6,000 horsemen, with a loss
of 265 killed, 721 wounded, and 292 missing. The Union forces
numbered about 5,000, with a loss of about 1,000. It was one of the
fiercest and most determined battles of the Civil war, and both
officers and privates in the companies from Atchison displayed great
bravery. First Lieut. Camille Aguiel was among the killed, and
privates Henry W. Totten and Casper Broggs, together with Corporal
William F. Parker, of Atchison, also lost their lives in this
engagement.
The Seventh regiment Kansas cavalry was ordered into active
service immediately following its organization. Colonel Daniel R.
Anthony, of Leavenworth, was a lieutenant-colonel of this regiment,
and among the line officers was William S. Morehouse, of Atchison,
who was second lieutenant. This regiment saw a great deal of active
service in the Civil war, and was first attacked by the rebels
November 11, 1861, while encamped in western Missouri, on the
Little Blue river. Following a furious battle the regiment lost nine of
its force by death and thirty-two wounded. This regiment
subsequently participated in an engagement at Little Santa Fe and at
Independence. In January, 1862, the Seventh regiment went into
camp at Humboldt, Kan., and remained there until it was ordered to
Lawrence in the following March, and subsequently was ordered to
Corinth, Miss., and from thence to Rienzi, Miss., where it was
assigned to the First Cavalry brigade, of which Phillip H. Sheridan
was commander, and subsequently saw much service in Tennessee
and other points in the South, and participated in the various actions
that occurred during General Smith’s expedition to the Tallahatchee,
after which the balance of their active service took place in Missouri.
It was mustered out at Ft. Leavenworth September 4, 1865.
The Eighth regiment Kansas infantry was perhaps closer to the
hearts of the people of Atchison county than any other regiment that
participated in the Civil war, for the reason that its lieutenant-colonel
was the beloved John A. Martin, editor of the Atchison Champion,
and subsequently governor of Kansas. It was originally recruited and
intended for home and frontier service. The fear of invasion, both by
hostile Indians on the west, and the rebels on the south and east,
kept fear alive in the hearts of many residents of Kansas, and for this
purpose it was deemed desirable to have a regiment of volunteer
soldiers close at hand. As originally organized, this regiment
consisted of six infantry and two cavalry companies, but various
changes were made during the three months following its
organization. It saw active service throughout the South, and
participated in many of the important battles of the Civil war, but in
none did it play a more conspicuous part than in the great battle of
Mission Ridge. The following is from Colonel Martin’s official report
of the part taken by the Eighth Kansas in this engagement:
“Shortly after noon, on the twenty-fifth (November), we were
ordered to advance on the enemy’s position at the foot of Mission
Ridge, and moved out of our works, forming in the second line of the
battle. We at once advanced steadily in line through the woods and
across the open field in front of the enemy’s entrenchments to the
foot of the hill, subjected during the whole time to a heavy artillery
fire from the enemy’s batteries, and as soon as we reached the open
field, to a destructive musketry fire. Reaching the first line of works
we halted to rest our men for a few moments, and then advanced
through a terrible storm of artillery and musketry, to the foot of the
hill and up it as rapidly as possible. The crest of the ridge at the point
where we moved up was formed like a horseshoe. We advanced in
the interior, while the enemy’s batteries and infantry on the right and
left, as well as in the center, poured upon us a most terrific fire. But
the men never faltered or wavered, although from the nature of the
ground, regiments were mingled one with another, and company
organization could not possibly be preserved. Each man struggled to
be first on top, and the officers and men of the regiment, without a
single exception, exhibited the highest courage and the most devoted
gallantry in this fearful charge.
“The enemy held their ground until we were less than a dozen
yards from their breastworks, when they broke in wild confusion and
fled in panic down the hill on the opposite side. A portion of our men
pursued them for nearly a mile, capturing and hauling back several
pieces of artillery and caissons, which the enemy were trying to run
off.
“We occupied the summit of Mission Ridge until the night of the
twenty-sixth, when we were ordered to return to camp at
Chattanooga.
“Our loss was one commissioned officer wounded and three
enlisted men killed and thirty-one wounded. The regiment went into
the battle with an aggregate force of 217 men and officers.
“Where all behaved with such conspicuous courage, it is difficult
to make distinction, but I cannot forebear mentioning my adjutant-
lieutenant, Sol. R. Washer. Wounded at Chicakamauga, and not yet
recovered from the effects of his wound, and suffering from a severe
sprain of the ankle, which prevented his walking, he mounted his
horse and rode through the whole battle, always foremost in danger.”
The Eighth infantry remained in camp at Chattanooga until it
removed to the relief of Burnside at Knoxville, which city was
reached on December 7. About the same time Sherman’s corps
arrived. The winter of 1863 was spent in east Tennessee, and in the
following February arrived home in Atchison and Ft. Leavenworth.
There was great rejoicing and celebration and both officers and
soldiers were greeted with waving banners, ringing bells, booming
cannon, and there was much feasting and speech making. The
regiment was home on a furlough, and early in April the men re-
assembled at Leavenworth and on the twelfth of that month was
ordered to report back to Chattanooga, where it subsequently saw
service in the Cumberland mountains, and throughout the State of
Tennessee.
Colonel Martin was mustered out at Pulaski November 17, his
term of enlistment having expired, and the following day he left for
the North, but the regiment was not mustered out of service until the
following January.
The Tenth regiment, Kansas infantry, was made up of the Third
and Fourth and a small portion of the Fifth Kansas regiments, and
among its officers were Mathew Quigg, captain of Company D; Seth
M. Tucker, first lieutenant, and David Whittaker, second lieutenant,
all of Atchison. The activities of this regiment were largely confined
to operations in Missouri and Arkansas, and afterwards in
Tennessee. In December, 1864, it arrived at Clinton, Miss., without
tents or blankets, and many of the men without shoes or overcoats.
During January it made an expedition into Mississippi, and the latter
part of that month marched to Waterloss, Ala., remaining there until
February 8, when it embarked for Vicksburg, where it remained until
February 19, and subsequently operated around Mobile, and the men
of this regiment were employed as skirmishers in the joint advance
upon the fortifications around Mobile. It was mustered out at
Montgomery, Ala., September 20, 1865, and finally discharged at Ft.
Leavenworth, Kan. The regiment was mostly composed of veterans,
who understood the life of a soldier, and realized the hardships of
military campaigns. They did their duty, whether it was in guarding
their own State from invasion, or assaulting the rebels at the siege of
Ft. Blakely.
The Thirteenth regiment, Kansas infantry, had more officers in
it from Atchison than any of the regiments that participated in the
Civil war. It was raised under President Lincoln’s call of July, 1862,
and was recruited by Cyrus Leland, Sr., of Troy, Kan., by virtue of
authority from James H. Lane, in the counties of Brown, Atchison,
Doniphan, Marshall and Nemaha. The regiment was organized
September 10, 1862, at Camp Staunton, Atchison, and mustered into
the service ten days later. Colonel of this regiment was Thomas M.
Bowen, of Marysville, and the major was Caleb A. Woodworth, of
Atchison. Among the line officers from Atchison were: Henry
Havenkorst, captain of Company B; August Langehemeken, second
lieutenant; Henry R. Neal, captain; Robert Manville, second
lieutenant; John E. Hayes, captain, Company F; Archimedes S.
Speck, first lieutenant; William J. May, second lieutenant; Patrick
McNamara, captain, Company K; Daniel C. O’Keefe, first lieutenant;
Hugh Dougherty, second lieutenant.
The regiment joined a division of General Blunt soon after the
battle of Old Ft. Wayne, and participated in various engagements in
Arkansas. At the battle of Prairie Grove, it was one of the first
regiments to be engaged, and in every attempt to capture the battery
of which this regiment formed the support at this battle, was
successfully repulsed, with heavy losses to the rebels. This battle
virtually finished the campaign for the winter. It subsequently did
garrison and out-post duty in Arkansas, and in the Cherokee Nation.
The regiment remained on duty at Ft. Smith, Ark., until March 3,
1865, when it was ordered to Little Rock, Ark., and on June 26 of
that year was mustered out of service.
Among the privates of this regiment from Atchison, who were
killed, were: James L. Parnell, of Mount Pleasant, and John Collins
and Lorenzo Richardson, of Atchison.
Thomas Roe, a fine, stout young man, son of a widowed mother,
of Brownsville, Pa., was the only member of Company D, of the
Second Kansas cavalry, that lost his life in battle during its nearly
four years of service in the Civil war. This company participated in
the battles of Cane Hill and Prairie Grove, in Arkansas, and other
engagements. Roe came to Kansas with the late Thomas Butcher, for
whom he worked until going into the war of the rebellion.
In May, 1861, a company of home guards was organized by Free
State men, of Lancaster and Shannon townships, Atchison county,
with a few from Brown and Doniphan counties, which gathered every
Saturday afternoon for drill, alternating at the homes of Johnson
Wymore and Robert White. Robert White, who had received military
training during the Mexican war, having served there in 1846–48,
did most of the drilling. A. J. Evans was captain; Robert White, first
lieutenant; John Bertwell, of Brown county, was second lieutenant.
The pro-slavery people were also organized and drilling at the
same time, consisting of South Carolinians, Virginians and
Missourians, who were for the Confederacy and slavery.
At a Sunday school meeting on the prairie, held in a vacant
settler’s shanty near Eden postoffice, where both sides in the
neighborhood worshiped on Sundays, Robert White found out on a
Sunday in August, 1861, that a southern organization was to disarm
all Free State men the following Tuesday. His nearest neighbor and a
good friend, also a southerner, thought White had found this out and
came and visited him a good part of Sunday afternoon and staying in
the evening until after 10 o’clock before going home, White showing
no excitement. Willis went home, seemingly much at ease, but he
was watched by his friend White until safely resting at his home,
when White went and called another Free State man from his bed
who notified half the Free State company and White the other half,
causing them to meet early the following Monday, when by the
middle of the afternoon of that day every pro-slavery man in that
part of the country had his fire arms taken from him, and before
Tuesday evening all of them had departed for Missouri.
Most of the members of the Free State company enlisted in the
following October as volunteers for three years’ service in the Union
army and became known as Company D of Second Kansas cavalry.
Robert White, who was commissioned as first lieutenant in Company
D, was discharged and sent home to die with a serious case of
inflammatory rheumatism, but he recovered so far that in 1863 he
raised and drilled a company that became a part of the State militia.
He was commissioned captain of this company and led it in the Price
raid at the battle of Westport in 1864 as a part of the regiment
commanded by Col. L. S. Treat in helping keep Capt. White’s old
brigade, commanded by Gen. Sterling Price, of the Mexican war,
from getting into Kansas. The late M. J. Cloyes and T. B. Platt, of
Atchison, were members of Captain White’s company in the Price
raid. Platt was clerk of the company; John English was first
lieutenant; W. F. Streeter, second lieutenant, and Francis
Schletzbaum was first sergeant.
The Seventeenth regiment, Kansas infantry, was a negro
regiment, but with white officers. James M. Williams was colonel,
and George J. Martin, of Atchison, was captain of Company B, and
William G. White and Luther Dickinson, of Atchison, were first and
second lieutenants. This regiment played an honorable part during
all the Civil war, and its service was largely confined to operations in
Arkansas and Texas. It was mustered out of service at Pine Bluff,
Ark., October 1, 1865.
The Second regiment, Kansas colored infantry, was organized in
June, 1863, at Ft. Smith, Ark., and among its line officers was First
Lieut. John M. Cain, of Atchison. It conducted itself with
conspicuous bravery with the army of the frontier, and during the
brief occupation of Camden, Ark., by General Steele’s forces, this
regiment was employed on picket and forage duty. It showed
conspicuous bravery around Poison Springs and Mark’s Mills, and
under the able command of Col. Samuel J. Crawford, who
subsequently became governor of Kansas, it won for itself an
enviable name among the regiments from Kansas, who participated
in the Civil war. This regiment was finally discharged from the
services at Leavenworth November 27, 1865, after having proved to
the Nation the fidelity of the colored soldier.
It was in September, 1864, that General Sterling Price created
great consternation by an attempted invasion of Kansas, which
ended in his defeat on the border by the Union forces, aided by the
Kansas State militia. At the time Price started north in his march
through Arkansas and Missouri. Maj. Gen. Samuel R. Curtis
commanded the Department of Kansas, which included Nebraska,
Colorado and Indian Territory, in addition to Kansas. General Curtis
had about 4,500 men, all of whom had been employed in protecting
the frontiers of Kansas and Colorado, and the overland mail route. At
this time General Curtis was near Ft. Kearney, operating against the
Indians. On receipt of word announcing the movements of General
Price, General Curtis was recalled and reached Kansas in September.
A few days later he received word that 3,000 rebels were marching
on Ft. Scott, and advised Governor Carney to call the militia into
service. At this time George W. Deitzler was major-general of the
State militia; John T. Norton was assistant adjutant-general; R. A.
Randlett, assistant quartermaster; Samuel S. Atwood, assistant
quartermaster; Charles Chadwick, George T. Robinson, Lewis T.
Welmorth, John J. Ingalls, Thomas White, Elijah G. Moore, H. Stein,
and John A. Leffkler were all majors. Constant reports of a
conflicting nature were spread from day to day, regarding the
movements of General Price, but the first point to be attacked was
Pilot Knob, the engagement commencing September 27 and lasting
all day. General Ewing put up a vigorous defense, with a force of
about 1,000 men, while the militia commanders in Kansas made
preparations for further resistance to the invasion of Price.
Meanwhile General Price continued to make headway, and on the
fourth of October an order was issued forbidding the transit of boats
below Kansas City. When it was discovered that the rebels under
Price had not been seriously checked in their movement westward,
further efforts were made by General Curtis to prevail upon
Governor Kearney to call out the militia, which the Governor seemed
disinclined to do. Finally, on October 9, 1864, Major General Deitzler
issued an order for the State militia from Doniphan, Brown, Nemaha
and Marshall counties to rendezvous at Atchison, and the militia
from other counties were ordered to other points in the State. A few
days later Leavenworth was fortified, because of a telegram which
was received from General Rosecrans, stating that it was Price’s
intention to strike that point first. The militia responded promptly,
and the following regiments reported for service at Atchison: The
Twelfth regiment, composed of 460 men, under the command of Col.
L. S. Treat, and the Eighteenth regiment, composed of 400 men,
under the command of Colonel Mathew Quigg. The total number of
militia enrolled under the call of the governor was 12,622, of which
about 10,000 were south of the Kansas river at the point most
exposed to danger. From the eleventh until the sixteenth of the
month there was great excitement, as the forces rapidly gathered, to
be organized and equipped. On the staff of General Deitzler there
were two men from Atchison: A. S. Hughes, an aide, and John J.
Ingalls, judge-advocate, with the rank of major.
As a result of this determined move on the part of Gen. Sterling
Price to invade Kansas, there followed in quick succession the battle
of Lexington, the battle of Big Blue, and finally the battle of
Westport, at which, on October 23, 1864, the forces of Price were
finally routed and his campaign and invasion were stopped, but not
until it had caused the citizens of Kansas, in addition to the labor and
loss of life, not less than half a million dollars.
CHAPTER IX.
NAVIGATION.
BOUND UP.
BOUND DOWN.
Atchison was chosen as an outfitting point for the Salt Lake freighters, in addition to many other
reasons, because we had one of the best steamboat landings on the river, and had the best wagon road in
the country leading west. Twenty-four miles west of Atchison this road was intersected by the old
overland mail trail from St. Joseph. Leavenworth had laid out a new road west, over which it was
planned to run the Pike’s Peak Express stages in the spring of 1859, as well as the mule and ox teams, for
Denver and the mountain mining camps. A branch road was also opened to intersect this route from
Atchison in the spring of 1859, under the direction of Judge F. G. Adams. The expedition started west
from Atchison in the spring of that year, over what is now known and was then known as the Parallel
road, then through Muscotah and America City, across into the Big Blue river, near Blue Rapids, and
westward through Jewell county. The object of this expedition was to open a shorter route to the
mountains than the one opened by the Leavenworth company, and the route proposed did save sixty-
five miles distance, and almost twelve hours time. E. D. Boyd, an engineer, measured the entire distance
from Atchison to Denver. He also made an accurate report, showing distances and the crossing of
streams, and a brief description of the entire route, which was published in the Atchison Champion, in
June, 1859. According to that report, the distance from Atchison to Denver was 620 miles. But
notwithstanding the advantage of this new road, it was abandoned immediately and never traveled by ox
or mule trains out of Atchison, for the reason that the old military road by Fort Kearney and along the
Platte river enjoyed Government protection from the Indians, and was settled at intervals almost the
entire distance.
During the period of overland freighting on the plains, more trains left Atchison than any other
point on the river. The leading firms engaged in the freighting business were, Stevens & Porter;
Dennison & Brown; Hockaday-Burr & Company; J. S. Galbraith: George W. Howe; Brown Brothers; E.
K. Blair; I. N. Bringman; Roper & Nesbitt; Harrison Brothers; Henry Reisner; J. C. Peters; P. K. Purcell;
R. E. Wilson; Will Addoms; George I. Stebbins; John C. Bird; William Home; Amos Howell; Owen
Degan, and a number of others.
The cost of shipping merchandise to Denver was very high, as everything was carried by the pound,
rather than by the hundred pounds rate. Flour, bacon, molasses, whiskey, furniture and trunks were
carried at pound rates. The rates per pound on merchandise shipped by ox or mule wagons from
Atchison to Denver prior to 1860, were as follows:
Flour 9 cents
Tobacco 12½ cents
Sugar 13½ cents
Bacon 15 cents
Dry goods 15 cents
Crackers 17 cents
Whiskey 18 cents
Groceries 19½ cents
Trunks 25 cents
Furniture 31 cents
It has been said by those who witnessed the tremendous overland traffic of the late fifties and the
early sixties, that those of this generation can form no conception of the enormous amount of traffic
overland there was in those days. Trains were being constantly outfitted not only at Atchison, but at
other points along the river. Twenty-one days was about the time required for a span of horses or mules
to make the trip to Denver and keep the stock in good condition. It required five weeks for ox trains to
make the same distance, and to Salt Lake, horses and mules were about six weeks making the trip, and
ox trains were on the road from sixty-five to seventy days. It was the ox upon which mankind depended
in those days to carry on the commerce of the plains. They were the surest and safest for hauling a large
part of the freight destined for the towns and camps west of the Missouri river. Next in importance to
the ox, was the mule, because they were tough and reliable, and could endure fatigue.
The year of 1859 was a big year in the history of Atchison, for in that year the percentage of the
growth of the town was greater than any other year in its history. The fact that it was the best point on
the Missouri river for the overland staging and freighting outfits, brought it in greater commercial
prominence. At that time, Irwin & McGraw were prominent contractors, who were supplying the various
military posts on the frontier. The mere fact that these Government trains were started from Atchison,
gave the town wonderful prestige.
It was nothing unusual to see two or three steamboats lying at the levee, discharging freight, and as
many more in sight either going up the river from St. Louis, or down the river from St. Joe. It was not
uncommon for a boat to be loaded at Pittsburgh, Pa., or Cincinnati, Ohio, going down the Ohio river and
up the Mississippi and Missouri to Atchison; it was not an unusual sight to see a whole boat load of
wagons and ox yokes, mining machinery, boilers and other material necessary for the immense trade of
the West.
The greater part of the traffic out of Atchison to the West was over the Military road, along the south
bank of the Platte, and along this road teams of six to eight yoke of cattle, hauling heavily loaded wagons,
and strings of four or six horse or mule teams, formed almost an endless procession.
The liveliest period of overland trade extended from 1859 to 1866, during which time there was on
the plains and in the mountains an estimated floating population of 250,000. The greater majority of the
people on the plains produced but few of the necessities of life, and consequently they had to be supplied
from the Missouri river. During the closing year of the Civil war, the travel was immense, most of the
emigration going into the gold mining camps of the Northwest.
While there was considerable freighting out of Atchison to the West following the opening of the
Territory, overland staging did not reach its height until 1861. The era of overland staging from the
Missouri river to the Pacific coast lasted altogether about eight years. The first great overland staging
enterprise started in 1858, on what is known as the Southern or Butterfield route. This route ran from
St. Louis and Memphis, Tenn., intersecting at Ft. Smith, Ark. After being in operation for nearly three
years, the route was succeeded by a daily line on the Central route, which ran from the Missouri river
five years, first starting at St. Joseph, Mo., July 1, 1861, and then from Atchison in September of that
year. On the Central route, the through staging came to a close after the completion of the Union Pacific
railroad from Omaha across the continent. Originally the stage enterprise was known as the Overland
Mail Company—the Southern or Butterfield line. After it was transferred north and ran in connection
with the stages to Denver, it was known as the Central Overland California and Pike’s Peak Express
Company. After passing into the hands of Ben Holladay, it became the Overland Stage Line, and finally
the name was changed to the Holladay Overland Mail Express Company. In 1866, the line had been
consolidated with the Butterfield Overland Dispatch, a stage company which was organized in 1865, with
headquarters in Atchison.
Atchison’s importance as an overland staging terminus was fixed by reason of an order of the
United States Postoffice Department. Before the final change, making Atchison headquarters and
starting point for the mail, the road from Atchison westward intersected the road from St. Joseph at
Kennekuk. The distance from Atchison to Kennekuk was twenty-four miles, while it was about thirty-five
miles from St. Joseph, and consequently there was a saving of about nine miles in favor of Atchison. This
was an important item, in carrying the mails, and resulted in the order of the Postoffice Department
making Atchison the starting point. The distance by the overland stage line from Atchison to Placerville
was 1,913 miles, and following the abandonment of the Butterfield or Southern route, it became the
longest and the most important stage line in America. There were 153 stations between Atchison and
Placerville, located about twelve and one-half miles apart. The local fare was $225.00, or about twelve
cents per mile, and as high as $2,000.00 a day was frequently taken in at the Atchison office for
passenger fare alone. The fare between Atchison and Denver was $75.00, or a little over eight cents per
mile, and to Salt Lake City, $150.00. Local fares ran as high as fifteen cents per mile. Each passenger
was allowed twenty-five pounds of baggage. All in excess of that was charged at the rate of $1.00 per
pound. During the war, the fare to Denver was increased from seventy-five dollars to $100.00, and
before the close of the war, it had reached $175.00 or nearly twenty-seven cents per mile.
It required about 2,750 horses and mules to run the stage line between Atchison and Placerville. It
required, in addition to the regular supply of horses to operate the stages, some additional animals for
emergencies, and it was estimated that the total cost of the horses on this stage line was about one-half
million dollars. The harness was the finest that could be made, and cost about $150.00 for a complete
set of four, or about $55,000.00 for the whole line. The feeding of the stock was one of the big items of
expense, and there were annually consumed at each station from forty to eighty tons of hay, at a cost of
$15 to $40 per ton. Each animal was apportioned an average of twelve quarts of corn every day, which
cost from two to ten cents a pound. In the Salt Lake and California divisions, oats and barley, grown in
Utah, were substituted for corn, but which cost about the same.
There were about 100 Concord coaches which, in the early sixties cost about $1,000.00 each. The
company owned about one-half of the stations, in addition to thousands of dollars’ worth of
miscellaneous property, at different places along the route. There were superintendents, general and
local attorneys, paymasters and division agents, all of whom drew big salaries. Among the stage
company’s agents in the late fifties and early sixties were Hugo Richards and Paul Coburn, at Atchison;
Robert L. Pease, of Atchison, was also for a time agent at Denver.
The mail was carried from Atchison west by Forts Kearney, Laramie and Bridges, once a week. The
schedule time from the river to Salt Lake City was about eighteen days, and the distance was about 1,200
to 1,300 miles.
In 1861 a daily overland mail was established out of Atchison, and with the exception of a few weeks
in 1862, 1864 and 1865, on account of Indian troubles, the overland was in operation and ran stages
daily out of Atchison for about five years. It was the greatest stage line in the world, carrying mail,
passengers and express. It was also regarded as the safest and the fastest way to cross the plains, and the
mountain ranges. It was equipped with the latest modern four and six horse and mule Concord coaches,
and the meals at the eating stations along the route were first-class, and cost from fifty cents to $2.00
each.
When Atchison was selected as the starting place for the overland mail, it was not certain how long
it would remain the eastern terminus of the mail route. The Civil war was at its height, and the rebels
were doing much damage to the Hannibal & St. Joseph railroad, which had been constructed in 1859.
They tore up the track, burned the bridges, destroyed the culverts, fired into the trains, and placed
obstructions along the roadbed, frequently delaying the mail from two to six days. As a result of this
condition of affairs, it was feared that Atchison would lose the overland mail, and the Government would
change the starting point to some town further north, but because of the advantageous geographical
position of Atchison, it was decided that it would be disastrous to make a change, so the Government
placed a large number of troops along the entire line of the Hannibal & St. Joe, to insure the safety of the
mails, and Atchison continued to be the point of departure for the overland mail, until 1866.
The stage coaches used by the overland line were built in Concord, N. H. They carried nine
passengers inside, and one or two could ride on the box by the driver. Some of the stages were built with
an extra seat above and in the rear of the driver, so that three additional persons could ride there,
making fourteen, with the driver. Sometimes an extra man would be crowded on the box, making as
many as fifteen persons, who could ride on the Concord coach without very much inconvenience.
This chapter on overland staging would be unfinished, unless some reference was made to Ben
Holladay, who played such an important part in the overland staging days of this country. Ben Holladay
had a remarkable career. In his early days, when he resided in Weston, Mo., he drove a stage himself. He
was a genuine westerner, having run a saloon and tavern in Weston as early as 1838 and 1839. He went
overland to California in 1849, and took a train to Salt Lake City with $70,000 worth of goods. He spent
some time in Utah, where he made considerable money.
Besides operating the Overland Stage for over five years, Holladay had other important interests in
the West. Among his enterprises was a fleet of passenger steamers, plying between San Francisco and
Portland, Ore. At the height of his career he was a millionaire, and few men in the country accumulated
wealth more rapidly. He spent his money freely, and squandered vast sums when he was making it. After
he had accumulated a fortune, he went to New York to live, and built a most pretentious residence a few
miles out of New York, on the Hudson river, which he called Ophir Farm. After he was awarded some
good mail contracts by the Government, he built a mansion in Washington, which he furnished superbly,
and collected a large classical library, with handsomely bound volumes, and also was a patron of art,
collecting fine oil paintings of celebrated masters in Europe and America. He also made a collection of
fine bronzes and statuary, and paid $6,000.00 each for two bronze lions.
It was in 1860 that he came into possession of the Central Overland California Mail Line, but
subsequent trouble with the Indians damaged his property to the extent of a half million dollars. His
stage stations were burned, and his stock stolen, and stage coaches destroyed. Finally, in 1888, being
broken in health and in debt, his Washington home, with its contents, was sold under the hammer.
He came into possession of practically all the big overland routes by purchase and foreclosure of
mortgages, and he made his vast fortune in mail contracts from the Government. He remained at the
head of the overland line for about five years, taking possession of it in December, 1861, and disposing of
it, including the stations, rolling stock and animals, in the latter part of 1866, to Wells Fargo & Company.
Mr. Holladay died in August, 1877, in Portland, Ore., a poor man.
BUTTERFIELD’S OVERLAND DISPATCH.
One of the interesting promoters in overland staging days was D. A. Butterfield. He came to
Atchison from Denver in 1864, and engaged in the commission business in a large stone warehouse near
the Massasoit House, and, in addition to his commission business, he was agent for a line of packets
plying between St. Louis and Atchison. Shortly after his arrival in Atchison he began the development of
an overland stage line, which subsequently reached very large proportions. His ambition was to be at the
head of an overland stage line, and, having selected what was known as the Smoky Hill route along the
Kansas and Smoky Hill rivers, which was fifty miles shorter than any other route to Denver, he
proceeded with the further development of his plans. He was a smart, capable, ambitious and aggressive
fellow, with vim, and was in touch with a number of men of large means in New York, whom he soon
interested in his enterprise. Early in 1865 the following advertisement appeared in the Atchison Daily
Free Press, announcing Mr. Butterfield’s project:
“BUTTERFIELD’S OVERLAND DISPATCH.
“Through bills of lading given from New York, Boston, Philadelphia, Pittsburgh, Chicago, St. Louis, and
Burlington, Iowa.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com