Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Wednesday, February 11, 2015

Visual Studio Immediate Window shortcut

To get in the immediate window in Visual studio ::
Debug --> Windows --> Immediate
Ctrl + Alt + I
Share/Bookmark

Tuesday, August 19, 2014

VS :: Peek Definition

Everyday I enjoy the Peek definition in Visual Studio 2013 !

Share/Bookmark

Friday, May 2, 2014

Global Assembly Cache Tool - Gacutil.exe

Gacutil.exe can help to view and manipulate the global assembly cache and download cache. Visual Studio installs the tool and it needs to run using the Developer Command Prompt.
gacutil [options] [assemblyName]


Share/Bookmark

Monday, April 28, 2014

How to get Assembly full name(VersionNo, Culture, PublickeyToken)

In Visual Studio, Open a project, Debug Menu-->Windows-->Immediate
Shortcut: (Alt + Ctrl + i) or (Ctrl + D, I) open the Immediate Window

?System.Reflection.Assembly.LoadFile(@"C:\Path\YourAssemblyName.dll").FullName


P.S.
If you can't see the immediate window:
I am guessing that you picked a profile that hides this window.
Try: Tools->Import and Export settings->Reset all settings, and pick general development settings.

If you encoutered with following message:
"Design time expression evaluation for class libraries requires the Visual Studio hosting process which is unavailable in this debugging configuration."
Be sure in the project "Enable the Visual Studio hosting process" is checked, enabled.
Be sure in the project "Enable the Visual Studio hosting process" is checked, enabled.

The host process which is pointed to in above message refers to a feature of the CLR, Hosting allows one to configure the CLR before it gets started. One primary use of this is configuring the primary AppDomain and setting up custom security policies. Which is exactly what the hosting process is doing. in debug mode you are running with a customized version of the CLR, one that improves the debugging experience.


Share/Bookmark

Friday, November 29, 2013

Automating package restore in Visual Studio, don’t keep NuGet Packages in source control

When developers install NuGet packages and set references to those assemblies then it would be necessary to keep them available during build. On the other side down the road maybe the NuGet packages in your projects need to be upgraded and also keeping more and more binaries in repositories will just consume more space in your local disk and in repository especially for Git or Distributed version control systems (DCVS) which include every version of every file within the repository.

The best way is to enable package restore during build, the feature added since NuGet 2.0 and improved as of NuGet 2.7.

By automating package restore in Visual Studio the build events can handle installing the missing packages which eliminate the necessity of keeping them in repository.

There are two levels which should be set, simply go for ToolsOptions and then try to choose Package Manager 1. Visual Studio is configured to 'Allow NuGet to download missing packages' 2. Visual Studio is configured to 'Automatically check for missing packages during build in Visual Studio'



It’s done, but there is other options too like [MSBuild-Integrated Package Restore] which I’ll point to that in next blog entry.

Share/Bookmark

Friday, November 22, 2013

Adding external assemblies to load with Visual Studio at startup

Needed to add user defined methods for Telerik Reporting to be able to call the methods in expression builder of report, then it was necessary that Visual Studio loads the assembly at startup to make it ready for Telerik Report designer in VS.

Looked into VS configuration file:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe.config

Found the probing tag points to PublicAssemblies & PrivateAssemblies:
<probing privatePath="PublicAssemblies;PrivateAssemblies;..."/>

The above paths allows to have access to assemblies other than GAC, in this case, I needed to drop the custom coded assembly in a path which is known for VS.

Also assemblies deployed in PublicAssemblies path appear in the Add Reference dialog box, if you don't like to make them available in the Add Reference list but be known for VS, it should be deployed in PrivateAssemblies path.

Simply found the paths as following:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies

in this special case, I added the following parts in devenv.exe.config

<configSections> ... <section name="Telerik.Reporting" type="Telerik.Reporting.Configuration.ReportingConfigurationSection , Telerik.Reporting , Version=7.2.13.1016 , Culture=neutral , PublicKeyToken=a9d7983dfcc261be" allowLocation="true" allowDefinition="Everywhere"/> </configSections>

and then added the following part in devenv.exe.config to introduce the external methods functionality to Telerik.Reporting designer.
<Telerik.Reporting> <AssemblyReferences> <add name="MyAssembly" version="1.0.0.0" /> </AssemblyReferences> </Telerik.Reporting>

Now VS loads the assembly and it gets available for Telerik.Reporting as extended methods inside designer.
Share/Bookmark

Thursday, August 29, 2013

SQL Server Data Tools - Update to open Database Project

When tried to open a SQL database project in Visual Studio 2012 Update 2, I encountered with the following error message.



My search ended up with updating SQL Server Data Tools for Visual Studio 2012 which I used this MSDN link to load and set it up, the problem solved.

Share/Bookmark

Monday, September 5, 2011

Visual Web Developer 2010 Express on NetBook

I tried to install Visual Web Developer 2010 Express on my Netbook
  • Intel Atom N550 (1.5GHz, 1MB L2 Cache)
  • 1 GB DDR3 RAM
  • 250 GB HDD
The folowing items installed and it took a few hours!
  • Microsoft .NET Framework 4
  • SQL Server Express 2008 R2
  • Visual Web Developer 2010 Express
  • Visual Studio 2010 SP1 Code (SP1 only installation)
  • Visual Studio 2010 SP1 KB983509
  • IIS 7.5 Express
  • SQL Server System CLR Types
  • SQL Server Native Client
  • Microsoft SQL Server Compact 4.0
  • SQL Server 2008 R2 Management Objects
  • Web Deployment Tool 2.1
  • Microsoft Visual Studio 2010 SP1 Tools for SQL Server Compact 4.0 Installer for New Installtion
  • Microsoft Visual Studio 2010 SP1 Tools for SQL Server Compact 4.0 Installer
  • Microsoft Visual Studio 2010 SP1 Tools for SQL Server Compact 4.0
  • ASP.NET MVC 3 Tools Update Installer
  • Microsoft Visual Studio 2010 SP1 Tools for ASP.NET Web Pages
  • ASP.NET MVC 3 Tools Update Language Packs Installer
  • ASP.NET MVC 3 Tools Update Language Packs
  • Visual Web Developer Express 2010 SP1
  • Microsoft Visual Studio 2010 SP1 Tools for SQL Server Compact 4.0 Installer for Repair
It worked but for sure it's very slow on this machine.


Share/Bookmark

Sunday, January 23, 2011

C# - Static Constructors

• You declare a static constructor by "static" keyword in front of the constructor name.
• To initialize static fields in a class you can use static constructor.
• A static constructor is called before an instance of a class is created
• A static constructor is called before a static member is called.
• A static constructor is called before the static constructor of a derived class.
• A static constructor does not take access modifiers or have parameters.
• A static constructor cannot be called directly.
• They are called only once.
• Can't access anything but static members.

class MyClass
{
// Static constructor
static MyClass()
{
//...
}
}

Share/Bookmark

Sunday, January 9, 2011

Visual Studio 2010 runs faster when the Windows Automation API 3.0 is installed

Applications that use Windows Automation APIs can significantly decrease Microsoft Visual Studio IntelliSense performance if Windows Automation API 3.0 is not installed. For example, the Windows pen and touch services can significantly decrease Visual Studio IntelliSense performance if Windows Automation API 3.0 is not installed.
http://support.microsoft.com/kb/981741
Share/Bookmark

Sunday, June 13, 2010

Visual Source Safe - Recursive get items

The following codes work around Visual Source Safe (VSS), it's to get latest items from a project path in VSS.

using System;
using System.IO;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Configuration;
using Microsoft.VisualStudio.SourceSafe.Interop;

namespace VssDiff
{
public class VssItem
{
#region Fields
private string cnStr;
private string dtaTblName;
#endregion

#region Properties
public string CnStr { get { return cnStr; } set { cnStr = value; } }
public string DtaTblName {
get { return dtaTblName; }
set { dtaTblName = value; }
}
#endregion

public DataSet VssDataSet;

public VssItem()
{
VssDataSet = new DataSet();
CnStr =
ConfigurationManager.ConnectionStrings["cnStr"].ConnectionString;
DtaTblName = "VSS";
}

public bool VssDataTableAdd()
{
bool retVal = false;
string errMsg = string.Empty;

if ( VssDataSet == null )
{
errMsg = "Data Set is Null, add new data table failed.";
MessageBox.Show( errMsg, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error );
return retVal;
}

DataTable vssDtaTbl = new DataTable(DtaTblName);
vssDtaTbl.Columns.Add("vssItemEnv",
System.Type.GetType("System.String"));
vssDtaTbl.Columns.Add("vssItemName",
System.Type.GetType("System.String"));
vssDtaTbl.Columns.Add("vssItemType",
System.Type.GetType("System.Int32"));
vssDtaTbl.Columns.Add("vssItemVer",
System.Type.GetType("System.Int32"));
vssDtaTbl.Columns.Add("vssItemSpec",
System.Type.GetType("System.String"));
vssDtaTbl.Columns.Add("vssItemLabel",
System.Type.GetType("System.String"));
vssDtaTbl.Columns.Add("vssItemComment",
System.Type.GetType("System.String"));
vssDtaTbl.Columns.Add("vssItemDate",
System.Type.GetType("System.DateTime"));

VssDataSet.Tables.Add(vssDtaTbl);

retVal = true;
return retVal;
}

public void VssGetLatest(string vssPrjPath)
{
VSSItem mainVssItem;
string userId = Environment.UserName;

Microsoft.VisualStudio.SourceSafe.Interop.VSSDatabaseClass
vssDb = new VSSDatabaseClass();

vssDb.Open(@"\\MyServer\VSS\srcsafe.ini", userId, "");
vssDb.CurrentProject = vssPrjPath; // "$/MyApp/SOURCE";

mainVssItem = vssDb.get_VSSItem(vssDb.CurrentProject, false);
foreach (VSSItem vssSubItem in mainVssItem.get_Items(false))
{
VssItemSave(vssDb, vssSubItem);

if (vssSubItem.Type == (int)VSSItemType.VSSITEM_PROJECT)
if (vssSubItem.Spec.Contains("MyApp"))
VssChildGetLatest(vssDb, vssSubItem);

Application.DoEvents();
}

vssDb.Close();
}

private void VssChildGetLatest(
VSSDatabaseClass vssDb,
VSSItem vssItm)
{
try
{
VSSItem vssChildItem = vssDb.get_VSSItem(vssItm.Spec, false);
foreach (VSSItem vssSubItem in vssChildItem.get_Items(false))
{
VssItemSave(vssDb, vssSubItem);

if (vssSubItem.Type == (int)VSSItemType.VSSITEM_PROJECT)
if (vssSubItem.Spec.Contains("MyApp"))
VssChildGetLatest(vssDb, vssSubItem);

Application.DoEvents();
}
}
catch { }
}

public bool VssItemSave(VSSDatabaseClass vssDb, VSSItem vssItm)
{
bool retVal = true;

try
{
DataRow vssItmDtaRow = VssDataSet.Tables[DtaTblName].NewRow();
vssItmDtaRow["vssItemEnv"] = DtaTblName;
vssItmDtaRow["vssItemName"] = vssItm.Name;
vssItmDtaRow["vssItemType"] = vssItm.Type;
vssItmDtaRow["vssItemVer"] = vssItm.VersionNumber;
vssItmDtaRow["vssItemSpec"] = vssItm.Spec;

foreach (VSSVersion vssVersion in vssItm.get_Versions(0))
{
if (vssVersion.VersionNumber == vssItm.VersionNumber)
{
vssItmDtaRow["vssItemLabel"] = vssVersion.Label;
vssItmDtaRow["vssItemComment"] = vssVersion.Comment;
vssItmDtaRow["vssItemDate"] = vssVersion.Date;
break;
}
}

VssDataSet.Tables[dtaTblName].Rows.Add(vssItmDtaRow);
}
catch (Exception ex)
{
retVal = false;
MessageBox.Show(ex.Message);
}
return retVal;
}
}
}

Share/Bookmark

Sunday, May 23, 2010

Visual Studio - Search order for assemblies

Search order for assemblies when building a project of a solution in Visual Studio:

* Files from the current project indicated by {CandidateAssemblyFiles}.
* $(ReferencePath) property that comes from .user/targets file.
* $(HintPath) indicated by reference item.
* Target framework directory.
* Directories found in registry that uses AssemblyFoldersEx Registration.
* Registered assembly folders, indicated by {AssemblyFolders}.
* $(OutputPath) or $(OutDir)
* GAC

If the desired assembly is found by HintPath, but an alternate assembly can be found using ReferencePath, it will prefer the ReferencePath to the HintPath one.
Share/Bookmark

Visual Studio - Specify assemblies location by registry key

- Open registry by Regedit
- Search for following key (Depend on VS version use the correct number to point to this key in registry):
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\AssemblyFolders]
- Set the value of the key [AssemblyFolders] of type REG_SZ to the path of your assemblies.
Share/Bookmark

Saturday, May 22, 2010

to specify where Visual Studio search for the assemblies which you reference in your project

Unfortunately Visual Studio doesn't allow you to edit to reference assemblies, then you need to open the project file by a text editor and directly edit the ta and save the project file. When Visual studio detects the file change, it will ask you to reload the file.

Example:
<Reference Include="YourAssembly.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\CommonAssemblies\YourAssembly.dll</HintPath>
</Reference>

Share/Bookmark

Tuesday, February 16, 2010

VS 2008 - Microsoft.VisualStudio.DataDesign.SyncDesigner.SyncFacade.SyncManager Error

I experience the following error message when I wanted to get connected to a database on a SQL 2008 Express from a machine with a newly installed Visual Studio 2008.

When I tried "Add New Data Source" and after creating connection string at the time of proceeding to finalize the connection, the Error Message came up:

Could not load type 'Microsoft.VisualStudio.DataDesign.SyncDesigner.SyncFacade.SyncManager' from assembly 'Microsoft.VisualStudio.DataDesign.SyncDesigner.DslPackage.Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

The simple solution which worked for me was installing VS 2008 SP1, at this moment it's available at:
http://www.microsoft.com/downloads/en/confirmation.aspx?familyId=fbee1648-7106-44a7-9649-6d9f6d58056e&displayLang=en
Share/Bookmark

Wednesday, December 16, 2009

T-SQL - Synonyms


Share/Bookmark

Saturday, December 12, 2009

Visual Studio - Import and Export Settings

As you know we can customizing the IDE in Visual Studio, if you change the place of toolbox, properties window, server explorer, or some other features, you can save your setting to keep it for later and if you need to move to another machine or setting back to this point either if you changed something more and you didn't like it, just simply bring it back to your saved settings.


General settings, Browsers, Start page commands, Toolbox, help filters, options, and ... are all customizable and possible to save them all and assign a name to this set.



On the other hand, we can reload pre saved settings,


Good naming for saved settings will help a lot at this point


And at last we can reset all the customized settings to default state.


This feature is very useful but somehow hidden, customizing the environment will hep your productivity, then just using it and make it work the way you want it.
Share/Bookmark

Sunday, October 25, 2009

Visual Studio 2010 and .NET Framework 4 Training Course


Links to new Interview videos and How Do I clips and new posts about Visual Studio 2010 Beta2 in Channel 9.
http://channel9.msdn.com/learn/courses/VS2010/

"The Visual Studio 2010 and .NET Framework 4 Training Course includes videos and hands-on-labs designed to help you learn how to utilize the Visual Studio 2010 features and a variety of framework technologies including:
  • C# 4.0
  • Visual Basic 10
  • F#
  • Parallel Computing Platform
  • WCF
  • WF
  • WPF
  • ASP.NET AJAX 4.0
  • ASP.NET MVC Dynamic Data."

Share/Bookmark

Tuesday, October 20, 2009

Visual Studio 2010 and .NET Framework 4 Beta 2


The Visual Studio 2010 and .NET Framework Beta 2 is available to MSDN subscribers on Monday, October 19th. Visual Studio 2010 Beta 2 and Dot Net framework 4 Beta 2 will be made available to the general public on 21st October. Users will be able to get their hands on the final version of Visual Studio 2010 on 22nd March 2010.
http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx

Visual Studio 2010 and .NET Framework 4 Beta 2 Walkthroughs
http://msdn.microsoft.com/en-us/vstudio/dd441784.aspx

Testers to get Visual Studio 2010 Beta 2 this week; final by March 2010
http://blogs.zdnet.com/microsoft/?p=4270&tag=content;col1

Other links:
Microsoft names Visual Studio 2010 dates
http://www.theregister.co.uk/2009/10/19/visual_studio_2010_second_beta_packaging/

http://msdn.microsoft.com/en-us/vstudio/default.aspx

http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx
Share/Bookmark

Sunday, October 11, 2009

Visual Studio - An error occurred loading this property page

If you found out that the "Design, Split, Source" buttons are not available anymore, your first reaction would be to take a look at Tools->Options->HTML Designer, at this point probably you encounter with this error message:
"An error occurred loading this property page"

I encountered with the error and it was resolved by running "devenv /setup" in Visual Studio 2008 Command Prompt and restarting Visual Studio. The "Design, Split, Source" buttons came back to the right place after running that command.
Share/Bookmark