Jim Fawcett CSE775 – Distributed Objects Spring 2006

Slides:



Advertisements
Similar presentations
Using.NET Platform Note: Most of the material of these slides have been taken & extended from Nakov’s excellent overview for.NET framework, MSDN and wikipedia.
Advertisements

Attributes Programming in C# Attributes CSE 494R (proposed course for 459 Programming in C#) Prof. Roger Crawfis.
Why COM and.Net? Jim Fawcett CSE775 – Distributed Objects Spring 2005.
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
1 Introduction to.NET Framework. 2.NETFramework Internet COM+ Orchestration Orchestration Windows.NET Enterprise ServersBuildingBlockServices Visual Studio.NET.
.NET Framework Introduction: Metadata
The Metadata System1. 2 Introduction Metadata is data that describes data. Traditionally, metadata has been found in language- specific files (e.g. C/C++
CIS NET Applications1 Chapter 2 –.NET Component- Oriented Programming Essentials.
.Net Remoting. 2 Distributed Computing under.Net In.Net, there are three levels of access to distributed computing machinery: In.Net, there are three.
C# Programming Fundamentals of Object-Oriented Programming Fundamentals of Object-Oriented Programming Introducing Microsoft.NET Introducing Microsoft.NET.
.NET Framework Danish Sami UG Lead.NetFoundry
Introduction to Java Beans CIS 421 Web-based Java Programming.
Module 14: Attributes. Overview Overview of Attributes Defining Custom Attributes Retrieving Attribute Values.
Attributes C#.Net Software Development Version 1.0.
.NET Mobile Application Development XML Web Services.
Building Custom Controls with ASP.NET and the Microsoft ®.NET Framework Rames Gantanant Microsoft Regional Director, Thailand
.Net Reflection Taipan Tamsare. Overview Reflection core concepts Exploring metadata Detail information Attributes Building Types at runtime.
Integrating and Extending Workflow 8 AA301 Carl Sykes Ed Heaney.
METADATA IN.NET Presented By Sukumar Manduva. INTRODUCTION  What is Metadata ? Metadata is a binary information which contains the complete description.
INTRODUCTION BEGINNING C#. C# AND THE.NET RUNTIME AND LIBRARIES The C# compiler compiles and convert C# programs. NET Common Language Runtime (CLR) executes.
Jim Fawcett CSE687 – Object Oriented Design Spring 2001
Jim Fawcett CSE681 – SW Modeling & Analysis Spring 2005
Jim Fawcett CSE775 – Distributed Objects Spring 2003
Review of Last Year’s Midterm
CSE791 - Distributed Objects, Spring 2002
Jim Fawcett CSE775 – Distributed Objects Spring 2017
Abstract Factory Pattern
Jim Fawcett CSE687 – Object Oriented Design Spring 2016
Jim Fawcett CSE681 – SW Modeling & Analysis Fall 2014
Jim Fawcett CSE775 – Distributed Objects Spring 2009
Browne Bag Seminar Applied .Net Attributes
.NET Remoting Priyanka Bharatula.
Using Application Domains Effectively
Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2005
.Net A brief introduction to
Out-of-Process Components
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
Satisfying Open/Closed Principle
Jim Fawcett CSE775 – Distributed Objects Spring 2003
Windows Communication Foundation and Web Services
Active Server Pages ASP.Net
Abstract Factory Pattern
Remote Method Invocation
Intent (Thanks to Jim Fawcett for the slides)
CS360 Windows Programming
Module 1: Getting Started
Introduction to C# AKEEL AHMED.
Creating and Using Classes
Programming in C# CHAPTER 1
Windows Internals Brown-Bag Seminar Chapter 1 – Concepts and Tools
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
.NET and .NET Core 10. Enabling Contracts Pan Wuming 2017.
CSE 451: Operating Systems Winter 2007 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Spring 2012 Module 22 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Autumn 2009 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Module 10: Implementing Managed Code in the Database
Out-of-Process Components
CIS 199 Final Review.
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Jim Fawcett CSE775 – Distributed Objects Spring 2006
.Net Application Domains
Jim Fawcett CSE681 – SW Modeling & Analysis Fall 2018
Jim Fawcett CSE775 – Distributed Objects Spring 2004
Lecture 7 ATL and Out-of-Process Components
C# COM Interoperability
Jim Fawcett CSE791 – Distributed Objects Spring 2002
Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2007
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Jim Fawcett CSE687 – Object Oriented Design Spring 2015
Presentation transcript:

Jim Fawcett CSE775 – Distributed Objects Spring 2006 .Net Attributes Jim Fawcett CSE775 – Distributed Objects Spring 2006

References Applied .Net Attributes, Bock and Barnaby, Apress, 2003 The C# Programming Lanuage, Anders Hejlsberg, et. al., Addison-Wesley, 2004 Pro C# 2005 and the .Net 2.0 Platfrom, Andrew Troelsen, Apress, 2005 COM Programming with Microsoft .Net, Templeman, Mueller, Microsoft Press, 2003 Brown Bag Seminar, Applied .Net Attributes, Mario Tayah, 2005 MSDN listing of .Net Attribute Hierarchy MSDN: Extending Metadata with Attributes

Uses of Attributes in .Net Provide custom additions to metadata for managed types Support serialization Support debugging and tracing Set COM+ attributes Activation, queuing, security, events, contexts, object pooling, synchronization, transactions Support creation of COM objects Support creation of .Net controls Support creation of Web Services Create ATL Server code – essentially builds ISAPI filters Implement performance counters Implement OLEDB consumers

Kinds of Attributes Custom attributes Distinguished custom attributes Add entries to metadata but are not used by run-time Distinguished custom attributes These attributes have data stored in the assembly next to the items to which it applies. OneWay is a distinguished custom attribute that affects marshaling by the run-time Pseudo custom attributes Changes, does not extend existing metadata Serializable is a pseudo custom attribute. It sets or resets the metadata flag tdSerializable

Defining Custom Attributes Create a class marked with the AttributeUsage attribute [AttributeUsage(AttributeTargets::All, AllowMultiple=true)] class myAttribute : System.Attribute { … } Targets include: Assembly, Class, Delegate, Event, Field, Method, …, All Typically, the class provides a constructor accepting a value of some type, e.g., string, and a property to retrieve that value. The value is stored in the metadata of the assembly that implements the attributed target. It is retrieved using the Reflection API.

Using Custom Attributes Decorate the target code with the custom attribute: [myAttribute(args)] public class decoratedClass { … } This serializes member data of the myAttribute class into metadata for the assembly holding class decoratedClass. Now other programs can access this information from the assembly’s metadata using reflection: Type t = typeof(target); object [] obj = Attribute.GetCustomAttributes(t); Now cast the elements of the obj array to the types of the stored metadata, e.g., the member data of class myAttribute.

Some .Net Provided Attributes [CLSCompliant(true)] - class fails to compile if not compliant [Conditional(“Debug”)] - won’t get called unless Debug defined [Assembly: AssemblyTitle(“…”)] - assembly descriptions [Assembly: AssemblyVersion(“1.2”)] [DllImport(“kernel32.dll”)] - accessing unmanaged global function public static extern int Beep(int freq, int dur); [Serializable()] - enabling serialization public class myClass { … } [OneWay()] - marshal only to remote object public void myFunc(string msg) { … } [Synchronization()] - allow access by one thread at a time class SomeClass : ContextBoundObject { … }

Design-Time and Security Attributes Attributes used with user defined controls [Category(“Custom Properties”)] - makes property page category [DefaultEvent(myEvent)] - double click on control to wire up [Description(“myPropertDesc”)] - description shown when selected [ToolBoxBitmap(“myBitMap.bmp”)] – defines bitmap used in toolbox Declarative security settings [FileIOPermission(SecurityAction.Deny, Read=@”c:\Windows\System32”)] public in ReadFile(string path) { … }

Support Creation of COM Objects

COM Attributes [ coclass, // an implementing class plus COM infrastructure threading("apartment"), vi_progid("AttribATL.Test"), progid("AttribATL.Test.1"), version(1.0), uuid("CC51A06F-70D1-4113-A821-3756FC45ADF9"), helpstring("Test Class") ] [ module // defines a COM server ( dll, uuid = "{E9944495-22AF-422F-A011-AE3FD9E17644}", name = "AttribATL", helpstring = "AttribATL 1.0 Type Library", resource_name = "IDR_ATTRIBATL“ ) ]; object attribute identifies an interface, events , IDL attributes, …

What they do Metadata attributes provide data that is used at compile time and/or runtime in an assembly’s metadata. COM attributes cause code to be generated and injected into the MSIL stream. C++ uses two providers: clxx.dll used for type generation and marshaling Atlprov.dll for ATL.

Building Attributed ATL Component

Adding a Class

Adding Simple Object

Test Class

Selecting Attribute Parameters

Adding Methods to Interface

Sending and Receiving Strings

Client Running Attributed ATL Component