Welcome to MSDN Blogs Sign in | Join | Help

Configuring Visual Studio to Debug .NET Framework Source Code

Earlier I posted a link to the announcement on ScottGu's blog about the framework source availiability for debugging. I wanted to follow-up with my experience using the reference source.

I found the installation instructions on "Configuring Visual Studio to Debug .NET Framework Source Code" on Shawn Burke's blog. I assume there is some official MS site for these instructions but I didn't look very hard. If anyone knows the link please let us know. The installation worked great on my Vista laptop with VS 2008. I did notice that much of the Orcas (i.e., 3.5) BCL has yet to be published. Unfortunately this includes the Managed AddIn Framework (MAF, System.AddIn*) source. I am following up on the Orcas release and I will let you know when it gets published. Enjoy! JackG

Extensibility; Clients and Services calling each other

In this post I will be showing sample code (also found on our CodePlex site) as well as an execution sequence diagram. I will show sample code addressing some frequently asked questions; A Host calling AddIn services, AddIns calling (aka. Automation) a Host, AddIns calling AddIns, Managing AddIns (utilizing LINQ), which assemblies are loaded (Per AD and utilizing direct connect), etc…

1.     A sample Host application that supports calls from the AddIn (aka., Automation) to the Host.

a.     In the past we have shown the Host calling into the AddIn (Sample code), which happens naturally via System.AddIn activation of the AddIn. In other words, the activation of an AddIn allows the Host to call through to the AddIn.

b.     We have shown the *pipeline* allowing the AddIn to automate the Host (Sample code).

                                          i.    As a result of several requests, this is a sample solution showing an end-to-end solution that includes the Host, Pipeline, and AddIn.

c.     In the past I have shown sample code using pure remoting (i.e., No System.AddIn*) for two-way remoting / bi-directional calls (i.e., Host Automation) but now I will show the equivalent using MAF (i.e., Managed AddIn Framework).

Extensibility; Clients and Services calling each other

2.     I am including a Sequence diagram that ties to the Sample App source code showing;

a.     AddIn Discovery, Qualification, Activation, AddIn calls into the Host (aka., Host Automation), AddIns requesting and calling other AddIn services (i.e., Client/Services).

 Sequence diagram of Clients and Services calling each other

3.     Isolation - AppDomains and AddIns/Assemblies activated within each, understanding Activation optimization (i.e., Direct Connect forgoing Isolation), and unloadability (i.e., which assemblies/Types are loaded/unloadable).

4.     Using LINQ to help you manage AddIns.

5.     The benefits of having Adapters, whereby you have code running in the locality of an AppDomain. This is also an example aiding in understanding MarshalByRef (MBRO). 

a.     See List<string> GetASMInAppDomain(string AppDomainName) in HostHelper.cs for comments on the problem and the solution.

6.     New features we included in the latest features we added to the VS2008 3.5 release.

a.     Direct connect Optimization. We have received a few questions on this feature and as such I wanted to clarify the implementation. 

                                          i.    You must enable DirectConnect

1.     AddInToken.EnableDirectConnect = true;

                                         ii.    Our Activate method makes it easy to create an Add-in in a new AppDomain and as a result people are forgetting to pass in an existing AppDomain to the Activate method.

1.     HAV = tokens[i].Activate<IAuthProvider>(AppDomain.CurrentDomain);

                                        iii.    Although we do not instantiate the Adapters we still require them to be defined in the pipeline folders.  As some have pointed out, this may be counter-intuitive.  We took this approach in order to guide you toward the right design (i.e., support for isolation and version resilience) going forward.

                                        iv.    Your Host view of AddIn and AddIn view of Host types respectively, must be the same type (i.e., in the same assembly).

1.     In my sample code I list the assemblies in a selected AppDomain so you can see what is loaded.  In the direct connect scenario you should not see the Adapter assemblies loaded in the AppDomain. 

b.     [ActivatableAs] Attribute enables AddIn side, View Type hierarchies. 

                                          i.    I created an Abstract base class (ABC) as the Base for my views and I marked the ABC with our new attribute [ActivatableAs] which tells us which Base type is used for activating the Addin.  The sample code shows how you can use Interfaces and Abstract Base Classes as views.  This also shows some of the differences between versioning an Interface (which would require casting over time or Adapting) and an Abstract Base Class which allows a little more flexibility in versioning due to its ability to have default implementations. Note that the CLR does not support multiple inheritance so using Abstract Base Classes should be carefully considered.

c.     Custom Qualification

                                          i.    Example of an Addin advertising its demand for activation in the Hosts default AppDomain. The Key/Value pair is nothing more than metadata you may use to suite any need your imagination allows.

d.     FindAddIn

                                          i.    There are a number of scenarios where you may not have a clean directory structure for Add-in’s, or you may not have write access to the Add-in store, or you may not know the location of the Add-in until runtime (e.g., Click-Once deployed Add-in’s), etc..

e.      AddIns calling AddIns

                                          i.    I will show one Add-in utilizing other AddIns that were instantiated by the Host. The AddIn consumer (Client) requests the List of other AddIns (Services) from the Host. This enables the AddIn to consume other services without having to do its own discovery and activation.

                                         ii.    This sample also shows the benefits of Adapter creation helper methods (AuthProviderHostAdapter) and the MAF support for passing Lists of reference types (CollectionAdapters.ToIListContract<> and CollectionAdapters.ToIListContract<>).

1.     For more on Value and Reference type behavior, check out these posts by TQ

a.     Are Arrays OK in Contracts?

b.     Reference vs. Value: Types, Passing and Marshalling

7.     Multiple Add-ins in a single Assembly

a.     Although this isn’t a new feature, I am frequently asked about how assemblies and pipeline segments should be factored (more on this later) and confusion over Add-ins and Assemblies.

                                          i.    Check out the DefaultAuthProvider.cs as an example.

Microsoft announcement of Silverlight 2 (Devices/RIA/Client)

Yesterday, Microsoft announced a significant technology advancement in Rich Internet Application (RIA) platform development.

This announcement was significant on many levels from my perspective. 

  1. It solidifies (beyond SL 1) the ability to use .Net to develop richer (beyond video and media) web client applications. As you may know, I have had strong opinions on the previous Web development experience (Thin Client - Web Clients).
  2. It clearly shows our effort in meeting customer demands to provide a continuum and compatibility of development environments from Devices to Web and Rich/Smart Client applications. Check out Scott Guthrie's blog post with sample code
  3. Providing VS designer support and very rich Expression Studio support for the above. This will further empower designers to build rich client applications with WPF and rich media/RIA experiences with Silverlight.

Check out the Mix08 site for more details, including the keynote.

Some of the coolest things I saw were:

  • The Hard Rock Café demo of zooming in and out of media images and retaining resolution. WPF rocks!
  • The upcoming Olympics media experience was unbelievable. The demo of multiple channels on the screen, the ability to rewind real time events and PIP (Picture In Picture). Unbelievable. Sniff, sniff, I miss my ability to do PIP on my TV. Sad that with High Def, etc... I had to give up on one of the coolest features I once had.
  • Silverlights ability to adjust the streaming experience based on my ever changing connectivity bandwidth was to cool for school.

One other note. I watched the keynote live from my desktop and I couldn't help but wonder how the audience could sit their so quietly when so many cool things were being shown on real bits. We aren't talking vapor or demo-ware here. I haven't been directly involved in the SL development effort and granted I work at Microsoft so I likely bring some bias, and I guess I am more excitable than your average person about where we landed on the ability to develop applications in a very compatible way from devices to Web to Rich Client applications (and maybe I had some influence) but can someone tell me why the audience was not as engaged. I mean, PIP - come on people, that's cool stuff! In any event, as a developer/consumer I am thrilled, as a contributor I am proud, and as a user I don't expect I will leave my DVI flat panel dual monitors during the Olympics.

I would love to get your thoughts on where we hit or missed the mark. Enjoy!

You asked for it (AddIn pipeline generator)

After all, our job is to make your life easier.  I have received a *lot* of requests for a tool that can generate the Add-In pipeline segments.  Ever since we mistakenly left comments in our MSDN articles code about the pipeline source being machine generated, some of you noticed that we may have been working on a tool.  Soooooo, as a continuation of Microsoft's open and transparent developer experience (see this link for .Net framework source code, and this link to view/file bugs, receive early drops, etc..) we just released our pipeline generation tool source code to the community!!! 

The tool generates source code as opposed to a binary (like tlbimp) so that you may alter the generated code.  You may have specific naming conventions, or you would like to contribute to the tools functionality, so you can now do so via Codeplex.  Here is a link to our Managed Extensibility and Add-In Framework source.  We are also adding our sample code from our Add-in team Blog so that we a consolidated source (pun intended).

You can't say I didn't get you anything for Christmas.  Have a great new year!  JackG

Winforms, WPF and AppDomain isolation

We just posted a solution to consider for the F.A.Q. of how to enable isolatable WinForms applications.  Check out this link.  This solution may be considered relative to my previous post and subsequent comments.  Note that WPF startup performance costs may be mitigated by applying the [LoaderOptimization(MultiDomainHost)] attribute to the main method.  This tells the loader that the app expects to load multiple AppDomains with similar code and thus should share the assembly images (WPF NGen images) between AppDomains.

 

Visual Studio 2008 and .NET Framework 3.5 RTM

It's official.  We have released to manufacturing.

I am personaly very excited about the Add-in addtions to the BCL, but you can also find over 250 new features in this release (e.g., LINQ).  Check out the new release here.

TechEd 2007 F.A.Q.

Hola!

I just returned from TechEd 2007 held in Barcelona, Spain. Barcelona is a beautiful city with incredible new and old architecture. The people are very friendly and even I was able to navigate the clean public transportation systems.  Yes, I am one of those people that get lost easily and never stop to ask for directions. I was surprisingly given a beautiful suite overlooking the Mediterranean at the Hilton Diagonal Mar hotel right next to the convention center. I would highly recommend the hotel! Ask for a suite above the 15th floor in order to take advantage of the 15th floor amenities!

I could go on and on about Barcelona, but I wanted to provide some links answering some of the F.A.Q.'s I received.

1.    Does the Add-In model support UI extensibility via WPF? Yes, check out my Channel 9 video, as well as the sample code.

2.    What is the state of Acropolis? Answer.

3.    What about the PAG CAB (WPF and Acropolis)? Answer

4.    Does the Add-In model support *in* domain activation, Click-once, custom meta-data, simple sandboxing, WPF isolation, and AddIn to AddIn communication?  Yes, these features were added in the final Beta.  Check out the “By popular demand link”.

5.    Can you tell me more about the WPF Add-In support (e.g., XBAP)? Here is the WPF blog site link.

6.    Where do I post WPF control specific Add-In questions?  Here is a link.

7.    Do you support Out of process activation and isolation of Add-Ins?  Do you support Partial Trust Add-Ins in an external process?  Can I have some control over the process? Yes, Yes, and Yes.  Here is a link to some sample code showing how easy it is.

8.    Can you tell me more about VSTA and the differences and/or reconciliation with the CLR Add-In model?  Check out these links.

9.    What are the rules/constraints of the types that may flow over the boundary? Here is a link to the contract constraints.

10.  Where are the Add-In MSDN articles?  Here are the links.

11.  What about WinForms support?  Who do I contact about this support? What about Crossbow?  Check out these links and comments; WinForms and MAF link, Crossbow link.

12.  Can you do Async programming in MAF? Yes, check out this link.

13.  What about ill behaved Add-Ins and unhandled exceptions?  Here is a link.

14.  Do you have sample code showing Host automation and Events?  Yes, check out this link.

15.  Where do I get Add-In support?  Here is a link.

16.  Can you show me more pictures and less text?  Can you tell more about the “Pipeline”? Can you show me some sample code for version tolerance, i.e., backward compatibility that supports something stronger than the use of a standard Interface or Abstract base class implementation.  Here is a link for all the above questions.

17.  Can the Add-In model be used as a dynamic component composition model?  Yes!  In some respects it was tragic that we used such a contextual naming convention of Host and Add-In, as opposed to component, composition, or automation.  I will be posting a sample application that shows the new Beta2 features we added and you will see the basis for a component model within the sample, as well as some code answering another F.A.Q. about the management of components/Add-Ins.  Stay tuned to this same bat channel.

If I missed one of your questions please let me know.  For those that I met at the conference, thank you for your support and thoughtful questions as well as the positive feedback and strong session scores (the checks in the mail ;-)

And for those that know me, I did make it to the WPT Barcelona casino for poker. The stakes were a little high for my taste and the players were quite good, but I managed to do well. Playing with people from Israel, Spain, and Holland, to name a few, was a cultural experience I will never forget.

Gràcies, Gracias, Merci

TechEd Developers conference

TechEd is shaping up to be a huge event in part due to the fact that we will not have a PDC this year.  Jesse and I will be doing a presentation on the Add-in model, and participating in a chalk talk among other things. If you have an opportunity to attend the conference please feel free to stop by and say hello.  If you would like to sync up at the conference please contact me via my blog.

For those interested in more details on the conference check out this link.

Hope to see you there, JackG

.Net 3.5 for ISV’s, Channel 9 video

We have modified the Soapbox video by moving the WPF on BCL Add-in model demo to the start of the video and we have posted this updated video to Channel 9.  The video will also be on the Channel 9 home page for a while.

From James, “Several weeks back James Vastbinder was able to coax Jack Gudenkauf into doing an interview on .NET 3.5 targeted at ISVs.  Jack is an Architect on the Base Class Library team and tasked to work with Microsoft’s ISV Partners. 

In this interview:

·         Jack talks about the BCL team and how they work within the larger Server and Tools business unit.

·         An inside view of the new Add-In Model in 3.5, (Its Jack's baby and he's rightly proud).

·         The Process ISV should mentally walk through when moving to managed code.

Tools and utilities used by the CLR team.”

Is that Brad Pitt on www.wevegottaguy.com?

Check out http://www.wevegottaguy.com/ and see if you recognize that handsome guy representing the Small Business Specialists ;-)  The videos on the right hand side are pretty darn funny.  Pure Improve!  It was a pleasure working with these skilled actors in these skits.  Apparently my videos are coming soon, or on the cutting room floor L

SBS

Microsoft recently launched a brand awareness campaign for the Microsoft Small Business Specialist Program.  This is a U.S. wide campaign containing multiple different elements: Online videos, web banners & web buttons on small business websites, press releases, the www.WeveGottaGuy.com website, online news agencies, and more.  The campaign is called the, "We've Gotta Guy," campaign and the premise behind it is simple.  How many times have you been talking with a prospective client and been told, "We've Gotta Guy?"  It could be their brother-in-law, a friend, a colleague's nephew from college, whatever.  Whoever "the guy" is, they are betting their critical business systems on them and putting their businesses at risk.  So we are reaching out to small businesses through a variety of ways to convey the message that there is professional assistance available to them in their local areas to help with their critical business systems and they are the Microsoft Small Business Specialists.  The call to action, look for the Microsoft Small Business Specialist "badge."

Posted by JackG | 1 Comments
Filed under: ,

.Net framework source code released

Recently I was speaking to a group of ISV's and Enterprise partners and as we spoke about the continued transparency of Microsoft, I vaguely mentioned more is coming.  Well, here it is.  ScottGu's blog post goes into the details of opening up our framework source code to the developer community.

Enjoy, JackG

What’s new in the .Net Framework 3.5 (Orcas)

Visual Studio (VS) 2008 and .Net 3.5, code named “Orcas”, will be released in the near future.  This release includes a number of new features and bug fixes.  The release includes new major features such as LINQ, Cider (The VS WPF designer), “Crossbow” (WPF and WinForms interoperability), and my personal favorite, the Managed Add-in Framework, etc… 

In the past, I outlined, provided sample code, and did some presentations on what’s new in 2.0.  Given the pending Orcas release and following my 9/12/07 presentation to ~78 ISV and enterprise partners on what’s new in Orcas, I wanted to share the content I presented.  Thanks to all the attendees for your feedback.  It is always a pleasure speaking with our customers.

BCL Additions or enhancements

·         System.TimeZoneInfo

·         System.DateTimeOffset

·         System.Collections.Generic.HashSet

·         System.IO.Pipes

·         EventSchemaTraceListener

·         Event Tracing for Windows Vista (ETW)

·         System.Threading.ReaderWriterLockSlim

 

Garbage Collector (GC)

 

·         Overview

·         System.Runtime.GCSettings.LatencyMode

·         System.GC.Collect(int generation, System.GCCollectionMode mode)

CLR Security

·         Support for “Suite B” crypto algorithms on Vista

o    Elliptic Curve Diffie Hellman for key exchange (ECDiffieHellmanCng class)

o    Elliptic Curve Digital Signature Algorithm for signing (ECDsaCng class)

o    FIPS certified Advanced Encryption Standard (AES) for symmetric encryption (AesCryptoServiceProvider class)

o    FIPS certified SHA2 for cryptographic hashing (SHA256Cng or SHA256CryptoServiceProvider classes)

·         Support for the trusted publisher list for managed controls in the browser

o    Enables a simple elevation model for controls in the browser

·         New opt-in reflection security model

o    Apps can reflect on the private members of libraries at the same or lower trust level. Useful for script engine scenarios

Extensibility (aka., Add-in’s, Add-on’s, Plug-in’s, Component models, …)

·         System.AddIn*

o    For those who offer, or wish to offer, application extensibility, the CLR now offers a robust solution with a number of features including; Discovery, Activation, Isolation, Unloadability, Sandboxing, Lifetime management, and WPF support.

CLR ThreadPool

o    We invested significant development resources improving the managed implementation to be as close to native socket scaling/perf.

o    Most of the code is now in managed code, eliminating unnecessary VM transitions

 

Misc

·         MSDN Article on CLR enhancements

·         Add-In team Blog

·         BCL Team blog

Microsoft Silverlight 1.0 RTW

Today we announced the release of Silverlight 1.0.  Here is a link to a previous post on the product.

Check out the Silverlight web site for more.  At the very least check out the Halo 3 trailer - Very cool!

Posted by JackG | 0 Comments
Filed under: