Archive for the ‘Visual Studio’ Category

Posted by OmegaMan at July 11, 2010

Category: Visual Studio

Tags: , ,

I ran into this problem when working with Visual Studio 2010. I had a project which had a SQL Server Compact database file (.sdf) which according to the build was to be Copied to the output directory during builds. But the problem was that during my unit testing, this file was not being copied out to the target directory for unit testing and code coverage. Once the test was run, it would fail because the database file could not be found.


To have any ancillary file included in a test output run, one needs to add it to the test deployment.  Here are the steps

  1. In the Solution Items folder of the solution find Local.testsettings file.
  2. Double click the Local.testsettings file
  3. Select the Deployment category.
  4. Choose the file by selecting the Add File button.
  5. Path to the file.

Done and retest to verify.


Posted by OmegaMan at May 2, 2010

Category: Errors, How To, Silverlight

Tags: , ,

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 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)


  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.


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.


Posted by OmegaMan at February 24, 2010

Category: Suggestions

Tags: , ,

iStock_000002461629XSmallCall me crazy but I named my kids, I named my pets and heck, yes I even name my threads. Things which are important to me in life are worth naming; right? Thread names for me can be important in debug situations. When one uses the Performance Wizard and chooses to have a Concurrency Visualization profile report, specifically the Threads section the name of a thread is not used.

Historically and in the latest version of Visual Studio 2010 the profile reports ThreadMedo not show the thread names. Why?

Don’t get me wrong on this, Visual Studio Twenty Ten is a great product and light years ahead of all other versions! I look forward to having it share my cube and work computer for eight plus hours a day when it is finally released. But heck a man can dream can he?

Let us take a look at what inspires me to write this diminutive dissertation on a distilled user suggestion…


One can name threads, simply by, well naming it. Here is a code snippet below:

Thread T1 = new Thread(ThreadOne);

T1.Name = "Jabberwocky";


Viola our thread is named. I cannot think of another reason for naming a thread except for debug purposes. Hey did someone mention debug?


Yep while debugging the nice little Threads window as shown above displays our named thread. But yet the Profile Performance reports do not show it. Are the two groups at Microsoft not talking to each other and sharing technology. ;-)

Heck I even tried a trick to Trojan Horse a name into the profiler (Reference the Microsoft.VisualStudio.Profiler dll located in the install directory at  \Team Tools \Performance Tools\)

Thread t = new Thread(new ParameterizedThreadStart(
threadIndex =>

Console.WriteLine("Hello from thread " + (int)threadIndex);

alas to no avail. The report still only shows the type of thread and its generic ID.


I feel that named threads might give one an edge in debugging race or deadlock conditions in code. This is a great tool which frankly could be made even better by including the actual thread names, if found in the report.

Connect Suggestion

If you find this little diatribe interesting go and put your two cents into the Microsoft Connect issue which I created:

Named Threads: Missing the Obvious on Profile Reports

Thanks for your time and well; taking a second look.


Posted by OmegaMan at June 2, 2009

Category: Bug Reports, Visual Studio


In loading Visual Studio 2010 beta 1, I was very disappointed. Out of the box, the dialog menu text is fuzzy along with most dialogs. Here is V2010 and Visual Studio 2008 side by side. Notice the File menu text is fuzzy:


Notice toolbox is the biggest offender. Even the colors while editing are not as crisp. Is it just me or do my eyes fail when looking at VS2010? Someone has beat me to writing a Microsoft Connect issue on this one: Fuzzy text display in Visual Studio 2010 Beta 1.


Posted by OmegaMan at September 18, 2007

Category: Install Projects

Tags: ,

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:
    public partial class ShowInfo : Installer
        public ShowInfo()
        // 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));
    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.


Posted by OmegaMan at September 11, 2007

Category: Visual Studio

Question: I need to find the hidden files such as reference.cs which is generated for me when I create a web service in Visual Studio 2005 but is is hidden. How do I find them?

Answer: Open up the Solutions Explorer and click the Show All Files button:




Posted by OmegaMan at April 27, 2007

Category: Macros

I created this before the code snippit region came along. This macro will work with VS2003 and VS2005. Simply highlight the code you want and a dialog box will come up asking for the name. Note depending on the location the #region and #endregion will be at those positions.

Sub RegionIt()
    Dim sWhat As String
    sWhat = InputBox("Region Name")
    If (sWhat <> "") Then

      Dim selection As TextSelection = DTE.ActiveDocument.Selection()
      Dim start As EditPoint = selection.TopPoint.CreateEditPoint()
      Dim endpt As EditPoint = selection.BottomPoint.CreateEditPoint()

      DTE.UndoContext.Open("Comment Region")
          start.Insert("#region " & sWhat & Chr(13))
          endpt.Insert(Chr(13) & "#endregion")
          'If an error occured, then need to make sure that the undo 
          'context is cleaned up. Otherwise, the editor can be left 
          'in a perpetual undo context
      End Try

    End If
End Sub
  • Recent Comments

    Thanks for this simple yet delightful code....
    Hey guys I'm having the same problem as Netanel KL { “Error HRESUL...
    Soluciono el problema con el primero (First step solved it for me)....
    Thank you! I was looking for this. You save my day!...
    Thank you! This was a big help. My requirement was a little differen...
    Thanks, after a small path adjustment it worked for Visual Studio 2015...
    Good call!...
    Thank you .. this helped...
    How about when you have a long string with no space? I tried it and it...
    Thank you, I ran into this same issues with Visual Studio 2015 after i...