Uncategorized

TF400030 – [Solved] – The local data store is currently in use by another operation – TFS 2012

Posted on Updated on

Introduction

In this very short post, we are going to briefly discuss a couple of common errors encountered in TFS 2012 when using local workspaces, running multiple instances of Visual Studio 2012, and having a large codebase.

Problem Description

If you are using TFS 2012 (including TFS 2012 Express) you may encounter one of the following errors:

  • TF400017 – The workspace properties table for the local workspace [name] could not be opened.
  • TF400030 – The local data store is currently in use by another operation. Please wait and then try your operation again. If this error persists, restart the application.

Pay particular attention to the highlighted word, local. These errors generally occur when you have a local workspace.

I was able to resolve this problem on my development machine by simply making sure that my workspace location was set to Server. Though this is the standard configuration we utilize internally, for some reason I had erroneously set my new workspace and forgotten to change its location. ūüė¶

To ensure your workspace is a Server workspace, open your Team Explorer, select Source Control Explorer, then select your workspace and make sure that the location is set as shown below:

TFS 2012 - TF400030, TF400017

Once you set the workspace location to Server, the poor performance and unpredictability should disappear! Happy coding!

 

 

Enterprise Architecture – What is an Enterprise Architect and Where in the Organization Does He Belong?

Posted on Updated on

What is Enterprise Architecture?

We probably all know the textbook definition of an Enterprise Architect to be something like this: “An Enterprise Architect is responsible for aligning business objectives and IT in a strategic way…“. But what is really happening in the world of business when it comes to Enterprise Architecture? How are companies evolving and making the most effective use of their Enterprise Architecture staff? Where in the overall hierarchy of the organization does (and should) Enterprise Architecture reside? What trends are we seeing in the business world to give us any indication of the true answer? How does the EA work with the CIO and/or CTO and should that role of EA fall under either of these?

In a survey that I read a few months ago (and I cannot remember the source), the author mentioned that as of 2012, less than 5% of Enterprise Architects reported directly to a higher company executive such as the CEO or COO, and the percentages of EAs reporting to CIOs and CTOs were around 45% and 15% respectively. These are estimates of course, but the numbers are interesting.

As an Enterprise Architect myself, I have had numerous discussions with people at various levels of the organizations in which I’ve worked and for whom I was contracted, and the opinions regarding the true role of the Enterprise Architect vary greatly. Furthermore, you will find no shortage of disagreement if you google the discussion and read the opinions.

With all of this in mind, let’s discuss Enterprise Architecture and the true role of the Enterprise Architect in the organization.

What are the Qualities of a Good Enterprise Architect?

First, let’s talk about just what type of person it takes to be a successful Enterprise Architect. An Enterprise Architect should be:

  • Technically competent in multiple areas – a good EA must be technically-competent and respected. For an EA, technical competence is no trivial endeavor. He or she must be well-versed in enterprise software, both COTS and internally-developed, must be very knowledgeable of network and server infrastructure, and must be able to effectively communicate with and assist the technical folks who manage all of the company’s IT assets. Beyond that, the EA must be very knowledgeable of not just the company, but the industry (or industries) in which the company competes. The EA must recognize the environmental factors that affect both the overall strategy and the day-to-day operations.
  • A tested problem solver – this goes without saying but it is important¬†to mention it as a critical quality. The successful Enterprise Architect must be able to quickly understand problems that are often not well understood by many and not easily identifiable. He or she must be able to quickly recognize patterns and behaviors, both environmental and internal.
  • A great communicator –¬†He or she should be able to communicate technical concepts to non-technical people clearly, concisely, accurately, and in my opinion, eloquently. The EA should be able to effectively communicate ideas and concepts to large groups of people and to individuals. The people with whom the EA interacts on a daily basis will be of varying knowledge and skill levels, and will have unique perspectives on their specific job roles and the overall operation of the business.
  • An effective salesperson – changing the way a company does business is no small task and many times salesmanship is required to convince stakeholders. Beyond that, the EA must be able to “sell” the wholistic vision to people at all levels of the organization and inspire each person to embrace that vision.
  • Detail-oriented – as they say “the devil is in the details”. Although Enterprise Architecture is a strategic endeavor, an EA should be able to ensure success through great attention to detail. Strategy should not lack detail in any way.
  • Objective and Deliberate – the EA should be a “voice of reason” and should be able to objectively formulate and implement the Enterprise Architecture skillfully and deliberately.
  • A “Sponge” – don’t laugh ūüôā An EA should be able to absorb and assimilate an enormous amount of information and knowledge quickly and effectively. He or she should, in reality understand the mission of the business as well or better than all of the individual stakeholders.
  • A proactive facilitator – the EA is the driving force behind change.
  • Able to think at all levels – the EA must be able to formulate the “master plan” and understand the details of its implementation well enough to accurately tailor the plan to the true needs of the business as a whole AND to ensure the correct and optimal orchestration of all of the smaller “pieces” of the architecture.

If you read the items above and conclude that the Enterprise Architect is a “jack of all trades” you are correct and that is why an organization must have the right person or people for the job! A successful EA should have the mindset of both strategic management and technical implementation. In other words, he should be able to craft the strategy, communicate it to stakeholders, and be able to actually implement it or oversee its implementation both functionally and technically.

Over the past several years, as companies began to realize the importance of making the right technology decisions and cohesiveness of the overall “master plan”, the role of Enterprise Architect grew more and more important. Today this need is greater than ever. With constant acquisitions and the disparate technologies that those often introduce into a company’s existing mix of IT resources, it is imperative for companies to position themselves in such a way that IT is a distinct competitive advantage, NOT a necessary evil.

I recall many years ago being told by a CEO that he wasn’t sure exactly what the IT folks did, but he knew they occupied a large part of one wing of the building and he just knew that they did “stuff” to keep the “systems” working. Wow! This type of thinking will not yield success in today’s business climate!

What is the Outcome of Successful Enterprise Architecture?

An organization that has correctly implemented an effective Enterprise Architecture will benefit in several ways. Though this list is certainly not exhaustive, I see these as the most noteworthy.

  • Greater profitability – correctly streamlined and enhanced business processes cost less, require fewer human resources, and should directly contribute to increased profitability.
  • Reduced risk – a successful Enterprise Architecture should reduce a company’s exposure to risk through proper identification of the risks themselves, implementation of systemic measures to mitigate those risks, and overall greater process integrity which will yield greater robustness and thus reduced composite risk.
  • Greater agility – a company that is nimble and able to quickly react to market changes and external influences is better able to compete and survive. Successful Enterprise Architecture allows a company to do this by being properly positioned both technically and functionally to adapt to any type of change.
  • Better decision-making – EA affords a company the ability to more proactively undertake proper impact analysis and simply be better able to make the right decisions quickly. One of the obvious benefits of better decision-making is cost reduction. Who wouldn’t want that?

So does it really come down to having a “wholistic¬†vision” just for sake of having it? Of course not. Having such an overarching view of the organization yields tangible, quantifiable benefits that are definitely not limited to the few items I listed above.

The Big Question – Where Should Enterprise Architecture Reside in the Organization?

So finally, the obvious question! Where does the role of EA belong? Is it a subset of IT, is it a business/functional endeavor, or is it a higher-level activity?

The Enterprise Architect role is one that often raises eyebrows in companies and organizations that are not truly serious about Enterprise Architecture. The EA is generally well compensated and is thus the target of discussions by those who do not understand his or her true value. This is unfortunate, but true in many organizations. In many smaller organizations, the Enterprise Architect is one of the the highest paid members of IT.

Senior management must drive change from the top. The degree of change that is often necessary within an organization commonly brings with it varying degrees of pain. People are generally comfortable with the status quo and as we all know, resist change. It’s human nature. But to be successful, the Enterprise Architect must overcome resistance and effectively craft the master plan and implement it. This requires the unwavering support of both senior and functional management.

An Enterprise Architect who reports directly to a CIO or CTO is often seen as an IT resource and viewed by functional management as just another “IT guy” (or girl). Ultimately, the CIO or CTO makes the decisions, in collaboration with other senior managers, and thus the Enterprise Architect is viewed as a “technical advisor”. The notion of anything beyond that often creates conflict among other departments who want to feel that they have the final say. But does this really work? Does it tie the Enterprise Architect’s hands unnecessarily?

Should the Enterprise Architect report directly to a senior manager? If so, should it be the CIO or CTO – should it be the CEO or COO? Is the Enterprise Architect a member of IT or should the position be more overarching? How much control/authority should the EA be given? Is an EA merely an “advisor” or something more? Though these are good questions, the answers probably depend on the company itself.

The perception that an EA is too “powerful” can sabotage the mission of Enterprise Architecture within an organization. But at the same time, the EA must have a clear sense of vision and drive to propel both him and the organization forward. So what is the acceptable¬†balance?

Discussion

I welcome discussion on this post! Please feel free to give me your thoughts and be as honest as possible. I know that this is a great source of debate in many organizations and although the business climate is changing, I am curious how the role of Enterprise Architect will evolve with it.

 

Serialization with C# and .NET

Posted on Updated on

What is Serialization?

In the world of software development, serialization is the process of converting an object into a format that allows it to either be persisted (saved) to disk or memory, or to be transmitted across a network or over HTTP or TCP.

An object that has been serialized can be reconstructed later which is known as deserialization. I like to think of deserialization as the process by which we re-inflate the object back into its original state. If you think of an XML web service as an example, an application can be written using standard .NET objects, serialized as XML, passed around via HTTP or TCP, then deserialized (re-inflated) by the receiving application and used further.

In this article, we are going to take a quick look at three forms of .NET serialization and talk briefly about each. The following three articles will address XML serialization, binary serialization, and SOAP serialization and provide walkthroughs that give you an overview of how to implement each.

Serialization in .NET

The .NET Framework provides a few serialization mechanisms. Let’s discuss the three most well-known:

  • XML Serialization – serializes the public fields and properties of an object into an XML stream. XML serialization does not record or preserve information about the object’s original type or namespace. The .NET Framework provides a class called the XmlSerializer. This class provides methods with which we can serialize an deserialize objects.
  • Binary Serialization – serializes an object or an entire hierarchy of objects into a binary format. Binary serialization is a very efficient means of serializing .NET objects. The BinaryFormatter class offers numerous methods allow us to serialize and deserialize objects.
  • SOAP Serialization – serializes an object into XML, but also serializes private members. SOAP serialization does not support serialization of generic collections, but the SoapFormatter saves assembly and type information along with the data itself. SOAP serialization is ideal for communications between heterogeneous applications, or applications that are written using different architectures, languages, platforms, etc.

The decision as to which type to use is dictated by the needs of the application. For example, XML and SOAP serialization produce XML output which is usable across multiple platforms. Binary serialization in .NET should only be used in situations where the objects to be serialized and deserialized reside in namespaces that are usable and referenced by each application. If there is only one application in the discussion, then binary serialization will provide a speedy, compact form of serialization that will be quite suitable. So it comes down to considering performance, storage type and location, and extensibility.

See the table below for a high-level comparison of these three types of .NET serialization.

Comparison of XML Serialization, SOAP Serialization, and Binary Serialization
Comparison of XML Serialization, SOAP Serialization, and Binary Serialization

To use serialization in .NET, you essentially only need two things:

  1. A stream to hold or receive the serialized output
  2. A formatter (XmlSerializer, SoapFormatter, or BinaryFormatter) to fill the stream with output

As we mentioned earlier, XML Serialization utilizes the XmlSerializer class, binary serialization is provided via the BinaryFormatter, and SOAP serialization is handled by the SoapFormatter – .NET provides very rich support for serialization.

.NET Serialization Walkthroughs

The following posts will dive into the specifics of serialization with C# and .NET. Use the links below to select the appropriate post.

XML Serialization in C# and .NET

Binary Serialization in C# and .NET

SOAP Serialization in C# and .NET

System.Reflection – Working with the Assembly Class

Posted on Updated on

The objects within the System.Reflection namespace of the .NET Framework provide us a means to get assembly and type information at runtime. Reflection is useful in situations where you need to introspect assemblies and their types, either to gain information or to make use of their functionality dynamically without knowing its specifics in advance. Sounds pretty cool, right? Well it is!

This article will walk you through the basics of Reflection and the Assembly class and will be followed by additional articles that dive much more deeply into the objects within the System.Reflection namespace.

The System.Reflection.Assembly Class

The Assembly class is the primary class within the System.Reflection namespace. This will be our starting point as we take a look at Reflection.

First, we will create a simple Visual Studio solution that we will call ‘ReflectionWalkthroughSolution’.

In this solution, we will add a C# Class Library project which we will call ‘MyClassLibrary’.

Next, we will add a Console Application which we will call ‘MyConsoleApplication’. These names are nonsensical, but this solution is merely for demonstration purposes :).

So, after doing these things, our Solution Explorer should look like this:

.NET Reflection - Solution Explorer Getting Started

MyConsoleApplication is bolded because I have set it as the startup project. This will allow us to hit F5 to debug the app and be able to use the console application as our entry point.

Next, expand MyConsoleApplication and Add a Reference to the MyClassLibrary project. Once this is done we are ready to start writing a little code.

Assembly.GetExecutingAssembly() Method

The first thing we will look at is how to get a reference to the assembly that is currently executing. To do this we will add some simple code in the Main() method of our console application as shown below. After writing this code, place a breakpoint on the line, then hover the thisAssembly object and take a look at the properties of the assembly and their values.

static void Main(string[] args)
{
    //get the currently executing assembly
    Assembly thisAssembly = Assembly.GetExecutingAssembly();

}

With the code running, when the breakpoint is hit, we can right-click and Add a Watch to the thisAssembly object. When we hit F10 to step over the line, the Watch window is populated with information pertaining to the ‘thisAssembly’ object. See the illustration below.

Hint: Click the image to view it full-size.

.NET Reflection - Assembly.GetExecutingAssembly() Watch Window
Properties of the ‘thisAssembly’ Assembly object

 

Let’s discuss some of the properties that are shown in the Watch window above.

The CodeBase property returns the full path at which the assembly resides. In other words, the execution location for the assembly, including the name of the assembly.dll file itself.

The CustomAttributes property is an IEnumerable<CustomAttributeData> type that displays all of the custom attributes that exist at the assembly level. If you take a look you will see that many of these come directly from the AssemblyInfo.cs file that is found under the Properties folder of the project.

Assembly.CustomAttributes Illustration
The Assembly.CustomAttributes property expanded.

We will dive into custom attributes in a later post. Attributes can be applied to assemblies, classes, properties, methods, and more and through Reflection can be retrieved and read using the appropriate objects. These attributes exist at the assembly level. For now, just be aware that these attributes can be retrieved in this way.

The DefinedTypes property is an IEnumerable<TypeInfo> type that displays all of the types (classes) defined within the assembly. In our simple little console application we only have one defined type. See below.

The Assembly.DefinedTypes property expanded
The Assembly.DefinedTypes property expanded

Looking ahead to later posts, once you have a reference to an Assembly, knowing the types defined in the assembly allow you to dive into the assembly and then into each type as needed.

The FullName property is a string value that displays the full name of the assembly. This is important when discussing a topic such as strong naming.

The Assembly.FullName property
The Assembly.FullName property

There are other properties of the Assembly object that are noteworthy for this introduction. They are the GlobalAssemblyCache property which tells you whether or not the assembly is GAC’ed, the ImageRuntimeVersion which tells you the full version of the .NET Framework against which the assembly is compiled, and the MainfestModule which gives specific information about the assembly itself.

Getting Assemblies loaded in the Current AppDomain (AppDomain.Current.GetAssemblies() Method)

Now that we’ve taken a quick look at the properties of an Assembly and how to get a reference to the currently executing assembly, let’s branch out a little and retrieve all of the assemblies referenced and loaded into the current AppDomain. An AppDomain is an isolated environment in which an application executes. The AppDomain class belongs to the System namespace. To retrieve the AppDomain for the currently executing application, we will the AppDomain.Current property.

If we return to the Main() method of the Program class of our little console application and remove the code we wrote originally and replace it with this code:

static void Main(string[] args)
{
    Assembly thisAssembly = Assembly.GetExecutingAssembly();

    //Get assemblies loaded in the current AppDomain
    Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();

    //create a StringBuilder to hold assembly information
    StringBuilder sb = new StringBuilder();

    //iterate through the array and write info for each assembly
    foreach (Assembly assembly in assemblies)
    {
        //let's create some rudimentary formatted output to show property values
        //for each assembly
        sb.AppendLine("================================================================");
        sb.AppendLine(String.Format("Assembly: {0}", assembly.FullName));
        sb.AppendLine("================================================================");

        sb.AppendLine(String.Format("CodeBase: {0}", assembly.CodeBase));
        sb.AppendLine(String.Format("Location: {0}", assembly.Location));
        sb.AppendLine(String.Format("Number of Types: {0}", assembly.DefinedTypes.Count().ToString()));
        sb.AppendLine(String.Format("Number of Custom Attributes:  {0}", assembly.CustomAttributes.Count().ToString()));
        sb.AppendLine(String.Format(".NET Runtime Version: {0}", assembly.ImageRuntimeVersion));

        //you can add more stuff here to see more properties...
    }

    string output = sb.ToString();
}

When we view the formatted output from our StringBuilder, it should look something like this:

================================================================
Assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
================================================================
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
Location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll
Number of Types: 3029
Number of Custom Attributes:  36
.NET Runtime Version: v4.0.30319
================================================================
Assembly: Microsoft.VisualStudio.HostingProcess.Utilities, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
================================================================
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.HostingProcess.Utilities/11.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.HostingProcess.Utilities.dll
Location: C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll
Number of Types: 12
Number of Custom Attributes:  17
.NET Runtime Version: v2.0.50727
================================================================
Assembly: System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
================================================================
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
Location: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll
Number of Types: 2273
Number of Custom Attributes:  27
.NET Runtime Version: v4.0.30319
================================================================
Assembly: System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
================================================================
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
Location: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll
Number of Types: 303
Number of Custom Attributes:  25
.NET Runtime Version: v4.0.30319
================================================================
Assembly: System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
================================================================
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
Location: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll
Number of Types: 2278
Number of Custom Attributes:  29
.NET Runtime Version: v4.0.30319
================================================================
Assembly: Microsoft.VisualStudio.HostingProcess.Utilities.Sync, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
================================================================
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.HostingProcess.Utilities.Sync/11.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll
Location: C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll
Number of Types: 5
Number of Custom Attributes:  18
.NET Runtime Version: v2.0.50727
================================================================
Assembly: Microsoft.VisualStudio.Debugger.Runtime, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
================================================================
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Debugger.Runtime/11.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Debugger.Runtime.dll
Location: C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll
Number of Types: 10
Number of Custom Attributes:  17
.NET Runtime Version: v2.0.50727
================================================================
Assembly: vshost32, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
================================================================
CodeBase: file:///C:/Temp/ReflectionWalkthroughSolution/MyConsoleApplication/bin/Debug/MyConsoleApplication.vshost.exe
Location: C:\Temp\ReflectionWalkthroughSolution\MyConsoleApplication\bin\Debug\MyConsoleApplication.vshost.exe
Number of Types: 1
Number of Custom Attributes:  19
.NET Runtime Version: v4.0.30319
================================================================
Assembly: System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
================================================================
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
Location: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll
Number of Types: 929
Number of Custom Attributes:  25
.NET Runtime Version: v4.0.30319
================================================================
Assembly: System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
================================================================
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
Location: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll
Number of Types: 86
Number of Custom Attributes:  22
.NET Runtime Version: v4.0.30319
================================================================
Assembly: System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
================================================================
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.DataSetExtensions/v4.0_4.0.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll
Location: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll
Number of Types: 25
Number of Custom Attributes:  24
.NET Runtime Version: v4.0.30319
================================================================
Assembly: Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
================================================================
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.CSharp/v4.0_4.0.0.0__b03f5f7f11d50a3a/Microsoft.CSharp.dll
Location: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll
Number of Types: 316
Number of Custom Attributes:  23
.NET Runtime Version: v4.0.30319
================================================================
Assembly: System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
================================================================
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
Location: C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll
Number of Types: 1049
Number of Custom Attributes:  21
.NET Runtime Version: v4.0.30319
================================================================
Assembly: System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
================================================================
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
Location: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll
Number of Types: 1229
Number of Custom Attributes:  25
.NET Runtime Version: v4.0.30319
================================================================
Assembly: MyConsoleApplication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
================================================================
CodeBase: file:///C:/Temp/ReflectionWalkthroughSolution/MyConsoleApplication/bin/Debug/MyConsoleApplication.EXE
Location: C:\Temp\ReflectionWalkthroughSolution\MyConsoleApplication\bin\Debug\MyConsoleApplication.exe
Number of Types: 1
Number of Custom Attributes:  14
.NET Runtime Version: v4.0.30319

Pretty simple, right? Now let’s dig into the Assembly a little deeper.

Getting Types within an Assembly (Assembly.GetTypes() Method)

Every Assembly can contain one of more Types. We can retrieve all of these types via the Assembly.GetTypes() method. To try this out, we replace the code in our console application’s Program class’s Main() method with this code:

static void Main(string[] args)
{
    Assembly thisAssembly = Assembly.GetExecutingAssembly();

    //get all of the Types defined in this Assembly
    Type[] types = thisAssembly.GetTypes();

    //robust code always checks for null FIRST
    if (types != null && types.Length > 0)
    {
        //we'll create a StringBuilder for our formatted output
        StringBuilder sb = new StringBuilder();

        //iterate through the Type[] array
        foreach (Type type in types)
        {
            sb.AppendLine("===============================================================");
            sb.AppendLine(String.Format("Type Name: {0}", type.Name));
            sb.AppendLine("===============================================================");

            sb.AppendLine(String.Format("Type FullName: {0}", type.FullName));
            sb.AppendLine(String.Format("Namespace: {0}", type.Namespace));

            sb.AppendLine(String.Format("Is it a Class?: {0}", type.IsClass.ToString()));
            sb.AppendLine(String.Format("Is it an Interface?: {0}", type.IsInterface.ToString()));
            sb.AppendLine(String.Format("Is it Generic?: {0}", type.IsGenericType.ToString()));
            sb.AppendLine(String.Format("Is it Public?: {0}", type.IsPublic.ToString()));
            sb.AppendLine(String.Format("Is it Sealed?: {0}", type.IsSealed.ToString()));

            sb.AppendLine(String.Format("Qualified Name: {0}", type.AssemblyQualifiedName));

            if (type.BaseType != null && !String.IsNullOrEmpty(type.BaseType.Name))
            {
                sb.AppendLine(String.Format("Base Type: {0}", type.BaseType.Name));
            }

            //there are many, many more properties that an be shown...
        }

        string output = sb.ToString();
    }
}

In our console application, there is only one type, the Program class. When we execute the code above we see information for that single type.

===============================================================
Type Name: Program
===============================================================
Type FullName: MyConsoleApplication.Program
Namespace: MyConsoleApplication
Is it a Class?: True
Is it an Interface?: False
Is it Generic?: False
Is it Public?: False
Is it Sealed?: False
Qualified Name: MyConsoleApplication.Program, MyConsoleApplication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Base Type: Object

Now that we’ve moved down a level and looked at Types within an assembly, let’s move down one more level.

The next post discusses the System.Reflection.Type class and its properties and methods.

8004E00F – COM+ was unable to talk to Microsoft Distributed Transaction Coordinator

Posted on Updated on

Problem Overview

When you open the Windows Component Services Configuration Console (dcomcnfg), you see a red, downward-pointing arrow on the My Computer icon under Component Services as shown below.

MSDTC 8004E00F - COM+ was unable to talk to the Microsoft Distributed Transaction Coordinator

This error is commonly caused by the MSDTC service being set to run under the local system account instead of NT Authority\NetworkService.

If you check the MSDTC service and discover that this is indeed the problem, follow these steps to change the identity:

  1. Open the Registry Editor (regedit.exe).
  2. Find the following registry key: HKEY_LOCAL_MACHINE\Software\Microsoft\MSDTC
  3. Right-click TurnOffRpcSecurity, then select Modify. Add a value of 1.
  4. Open the Services Console and stop the MSDTC service.
  5. Right-click the service and select Properties on the popup menu.
  6. When the Properties dialog opens, click the Log On tab and change the identity to NT Authority\NetworkService (the password is blank).
  7. Click Apply then click OK.
  8. Return to the Services management console and restart the MSDTC service.

If the problem persists, check the Application Log within the Event Viewer and look for errors (red icons). The Event Viewer is a great resource for finding out what is really going on.

One possible solution is to stop the service, uninstall and then reinstall MSDTC. To do this, follow these steps:

  1. Stop the MSDTC service.
  2. Open a command prompt (cmd).
  3. Type “msdtc -uninstall”.
  4. Type “msdtc -install”
  5. Close the command prompt.