Upload
shannon-martin
View
215
Download
0
Tags:
Embed Size (px)
Citation preview
CTS301 Connected SystemsManaged Programming For Win32 Developers
CTS301 Connected SystemsManaged Programming For Win32 Developers
David S. PlattDavid S. PlattSupreme and Exalted Supreme and Exalted Dictator-for-LifeDictator-for-LifeRolling Thunder ComputingRolling Thunder Computing
Mon 10:45Mon 10:45 CTS200 Service Orientation and the Windows/.NET DeveloperCTS200 Service Orientation and the Windows/.NET Developer
Mon 1:30Mon 1:30 CTS300 Prescriptive Guidance-Juggling Web Services, WSE, .NET Remoting, CTS300 Prescriptive Guidance-Juggling Web Services, WSE, .NET Remoting, System.EnterpriseServices, and MSMQSystem.EnterpriseServices, and MSMQ
Mon 3:15Mon 3:15 CTS308 Applied Web Services in Hewlett Packard's Core eCommerce SolutionsCTS308 Applied Web Services in Hewlett Packard's Core eCommerce Solutions
Mon 5:00Mon 5:00 CTS404 Best Practices for Dealing With State at Multiple Layers Within YourCTS404 Best Practices for Dealing With State at Multiple Layers Within Your .NET Applications .NET Applications
Tue 1:30Tue 1:30 DEVC27 Service Orientation OverviewDEVC27 Service Orientation Overview
Tue 3:15 CTS301 Managed Programming for Win32 Developers
Wed 2:00Wed 2:00 CTS302 Using Web Services Enhancements v2.0 (WSE) to Secure Web ServicesCTS302 Using Web Services Enhancements v2.0 (WSE) to Secure Web Services
Wed 10:15Wed 10:15 CTS400 Using Web Services Enhancements v2.0 for Messaging Over Multiple Machines CTS400 Using Web Services Enhancements v2.0 for Messaging Over Multiple Machines and Networksand Networks
Wed 5:30Wed 5:30 CTS303 Applied Web Services at the Ohio State University Medical CenterCTS303 Applied Web Services at the Ohio State University Medical Center
Thur 8:30Thur 8:30 CTS403 Handling Errors with TransactionsCTS403 Handling Errors with Transactions
Thur 8:30Thur 8:30 DEVC35 Web Services InteroperabilityDEVC35 Web Services Interoperability
Thur 1:30Thur 1:30 CTS406 Versioning of Connected .NET ApplicationsCTS406 Versioning of Connected .NET Applications
Thur 1:30Thur 1:30 DEVC16 Distributed Applications Performance PanelDEVC16 Distributed Applications Performance Panel
Thur 5:00Thur 5:00 CTS304 Availability and Reliability - Failure Is Not An OptionCTS304 Availability and Reliability - Failure Is Not An Option
Fri 10:45Fri 10:45 CTS405 Choosing a Hosting Model - Dealing with Threads, Application Domains, CTS405 Choosing a Hosting Model - Dealing with Threads, Application Domains, and Processesand Processes
Fri 1:00Fri 1:00 CTS306 Deployment and ManagementCTS306 Deployment and Management
Fri 2:45Fri 2:45 CTS307 Using Service Orientation to Drive Business ProcessesCTS307 Using Service Orientation to Drive Business Processes
Fri 9:00Fri 9:00 DEVC40 Versioning PanelDEVC40 Versioning Panel
Connected Systems TrackConnected Systems Track
Why Managed Code? Why Managed Code?
Better Applications, SoonerBetter Applications, Sooner
BetterBetter
Type checking and verificationType checking and verification
Garbage collectionGarbage collection
Exception handlingException handling
Code-access securityCode-access security
SoonerSooner
InheritanceInheritance
PrefabricationPrefabrication
Larger component marketplaceLarger component marketplace
Other OO featuresOther OO features
AgendaAgenda
Microsoft-SpecificMicrosoft-SpecificCOM InteropCOM Interop
COM+COM+
MSMQMSMQ
RemotingRemoting
Platform IndependentPlatform IndependentWinsockWinsock
HTTP and FTPHTTP and FTP
Web ServicesWeb Services
COM InteropCOM Interop
You can use COM objects from .NET by You can use COM objects from .NET by using a runtime-callable wrapper, thus:using a runtime-callable wrapper, thus:
.NET client.NET client COM objectCOM objectRuntimeRuntimecallablecallablewrapperwrapper
IUnkown, IDispspatch, IFoo interfacesIUnkown, IDispspatch, IFoo interfaces
COM InteropCOM Interop
AdvantagesAdvantages
1.1. Can write managed code and still use Can write managed code and still use legacy components if neededlegacy components if needed
COM InteropCOM Interop
CaveatsCaveats1.1. COM objects often leak in places COM objects often leak in places
the .NET garbage collector doesn’t the .NET garbage collector doesn’t clean up.clean up.
Consider rewriting leaky components in Consider rewriting leaky components in managed codemanaged code
try out-of-proc objects using COM+ try out-of-proc objects using COM+ process recycling feature in W2k3 SV process recycling feature in W2k3 SV
COM InteropCOM Interop
CaveatsCaveats2.2. Managed – unmanaged transition Managed – unmanaged transition
slower than pure managed – buy CPU slower than pure managed – buy CPU cycles with cashcycles with cash
3.3. Requires UnmanagedCode permissionRequires UnmanagedCode permission
To Explore COM Interop FurtherTo Explore COM Interop Further
““.NET Interop: Get Ready for Microsoft .NET Interop: Get Ready for Microsoft .NET by Using Wrappers to Interact .NET by Using Wrappers to Interact with COM-based Applications,” with COM-based Applications,” by David S. Platt, MSDN Magazine, by David S. Platt, MSDN Magazine, August 2001 August 2001
Online at: Online at: http://msdn.microsoft.com/msdnmag/ishttp://msdn.microsoft.com/msdnmag/issues/01/08/interop/default.aspxsues/01/08/interop/default.aspx
Enterprise Services/COM+Enterprise Services/COM+
COM+ provides useful runtime services to COM+ provides useful runtime services to COM object designers such as COM object designers such as
TransactionsTransactions
Object PoolingObject Pooling
SynchronizationSynchronization
JIT ActivationJIT Activation
Role-Based SecurityRole-Based Security
These are available to managed objects via These are available to managed objects via System.EnterpriseServicesSystem.EnterpriseServices
Enterprise Services/COM+Enterprise Services/COM+
Easy to useEasy to use
Derive from Serviced ComponentDerive from Serviced Component
Specify service usage statically via Specify service usage statically via attributes or dynamically via attributes or dynamically via programming modelprogramming model
Vote on transaction with ContextUtil or Vote on transaction with ContextUtil or auto-completeauto-complete
Managed Code TransactionManaged Code TransactionManaged Code TransactionManaged Code Transaction
Enterprise Services/COM+Enterprise Services/COM+
Performance Performance
In real-life scenarios, method call In real-life scenarios, method call performance is equal to unmanaged performance is equal to unmanaged
Understand what COM+ is doing under Understand what COM+ is doing under the hood – most performance the hood – most performance problems come from failing to do this problems come from failing to do this
See Rich Turner’s white paper at end of See Rich Turner’s white paper at end of
this sectionthis section
Enterprise Services/COM+Enterprise Services/COM+
AdvantagesAdvantages1.1. Easier programming of services Easier programming of services
you needyou need
2.2. Method call code is fastMethod call code is fast
3.3. Migration path to “Indigo”Migration path to “Indigo”
Enterprise Services/COM+Enterprise Services/COM+
CaveatsCaveats1.1. Object creation and destruction are Object creation and destruction are
somewhat slower – use JITA and somewhat slower – use JITA and pooling (should do that anyway) pooling (should do that anyway)
2.2. Be chunky Be chunky
3.3. Avoid STA Avoid STA
4.4. Learn underlying COM+ Learn underlying COM+
5.5. Avoid finalizers Avoid finalizers
To Explore Enterprise Services/COM+ FurtherTo Explore Enterprise Services/COM+ Further
““COM+ Integration: How .NET COM+ Integration: How .NET Enterprise Services Can Help You Enterprise Services Can Help You Build Distributed Applications” Build Distributed Applications” by Tim Ewald, MSDN magazine,by Tim Ewald, MSDN magazine,October 2001October 2001
Online at: Online at: http://msdn.microsoft.com/msdnmag/ishttp://msdn.microsoft.com/msdnmag/issues/01/10/complus/sues/01/10/complus/
To Explore Enterprise Services/COM+ FurtherTo Explore Enterprise Services/COM+ Further
““.NET Enterprise Services .NET Enterprise Services Performance”, by Turner, Buerk, Performance”, by Turner, Buerk, and Driver and Driver
Online at: Online at: http://http://msdn.microsoft.com/library/default.aspmsdn.microsoft.com/library/default.asp?url?url=/library/en-us/dncomser/html/entsvcp=/library/en-us/dncomser/html/entsvcperf.asperf.asp
COM and .NET Component Services by COM and .NET Component Services by Juval Lowy, O’Reilly Press Juval Lowy, O’Reilly Press ISBN 0596001037ISBN 0596001037
MSMQ/Messaging ServicesMSMQ/Messaging Services
Store-and-forward messaging service Store-and-forward messaging service for decoupled operationfor decoupled operation
Requires different design thinking; Requires different design thinking;
For example, you can’t depend on the For example, you can’t depend on the order in which messages are order in which messages are processed. Responses come processed. Responses come asynchronously, sometimes not at allasynchronously, sometimes not at all
MSMQ/Messaging ServicesMSMQ/Messaging Services
Managed apps access MSMQ via the Managed apps access MSMQ via the System.Messaging namespaceSystem.Messaging namespace
Implemented as a wrapper over MSMQ Implemented as a wrapper over MSMQ via P/Invokevia P/Invoke
Need to choose data-coupled versus Need to choose data-coupled versus code-coupled operationcode-coupled operation
System.MessagingSystem.MessagingSystem.MessagingSystem.Messaging
MSMQ/Messaging ServicesMSMQ/Messaging Services
AdvantagesAdvantages1.1. Easy sending and receiving of Easy sending and receiving of
most .NET objectsmost .NET objects
2.2. Fairly easy tweaking of most Fairly easy tweaking of most of remainderof remainder
MSMQ/Messaging ServicesMSMQ/Messaging Services
CaveatsCaveats
1.1. Message body is limited to 4 MBMessage body is limited to 4 MB
2.2. Coarsely-grained code access security Coarsely-grained code access security capabilities; Full trust is required to use capabilities; Full trust is required to use System.Messaging at all; There are no System.Messaging at all; There are no subset permissions subset permissions
3.3. Lacks a few seldom-used features of Lacks a few seldom-used features of MSMQ’s COM libraries, such as direct MSMQ’s COM libraries, such as direct access to SOAP envelope; You can get access to SOAP envelope; You can get these by importing the COM libraries these by importing the COM libraries through .NET’s COM interop featurethrough .NET’s COM interop feature
To Explore MSMQ/Messaging Services FurtherTo Explore MSMQ/Messaging Services Further
““Send MSMQ Messages Securely Send MSMQ Messages Securely Across the Internet with HTTP and Across the Internet with HTTP and SOAP”, by David S. Platt,SOAP”, by David S. Platt,MSDN Magazine, December 2003 MSDN Magazine, December 2003
Online at: Online at: http://msdn.microsoft.com/msdnmag/ishttp://msdn.microsoft.com/msdnmag/issues/03/12/MSMQandNET/sues/03/12/MSMQandNET/
.NET Remoting.NET Remoting
Looks and feels similar to DCOMLooks and feels similar to DCOM
ClientClient ServerServer
StubStubProxyProxy ObjectObjectChannelChannel
4.4. Call transmitted Call transmitted through channel through channel to stubto stub
5.5. Call made locally Call made locally to objectto object
3.3. Client makes calls Client makes calls on local proxyon local proxy
1.1. Client makes call Client makes call creating object creating object on serveron server
2.2. Object created on Object created on server; Proxy, server; Proxy, stub, and channel stub, and channel set upset up
.NET Remoting.NET Remoting
Important differences from DCOMImportant differences from DCOMUses .NET FrameworkUses .NET Framework
No unmanaged versionNo unmanaged version
Client can’t launch host applicationClient can’t launch host application
Object lifetime managed by leasing Object lifetime managed by leasing instead of reference countinginstead of reference counting
.NET Remoting.NET Remoting
More topological options than More topological options than Web ServicesWeb Services
Stateless, stateful, or singleton objectsStateless, stateful, or singleton objects
TCP, HTTP or custom transportsTCP, HTTP or custom transports
Binary, SOAP, or custom formattersBinary, SOAP, or custom formatters
.NET Remoting.NET Remoting
Microsoft recommends it forMicrosoft recommends it forCalling between different application Calling between different application domains inside the same process domains inside the same process
Handling custom wire protocols Handling custom wire protocols and formats and formats
.NET Remoting.NET Remoting.NET Remoting.NET Remoting
.NET Remoting.NET Remoting
Rich Turner’s blog says:Rich Turner’s blog says:
““No! Nope! Niet! Non! Negative! Nuh-huh! No! Nope! Niet! Non! Negative! Nuh-huh! [shake head vigorously]!!!”[shake head vigorously]!!!”
But …But …
.NET Remoting.NET Remoting
CaveatsCaveats
1.1. Won’t interop with Indigo on wireWon’t interop with Indigo on wire
2.2. Harder to port than asmx/ws codeHarder to port than asmx/ws code
3.3. Requires sharing assemblies – intimate Requires sharing assemblies – intimate interaction, not service-orientedinteraction, not service-oriented
4.4. No security built inNo security built in
.NET Remoting.NET Remoting
Caveats, continuedCaveats, continued
5.5. Few wizards, not nearly as much mind-share Few wizards, not nearly as much mind-share as web servicesas web services
6.6. Fewer people doing it; Harder to find expertsFewer people doing it; Harder to find experts
7.7. Your COM reflexes feel like they’ll work, Your COM reflexes feel like they’ll work, but often don’tbut often don’t
To Explorer .NET Remoting FurtherTo Explorer .NET Remoting Further
““Design and Develop Seamless Distributed Design and Develop Seamless Distributed Applications for the Common Language Applications for the Common Language Runtime” by Dino Esposito, MSDN Magazine, Runtime” by Dino Esposito, MSDN Magazine, October 2002; Online at: October 2002; Online at: http://msdn.microsoft.com/msdnmag/issues/http://msdn.microsoft.com/msdnmag/issues/02/10/NETRemoting/02/10/NETRemoting/
Introducing Microsoft .NET, 3rd EditionIntroducing Microsoft .NET, 3rd Edition, by , by David S. Platt, Microsoft Press; Chapter 10.David S. Platt, Microsoft Press; Chapter 10.
Advanced .NET Remoting by Ingo Rammer, Advanced .NET Remoting by Ingo Rammer, A! Press; Separate editions available A! Press; Separate editions available in C# and VB in C# and VB
WinsockWinsock
Closest-to-the metal programmingClosest-to-the metal programming
Earliest cross-platform programmingEarliest cross-platform programming
Available to managed applications via Available to managed applications via System.Net.Sockets namespaceSystem.Net.Sockets namespace
System.Net.SocketsSystem.Net.SocketsSystem.Net.SocketsSystem.Net.Sockets
WinsockWinsock
AdvantagesAdvantages
1.1. Very tight, finest-grained control Very tight, finest-grained control
2.2. Work with earliest cross-platform Work with earliest cross-platform legacy apps, particularly mainframes legacy apps, particularly mainframes
WinsockWinsock
CaveatsCaveats1.1. Low level of abstraction, you spend Low level of abstraction, you spend
lots of time on little stuff lots of time on little stuff
2.2. Geeks like low abstraction, but it Geeks like low abstraction, but it doesn’t make moneydoesn’t make money
3.3. Mostly for plumbersMostly for plumbers
To Explore Winsock FurtherTo Explore Winsock Further
““VB.NET TCP Client - Server Socket VB.NET TCP Client - Server Socket Communications,” by Peter A. Bromberg, Communications,” by Peter A. Bromberg, Ph.D.; Online at: Ph.D.; Online at: http://www.eggheadcafe.com/articles/200203http://www.eggheadcafe.com/articles/20020323.asp23.asp
““The Dryer ate my Winsock” The Dryer ate my Winsock” by Randy Cragin; Online at: by Randy Cragin; Online at: http://members.cox.net/randus/VB9.htmhttp://members.cox.net/randus/VB9.htm
Network Programming for the Microsoft .NET Network Programming for the Microsoft .NET Framework, by Anthony Jones, Jim Ohlund, Framework, by Anthony Jones, Jim Ohlund, and Lance Olson; Microsoft Press, 2003, and Lance Olson; Microsoft Press, 2003, ISBN 073561959X ISBN 073561959X
HTTP And FTPHTTP And FTP
Higher level protocols than socketsHigher level protocols than sockets
More details abstracted awayMore details abstracted away
HTTP available through: HTTP available through: System.Net.WebRequest and System.Net.WebRequest and WebResponse classWebResponse class
FTP coming in WhidbeyFTP coming in Whidbey
HttpWebRequestHttpWebRequestHttpWebRequestHttpWebRequest
HTTP And FTPHTTP And FTP
AdvantagesAdvantages1.1. Easy programmingEasy programming
2.2. Goes just about everywhereGoes just about everywhere
CaveatsCaveats1.1. Still low level of abstractionStill low level of abstraction
2.2. Still most useful for plumbersStill most useful for plumbers
To Explore HTTP FurtherTo Explore HTTP Further
““System.Net.HttpWebRequestClass”, System.Net.HttpWebRequestClass”, online at: online at: http://www.dotnet247.com/247referenchttp://www.dotnet247.com/247reference/System/Net/HttpWebRequest.aspxe/System/Net/HttpWebRequest.aspx
Network Programming for the Network Programming for the Microsoft .NET Framework, by Anthony Microsoft .NET Framework, by Anthony Jones, Jim Ohlund, and Lance Olson; Jones, Jim Ohlund, and Lance Olson; Microsoft Press, 2003, Microsoft Press, 2003, ISBN 073561959XISBN 073561959X
Web ServicesWeb Services
SOAP-based web services first SOAP-based web services first available via COM-based SOAP toolkit available via COM-based SOAP toolkit – being retired July 1, 2004– being retired July 1, 2004
Essentially all of .NET was designed to Essentially all of .NET was designed to enable web servicesenable web services
Service-oriented architecture requires Service-oriented architecture requires different design thinking – different design thinking – See Rich Turner’s blog given earlierSee Rich Turner’s blog given earlier
Web ServicesWeb Services
WS classes in Visual Studio provide WS classes in Visual Studio provide basic connectivitybasic connectivity
Web Service Enhancements 2.0 adds Web Service Enhancements 2.0 adds security: Authentication, Integrity, security: Authentication, Integrity, EncryptionEncryption
Also adds routing and Also adds routing and attachment supportattachment support
Official product, but time-limited Official product, but time-limited support: 2 years standard, 1 extendedsupport: 2 years standard, 1 extended
Web Service Web Service Enhancements 2.0Enhancements 2.0Web Service Web Service Enhancements 2.0Enhancements 2.0
Web ServicesWeb Services
Advantages Advantages
1.1. Much easier programming of clients Much easier programming of clients than soap toolkitthan soap toolkit
2.2. Much, much easier programming of Much, much easier programming of servers, dittoservers, ditto
3.3. Web Services Enhancements for Web Services Enhancements for security, routing, and attachmentssecurity, routing, and attachments
4.4. Future development work proceeds Future development work proceeds along this path – look out for “Indigo”along this path – look out for “Indigo”
Web ServicesWeb Services
CaveatsCaveats1.1. You have to make the change; It’s timeYou have to make the change; It’s time
To Explore FurtherTo Explore Further
““Migrating from the SOAP Toolkit to Migrating from the SOAP Toolkit to Web Services”, by Peter Vogel, online Web Services”, by Peter Vogel, online at: at: http://msdn.microsoft.com/webservicehttp://msdn.microsoft.com/webservices/building/soaptk/default.aspx?pulls/building/soaptk/default.aspx?pull=/library/en-us/=/library/en-us/dndotnet/html/migrsoapwebserv.aspdndotnet/html/migrsoapwebserv.asp.NET Web Services: Architecture and .NET Web Services: Architecture and Implementation, by Keith Ballinger, Implementation, by Keith Ballinger, Addison-Wesley, 2003 ISBN 0-321-Addison-Wesley, 2003 ISBN 0-321-11359-411359-4
To Explore Further, Cont’dTo Explore Further, Cont’d
The Microsoft Platform Ahead, by The Microsoft Platform Ahead, by David S. Platt; Microsoft Press, 2004; David S. Platt; Microsoft Press, 2004; Chapter 4 covers the Web Service Chapter 4 covers the Web Service Enhancements, version 2.0. Enhancements, version 2.0.
Rich Turner’s blog “On the Road to Rich Turner’s blog “On the Road to ‘Indigo’ ” ‘Indigo’ ”
http://blogs.msdn.com/richturner666/http://blogs.msdn.com/richturner666/
ConclusionConclusion
Managed Code is not that different Managed Code is not that different from what you’re doing now from what you’re doing now
Almost everything you currently do Almost everything you currently do unmanaged can be done managed, unmanaged can be done managed, probably better and more easilyprobably better and more easily
Q1:Q1: Overall satisfaction with the sessionOverall satisfaction with the session
Q2:Q2: Usefulness of the informationUsefulness of the information
Q3:Q3: Presenter’s knowledge of the subjectPresenter’s knowledge of the subject
Q4:Q4: Presenter’s presentation skillsPresenter’s presentation skills
Q5:Q5: Effectiveness of the presentationEffectiveness of the presentation
Please fill out a session evaluation on CommNetPlease fill out a session evaluation on CommNet
© 2004 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.