Posts tagged ‘Visual Studio’

Visual Studio: How to Resolve TestWindowPackage.Initialize Failure

I began to receive the error message box in Visual Studio after a restart from an install of an unrelated to test Visual Studio plugin (which I have used in the past):

The ‘TestWindowPackage’ package did not load correctly.  … examining the file … AppData\Roaming\Microsoft\VisualStudio\12.0\ActivityLog.xml

Looking at that log showed these errors:

TestWindowPackage.Initialize failed with exception … System.InvalidOperationException:

Loading MEF components failed with the following exception:
The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

No exports were found that match the constraint:
    ContractName    Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer
    RequiredTypeIdentity    Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer

 

To resolve the issue I did step 1 and 2 but am showing step 3 in case it helps.

  1. Close all instances of Visual Studio.
  2. Delete all files in `AppData__abENT__#92;Local__abENT__#92;Microsoft__abENT__#92;VisualStudio__abENT__#92;12__abENT__#46;0__abENT__#92;ComponentModelCache` Note that directory is not found in `Roaming` as the activity log file, but in `Local`.
  3. Restart, if that doesn’t work then start over with step 4.
  4. From a Visual Studio Command Line do this operation: `devenv __abENT__#8260;setup __abENT__#8260;ResetSkipPkgs` See (/Setup (devenv.exe)) for more information.
Share

Visual Studio Fix: Intellisense Not Popping Up or Not Working

(Update 4/27/2015 Added Asp.net intellisense failure)

I was running the latest version of Visual Studio 2013 and ran into the intellisense not automatically popping up when I would type a period. Now I could hit CTRL-J (list members) and it would pop up the list which showed me that it worked and was not dead per se, but I still did not have it automatically popup after typing a period. I was also running Visual Studio 2012 on the same box and it did not have the same problem; intellisense popped the list up on the period. I thought, “This ends here” and researched it. Here is what made it auto pop for me:

  1. In quick launch type “Statement Completion” and choose the first one  “Text Editor -> All Languages -> General” to be taken to the options page for all languages.
  2. On the general options page in the “Statement Completion” section override whatever is in the boxes “Auto list members” and “Parameter Information” and makes those checked. Such as shown here:

Statement Completion

 

That brought back the auto popup for me in VS2013 and should for you as well.  This fix should work with any version of Visual Studio 2008, 2010, 2012 and 2013.

Still having problems? Then see Using Intellisense on MSDN for other troubleshooting suggestions.


ASP.Net

It has been reported that ASP.Net users are experiencing a different kind of intellisense failure. If it is web related intellisense look into installing Visual Studio Web tools.  See

Announcing release of ASP.NET and Web Tools 2013.1 for Visual Studio 2012

Share

Visual Studio: Downloaded Assembly Gives "ValidateXaml" task failed unexpectedly Error or FileLoadException

This is a How To Fix when you have downloaded a foreign (to your computer) assembly which can occur when dealing with Silverlight assemblies but it applies to all assemblies downloaded. Here is more of the errors:

error MSB4018: The "ValidateXaml" task failed unexpectedly.

error MSB4018: System.IO.FileLoadException: Could not load file or assembly ‘… \ImageSequence.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

The situation is that the OS has identified that the assembly was not made on the computer and has been blocked. This is usually the case with downloaded assemblies and is a security feature.

Steps To Resolve

  1. In Visual Studio in the Solution Explorer Window right click on the project which contains the dll and select Open Folder in Windows Explorer.
  2. In Windows Explorer find the dll in question and right click and select Properties.
  3. Select Unblock and select OK. (As shown below)

    BlockedFile

  4. Rebuild.

Once you see the properties and this text its more self explanatory than the Visual Studio error.

This file came from another computer and might be blocked to help protect this computer.

Why?

Remember that .Net is an Xcopy install. Meaning that any .Net application can be installed by simply copying over the assemblies. The OS recognizes the assemblies and categorizes them for running. When one copies code over and tries to manipulate it in Visual Studio the OS blocks for safety reasons and it subsequently fails during a Visual Studio build.

Share

Test Custom Actions During Install Deployment

In researching a MSDN forum question I needed to see the current user’s credentials during a custom action during an Setup and Deployment project created from a Visual Studio 2005 project. My goal was to show a message box during install that would display the user’s credentials and domain.

What makes this project unique is that we will be using MessageBox, from the System.Windows.Forms namespace. This article shows you how to utilize a MessageBox in a custom action. Here are the steps

  1. Using this article as a basis Walkthrough: Creating a Custom Action we will do everything it does except do a Commit action.
  2. Add a reference to the dll project to include the System.Windows.Form namespace which will not be included by default.
  3. In the custom installer class created in the helper dll override the Install Method such as:
    [RunInstaller(true)]
    public partial class ShowInfo : Installer
    {
        public ShowInfo()
        {
            InitializeComponent();
        }
    
    
        // Add and override this method to show the current user and the domain.
        public override void Install(System.Collections.IDictionary stateSaver)
        {
    
    
            WindowsIdentity wi = WindowsIdentity.GetCurrent();
    
    
            MessageBox.Show(string.Format("Name :{0}{1}System {2}", wi.Name, Environment.NewLine, Environment.UserDomainName));
    
    
            base.Install(stateSaver);
        }
    }
    Then add these usings to the top of the file:
    using System.Windows.Forms;
    using System.Security.Principal;
  4. Then in the install project unlike the Walkthrough, add the custom dll to the Custom Actions operation in the Install Node.
  5. Build and install. Note the message box may come up behind other windows during install, so you may have to look.

This is a quick way to show information during an install for debug purposes or user info. Note it is a modal dialog and will stop processing until the user closes the message box window.

Share

Alignment Macro for Visual Studio 2003/2005

Macro

In all of my editors I have used, I have always written a macro to align equal signs in code. For me code has to be aesthetically pleasing and this process helps that by making the equal signs as well as other items line up.

The macro purpose is to align target text on the current and following lines looking for the text until it can no longer find it. At that point it stops, calculates which point is the farthest out and then moves all the other lines to that location.

There are actually two macros, one to only align just = signs and the other which asks for target text to align.

Before
Equal Before
Any Before
Any Ask
There are actually two macros in this package for extra flexibility. Besides just aligning equal signs…the other macro will align anything. To do that it will prompt the user as to what to align. That can be either one character or a word or phrase.
Any Ask
After
Equal After Any After
Notes

  • Macro starts at current text editing position.
  • Tabs in document may interfer with calculation. If that is the case remove tabs or make sure they are evenly placed for all lines in question.
  • There are two public macros in this package (Align and AlignIt). Its best to assign them to similar keystrokes like Alt-F10 and Ctrl-Shift-F10.
  • This is a non-destructive macro, it will not delete lines or move items to other lines.
  • Once it cannot find the target text it will stop.
  • Download is in the form of a zip file which contains the vb code and a readme. There should not be viruses…but it is always good to check.

Download

Align VB Macro for VS 2003/05 in Zip

Share