Archive for June, 2009
I’m on vacation this week. I’ll be back to posting on June 23, 2009.
I recently had an email conversation with a former colleague. He works at an organization that uses some pretty cutting edge technology. My feeling is that the organization firmly understands the value of moving to the latest and greatest is fraught with peril but rewards the early pioneers if these moves happen appropriately. In particular, they are already evaluating Oslo. I’m a big fan of proactive thinking. I have long heard rumors that the Chicago market is too backward or old fashioned, and I just don’t see that. Instead, I hear that a Chicago business is actively hiring and is using the latest and greatest technology to make their business more competitive.
We also have a very active Ruby and Python community which, from what I can tell, is growing every month. I think that the city has already turned itself into a tech hub. We just need that first billion dollar company and the world will know too. I know this will take 7-10 years for the seeds to start bearing fruit, but the process is in motion.
I love this!
This is day #3 of my journey through the .NET 4.0 assemblies. I’m planning to split up large assemblies over several days so that I give bigger assemblies proper treatment. Today, that won’t be happening! By the way, this is actually turning out to be pretty neat. .NET ships with a lot of interesting pieces, and the assemblies that sort early in the alphabet (because they don’t start with System) are pretty interesting glimpses into how .NET does things.
Today, we look at IEExecRemote. This assembly contains a single type:
IEExecRemote, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
In GAC: True
Number of types: 1
Number of namespaces: 1
So, what does this IEExecuteRemote do? Reading the docs, we see that this is another class that “supports the .NET Framework infrastructure and is not intended to be used directly from your code.” So what? What does it do? It runs a managed application over the Internet. OK, that’s kind of generic and not very helpful. What is really going on? When you start a .NET application via a URL, Windows fires up an application called IEExec.exe. This KB article describes the process. This part of the discussion is pertinent:
The IEExec.exe application is an undocumented Microsoft .NET Framework application that is included with the .NET Framework. You can use the IEExec.exe application as a host to run other managed applications that you start by using a URL.
For example, when you start a smart client by using a URL, no processes run with the smart client name. Instead, each application that you start by using a URL receives its own copy of the IEExec.exe application. The IEEXEC.exe application sets up the appropriate environment for the application to run in.
Typically, the IEExec.exe application works closely with Microsoft Internet Explorer to help you start the .NET Framework applications. The IEExec.exe application hooks to Internet Explorer version 5.01 and later to listen for assemblies that are requested. During a request, the executable is downloaded to the assembly download cache. Internet Explorer spawns a process for the IEExec.exe application and then passes the raw evidence information of the executable to the IEExec.exe application. The IEExec.exe application then uses the raw evidence information to set up an environment that has constrained-security settings for the executable.
IEExecuteRemote and IEExec work together to host and run assemblies that are stored at URLs (instead of the local file system). IEExec loads the IEExecuteRemote instance in a separate AppDomain and then runs the remote assembly in that domain. The only method that IEExec excecutes on IEExecuteRemote is the ExecuteAsAssembly method.
Over the years, I’ve come to use Google for SOOOOOOO much. Over the past week, I changed my default search engine in Internet Explorer and Firefox over to Bing. From what I think I’m seeing, Bing slightly exceeds Google in effectiveness. It might be that the UI is a little fresher, the results have slightly better relevance, or just that it is something new. Regardless, after several days of really heavy use, I don’t think I’m returning to Google search anytime soon.
FWIW, I tend to type in sentence based queries as opposed to sophisticated boolean logic. Bing likes my questions better than Google does, and that let’s me get my job done faster.
From what I’m seeing, Bing is a little bit better. A little bit is enough for me to switch.
I’m on day 2 of going through assemblies in .NET 4.0. I may miss a day here and there, but I want to find out what is in all the libraries. For some of the bigger libraries, I think I’ll do a namespace breakdown over several days.
The assembly today is CustomMarshalers, and it has very few classes; 4 to be exact.
CustomMarshalers, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
In GAC: True
Number of types: 4
Number of namespaces: 1
These classes all handle special scenarios for interacting with COM. Since there are only 4 classes, I’ll cover each.
The CLR will not use this marshaler automatically. You need to know when it is needed. When P/Invoking a function or declaring a CLR wrapper for a COM object, you may have an object that only implements IDispatchEx. IDispatch was originally created for Visual Basic and allows late bound dispatch to properties. In other words, it allows for duck typing. IDispatchEx allows for an object to add and remove methods to a given object and exists to support dynamic features of Windows Script Host (languages: VBScript and JScript).In the .NET world, one adds and removes members from a type by implementing the System.Runtime.InteropServices.IExpando interface. From reading the documentation, it appears that if your underlying COM object implements IDispatchEx, you should must the infrastructure to marshal to an IExpando.
MarshalTypeRef=typeof(ExpandoToDispatchExMarhsaler))] IExpando expando);
COM allows code to enumerate a collection of VARIANT data using the IEnumVARIANT interface. A VARIANT allows one to put an integer, boolean, string, or complex object inside of a uniform binary type. In .NET, one would have a bunch of COM values that one wants to treat as System.Object. The CLR knows to use this marshaler when marshalling between a COM IEnumVARIANT and a .NET IEnumerator.
COM contains an interface named ITypeInfo. ITypeInfo is used for reading information about objects. Type browsers use ITypeInfo to figure out the characteristics and methods of objects contained in COM type libraries. A type library will be in a .tlb file or embedded in the dll/exe. Compilers use ITypeInfo to compile references to members of a type. If you export a .NET type to COM, the tools that read ITypeInfo need a way to read the information about your .NET types as ITypeInfo. Fortunately, this public type is meant to be used by the framework and not by your code. Still, it’s good to know what the class does.
This type is automatically used when bridging between an System.Collections.IEnumerable and an IDispatch where a member with a DISPID of -4 (enumerable member) is present. You will typically interact with this class when using tlbimp.exe to consume a type library from within your .NET application.
Whew-that was a lot of detail to cover. I can’t promise to do this every day, but I know that COM interop is one of my weak points. As you find issues with these descriptions, let me know. These blog entries are simply documenting my trip through the class libraries and all the reading I’m doing.
One of the questions I had at the Chicago Code Camp in my Google App Engine presentation was about permissions on deleting values from table storage. In GAE, each item in the datastore has a globally unique key-absolutely unique across all entities in your application and, I believe, unique across all objects. The question was this: if I figure out an ID of your objects, can I cause a delete from a second GAE application?
Fortunately, no. At the time of this writing, I have an object (a picture) whose ID is ahJzc2VlbHktc2lsdmVybGlnaHRyDwsSCUltYWdlRmlsZRgCDA. I tried deleting that exact ID from a different application. The delete failed. So, the delete would only work if it comes from the application in question. That’s what I hoped happened, and it does.
Thanks for the great question!
In the spirit of DNRs “Better Know a Namespace”, I’m going to go ahead and try to understand what the 140 assemblies on my machine that appear to be part of .NET 4.0 actually do. I’ll go through these as I can, just as a way to know what exists. Here is the first one:
Accessibility, Version=184.108.40.206, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
In GAC: True
Number of types: 10
Number of namespaces: 1
Value type Accessibility._RemotableHandle
Value type Accessibility.__MIDL_IWinTypes_0009
This assembly provides the interfaces and struct definitions needed to interact with the Windows Accessibility system. The assembly is a managed wrapper for the COM accessibility interface. This interface helps assistive technology products work with applications. It also provides a way to access, identify, and manipulate an application’s user interface. Wikipedia has a great article on the technology.