MICROSOFT.NET INTEROPERABILITY BLACK BELT – TIPS & TRICKS Vjekoslav Babic (Fortempo)

Preview:

Citation preview

MICROSOFT .NET INTEROPERABILITY BLACK BELT –

TIPS & TRICKS Vjekoslav Babic

(Fortempo)

Vjekoslav Babićconsultant, trainer, blogger, author

Blog: vjeko.comE-mail: vjeko@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

Take .NET Interoperability…… slice it to ribbons…… and then glue it all back together

AGENDA

WHAT’S WRONG WITH .NET INTEROPERABILITY?

Part 1

Strong Type

IEnumerable<T>

foreach

for (int i = 0; i < foos.Count(); i++){

Foo f = foos.ElementAt(i);// Do something

foreach (Foo f in foos)

{

// Do something

}

for (int i = 0; i < foos.Count(); i++){

Foo f = foos.ElementAt(i);// Do something

foreach (Foo f in foos)

{

// Do something

}

DON’T DO THIS

FOR i := 0 TO Foos.Count - 1 DO BEGIN Foo := Foos.Item(i);END;

DO THIS INSTEAD

Enumerator := Foos.GetEnumerator;WHILE Enumerator.MoveNext DO BEGIN Foo := Enumerator.Current;END;

Demo 1

Simple List

System.Object

Demo 2

Not That Simple List

Demo 3

Very Rude Codeunit

Demo 4

A Nice Idea That Fails

Reflection

System.Type

System.Activator

Demo 5

System.Activator

Demo 6

Strongly-Typed Generics

Demo 7

A Nice Idea That Works

Part 2

Error Handling

Demo 8

File.Delete

try..catch

Demo 9

Try..Catch

Part 3

Dependencies

Demo 10

Tight Coupling

PRS.NET

Demo 11

Facade

But there is an even better way.

Inversion of Control Pattern

Demo 12

Inversion of Control

Quick Tip

Simple GAC Deployment

Part 4

Auto-Deployment

Demo 13

Client/Server

Demo 14

Auto-Deployment