microsoft .net interoperability for beginners
DESCRIPTION
Microsoft .NET Interoperability for Beginners. Vjekoslav Babic (Fortempo). About me. Vjekoslav Babić consultant, trainer, blogger, author Twitter: @ v jekob Mibuso : Vjeko Blog:vjeko.com Author of many How Do I… videos for MSDN and PartnerSource for NAV 2013 and NAV 2013 R2 - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/1.jpg)
MICROSOFT .NET INTEROPERABILITY
FOR BEGINNERSVjekoslav Babic
(Fortempo)
![Page 2: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/2.jpg)
Vjekoslav Babićconsultant, trainer, blogger, author
Twitter: @vjekobMibuso: VjekoBlog: vjeko.com
Author of many How Do I… videos for MSDN and PartnerSource for NAV 2013 and NAV 2013 R2
Co-author of “Implementing Microsoft Dynamics NAV 2009” book
ABOUT ME
![Page 3: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/3.jpg)
HOW OTHER PEOPLE SEE PROGRAMMERS
![Page 4: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/4.jpg)
HOW PROGRAMMERS SEE OTHER PEOPLE
![Page 5: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/5.jpg)
![Page 6: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/6.jpg)
![Page 7: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/7.jpg)
Most of the time?
WHAT DO PROGRAMMERS REALLY DO?
![Page 8: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/8.jpg)
![Page 9: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/9.jpg)
SO, WHAT DO PROGRAMMERS DO MOST OF THE TIME?
![Page 10: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/10.jpg)
% OF TOTAL TIME SPENT PROGRAMMING
![Page 11: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/11.jpg)
% OF TOTAL TIME SPENT PROGRAMMING IN C/AL
![Page 12: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/12.jpg)
37.5% OF ALL STATISTICS AREJUST MADE UPON THE SPOT
![Page 13: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/13.jpg)
WHAT ARE WE DOING HERE TODAY?Basic Concepts• Constructors• Methods• Overloading• Events• Enumerations
Slightly Advanced Concepts• Classes and Interfaces• Arrays and Collections• Enumerators• Generics• Reflection• Creating Assemblies• Creating Control Add-ins
![Page 14: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/14.jpg)
HOW ARE WE DOING IT?General conceptsManaging strings and textManaging dates, times, and numbersAccessing operating system, file system, and the environmentManaging data, arrays, collections, and streamsCustom assembliesClient Add-ins
![Page 15: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/15.jpg)
PART ONEGeneral concepts
![Page 16: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/16.jpg)
ASSEMBLIESBuilding blocks of the .NET Framework
Assemblies can be:• Executable files (EXE)• Dynamic Link Libraries (DLL)
Assemblies can be deployed to:• Single application: any folder accessible to a .NET application• All applications: Global Assembly Cache (GAC)
![Page 17: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/17.jpg)
TYPE.NET Framework is strongly-typed, very similar to C/AL
Types can be:• Simple• Complex
.NET is object-oriented:• Types can be inherited
Two types of complex types:• Classes• Interfaces
![Page 18: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/18.jpg)
CLASSES AND INTERFACESBoth represent complex types (types that contain members)
Classes:• Define the structure• Encapsulate functionality• One class can inherit from only one parent class
Interfaces:• Only define the structure, but not the functionality• Represent behaviors of classes• One class can implement multiple interfaces• By convention, names start with I, and many names end with …
able
![Page 19: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/19.jpg)
THE DotNet DATA TYPEVariables of type DotNet give access to .NET Framework
Each DotNet variable specifies:• Assembly• Type
DotNet gives access to:• Methods• Properties• Constructors• Enumerations
![Page 20: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/20.jpg)
IMPORTANT: CASE SENSITIVITYAll .NET Framework identifiers are CASE SENSITIVE
![Page 21: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/21.jpg)
PART TWOManaging strings and text
![Page 22: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/22.jpg)
System.StringA powerful class to handle text information.Maps fully and directly to Text data type in C/AL.
![Page 23: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/23.jpg)
METHODSEquivalent to functions in C/AL
Methods are defined by their signature. Signature consists of:• Name• Type and kind of parameters (by value, by reference, or output)
Return value can be:• Of specific type• void
![Page 24: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/24.jpg)
System.String POINTS OF INTEREST
Analyzing content
• StartsWith• EndsWith• Contains• IndexOf• IndexOfAny• IsNullOrWhiteSpace• LastIndexOf• LastIndexOfAny• Substring
Modifying content
• Insert• PadLeft• PadRight• Remove• Replace• Trim• TrimStart• TrimEnd
![Page 25: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/25.jpg)
System.Text.StringBuilderA very powerful class to handle large text data efficiently.
![Page 26: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/26.jpg)
CONSTRUCTORSCreate an instance of a class.
There is no equivalent in C/AL to constructors.CREATE function for instantiating automation objects is the closest
Typically used to:• Initialize the default state of an object• Execute default initialization logic• Limit instantiation
![Page 27: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/27.jpg)
SYNTAX OF A CONSTRUCTORThe name of the constructor always matches the class name.
This probably looks confusing in C/AL:StringBuilder := StringBuilder.StringBuilder;
(why in the Earth do we need all those StringBuilders?)
Replace the StringBuilder variable name with s, and it’s more manageable:s := s.StringBuilder;
The syntax of the constructor in C/AL is the following:Variable := Variable.[Class Name]({argument1, …});
![Page 28: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/28.jpg)
System.Diagnostics.StopwatchA simple and useful class to handle time measurements.
![Page 29: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/29.jpg)
NAMESPACEA higher-level scope used to organize code
Namespace has a many-to-many relationship to assemblies:• One assembly can contain multiple namespaces• The same namespace can span multiple assemblies
![Page 30: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/30.jpg)
System.Text.RegularExpressionsA namespace containing classes for managing regular expressions.
In case you didn’t know:• Regular Expressions (RegEx) are a language used for searching
text data through pattern matching• Regular Expressions are SQL of textual data
![Page 31: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/31.jpg)
OVERLOADINGCapability that allows multiple members to use the same name as long as the signature remains different.
C/AL understands overloading of:• Methods• Constructors
.NET supports, but C/AL does not understand overloading of:• Indexers• Operators
![Page 32: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/32.jpg)
PART THREEManaging dates, times, and numbers
![Page 33: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/33.jpg)
System.DateTimeManages date and time information.Maps fully and directly to DateTime data type in C/AL.
Many useful properties and methods.
![Page 34: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/34.jpg)
PROPERTIES AND FIELDSProperties and Fields are members of complex classes that contain a
value.
Property:• Always accessible from C/AL• Can be gettable, settable, or both
Field:• Never accessible from C/AL
![Page 35: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/35.jpg)
System.GlobalizationNamespace that defines a lot of useful type for managing date and time formats, regional settings, cultures, etc.
Useful classes:• Calendar• CultureInfo• DateTimeFormatInfo• NumberFormatInfo
![Page 36: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/36.jpg)
System.Globalization.CalendarManages time division into years, months, weeks, days, etc.
![Page 37: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/37.jpg)
System.Globalization.CultureInfoProvides access to culture information. Cultures are the heart of the .NET localization/globalization functionality.
![Page 38: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/38.jpg)
System.Globalization.DateTimeFormatInfoProvides access to date and time formatting information.
![Page 39: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/39.jpg)
System.Globalization.NumberFormatInfoProvides access to number formatting information.
![Page 40: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/40.jpg)
System.MathProvides methods for trigonometric, logarithmic, and other common mathematical functions.
![Page 41: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/41.jpg)
System.Numerics.BigIntegerRepresents an arbitrarily large integer value, without any theoretical upper or lower bounds.
![Page 42: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/42.jpg)
System.ConvertConverts a base data type to another base data type.
![Page 43: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/43.jpg)
PART FOURAccessing operating system, file system, and the environment
![Page 44: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/44.jpg)
System.IONamespace that provides many useful input and output classes.
![Page 45: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/45.jpg)
System.IO.FileProvides static methods for the creation, copying, deletion, moving, and opening of files.
![Page 46: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/46.jpg)
STATIC OBJECTS AND METHODSStatic classes cannot be instantiatedStatic methods can be called on classes
Static classes and members are shared for the whole application domain
Microsoft Dynamics NAV Server runs as a single application domain
![Page 47: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/47.jpg)
System.IO.DirectoryExposes static methods for creating, moving, and enumerating through directories and subdirectories.
![Page 48: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/48.jpg)
System.IO.PathPerforms operations on String instances that contain file or directory path information.
![Page 49: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/49.jpg)
System.IO.FileSystemWatcherListens to the file system change notifications and raises events when a directory, or file in a directory, changes.
![Page 50: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/50.jpg)
EVENTSEnable a class to notify other classes when something of interest
happens.
Equivalent to C/AL triggers.
Events are not automatically exposed.You must first set the WithEvents property.
Events can run be:• Server-Side: default behavior, if RunOnClient is No• Client-Side: if RunOnClient is Yes
![Page 51: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/51.jpg)
EVENTS ARE NOT AS INNOCENT AS THEY APPEARWhenever using events, consider:• Client-Side events can only run in pages• Events can be synchronous and asynchronous• Event triggers are only created when the WithEvents is first set to
Yes
![Page 52: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/52.jpg)
ENUMERATIONSTypes that consist of set of named constants.
Similar, but not nearly equal to C/AL options.
C/AL .NET
Always of Integer type Of any integer numeric type, except char
Always 0-based 0-based by default, but can be any value
Each consecutive element is increased by 1
Every element can have an explicit numeric value, even negative
![Page 53: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/53.jpg)
SUPPORT FOR ENUMERATIONS IN C/SIDE
NAV 2009 R2 NAV 2013
Does not recognize them Recognizes them
You must use integers You can use named values
You cannot use bitwise operators (AND, OR, NOT, XOR).You can use + in place of OR, but that’s about it.
![Page 54: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/54.jpg)
System.EnumEnables managing enumerations at runtime.
![Page 55: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/55.jpg)
MANAGING TYPE INFORMATION AT RUNTIMESystem.TypeGETDOTNETTYPECANLOADTYPE
![Page 56: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/56.jpg)
System.Diagnostics.EventLogProvides interaction with Windows event logs.
![Page 57: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/57.jpg)
PART FIVEHandling data• Arrays• Collections• Streams
![Page 58: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/58.jpg)
ARRAYS AND COLLECTIONSArrays:• Contain a fixed number of values of the same data type• Roughly correspond to C/AL arrays (variables with Dimensions
property)
Collections:• Contain an arbitrary, flexible number of values of the same data
type• No equivalent in C/AL
Both arrays and collections are extensively used in .NET
![Page 59: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/59.jpg)
System.ArrayProvides methods for creating, manipulating, searching, and sorting
arrays.
Serves as the base class for all arrays in the common language runtime.
![Page 60: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/60.jpg)
ENUMERATORSEnable iterating through arrays and collections.C# uses the foreach keyword to manage the iteration.
Two interfaces are in charge of the enumerator-based iteration:• IEnumerable<T>• IEnumerator<T>
IEnumerable<T>• Exposes the enumerator
IEnumerator<T>• Allows iteration through enumerable object• Current• MoveNext
![Page 61: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/61.jpg)
System.Collections.SortedListRepresents a list of key/value pairs that are sorted.
![Page 62: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/62.jpg)
System.Collections.HashTableRepresents a list of key/value pairs that are stored by using a hash
table.
![Page 63: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/63.jpg)
System.Collections.Generic.List<T>Represents a strongly typed list of objects that can be accessed by
index.
Provides methods to search, sort, and manipulate lists.
![Page 64: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/64.jpg)
GENERICSAllow a single design-time declaration that compiles to multiple run-time types.
List<T> can compile to List<int>, List<string>, or List<MyDesiredClass>
Supported on:• Classes and interfaces• Methods• Properties• Structures• Fields
In C/AL, all generics are of type System.Object
![Page 65: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/65.jpg)
System.Collections.Generic.Dictionary<TKey,TValue>Represents a strongly typed collection of keys and values.
Provides fast methods to look up content.
![Page 66: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/66.jpg)
System.TimeSpanContains a lot of functionality for managing timespans down to a resolution of 100 nanoseconds.
![Page 67: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/67.jpg)
MAPPING .NET TYPES TO C/ALSome types map fully:• String• DateTime• InStream and OutStream
Many data types map uni-directionally:• Most simple data types (Boolean, Decimal, Integer, etc.)• Some complex data types (Duration)
You cannot use uni-directionally mapped .NET data types in C/AL directly.
![Page 68: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/68.jpg)
REFLECTIONCapability of .NET to gain insight into itself.
Enables managing objects and calling their functionality at runtime without knowing much about the type at design time:• Discovering information about types• Loading assemblies• Instantiating objects• Executing methods• Getting and setting properties• And many more
![Page 69: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/69.jpg)
System.IO.StreamA class that provides a generic view of a sequence of bytes.
Typical descendants:• System.IO.MemoryStream• System.IO.FileStream
Fully mutually interchangeable with both InStream and OutStream C/AL types.
Limitation:• CREATEOUTSTREAM and CREATEINSTREAM cannot be called on
System.IO.Stream
![Page 70: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/70.jpg)
System.Net.WebClientProvides common methods for sending data to and receiving data from a resource identified by a URI.
![Page 71: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/71.jpg)
PART SIXDeveloping Custom Assemblies
![Page 72: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/72.jpg)
USING VISUAL STUDIOCreating an assemblyQuick overview of C# project structureAdding classes
![Page 73: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/73.jpg)
DEPLOYING ASSEMBLIESClient deploymentService Tier deploymentGlobal Assembly Cache (GAC)
![Page 74: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/74.jpg)
CLIENT DEPLOYMENTRequired for development and Must be deployed in:• 2009:<Program Files (x86)>\Microsoft Dynamics NAV\6.0\Classic
• 2013<Program Files (x86)>\Microsoft Dynamics NAV\6.0\RoleTailored Client<Program Files (x86)>\Microsoft Dynamics NAV\7.x\RoleTailored Client
Best practice:• Deploy in separate Add-ins subfolder
Assembly is loaded on first design access to the C/SIDE object which uses it
Client must be restarted to refresh the loaded assembly
![Page 75: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/75.jpg)
SERVICE TIER DEPLOYMENTPer instance of NSTMust be deployed in:<Program Files>\Microsoft Dynamics NAV\x.y\<Service>
Best practice:• Deploy in separate Add-ins subfolder
Deployed assembly is loaded on first callNST must be restarted to refresh the assembly
![Page 76: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/76.jpg)
GLOBAL ASSEMBLY CACHE (GAC)Central repository of known .NET assembliesMachine-wideOnce registered in GAC, assembly is accessible from anywhere
in .NETAllows side-by-side execution of different code versionsRequirements:VersioningStrong naming with a public keyDeployment to GAC
![Page 77: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/77.jpg)
GLOBAL ASSEMBLY CACHE AND C/SIDEC/SIDE is aware of the GACObjects deployed to GAC are not required to be deployed to Add-ins
![Page 78: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/78.jpg)
SIMPLIFYING DEPLOYMENTAlways strongly sign assembliesUse Post Build eventsAlways deploy to GAC
![Page 79: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/79.jpg)
PART SEVENDeveloping Client Add-ins
![Page 80: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/80.jpg)
DEVELOPING ADD-IN CONTROLSCreating add-in controlsDeploying add-in controlsConsuming add-in controls
![Page 81: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/81.jpg)
![Page 82: Microsoft .NET Interoperability for Beginners](https://reader036.vdocuments.site/reader036/viewer/2022081502/56815fcd550346895dcecadd/html5/thumbnails/82.jpg)