How can I get the version of SSMS from VSIX - windows

I am developing an extention for SSMS using VSIX.
In this extension I need to know which version of SSMS I am running on.
What is the best way to get that?

I do it like this in my SSMS extension (for SSMS 16 and higher)
var dte = GetServiceHelper(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
if (dte == null) return new Version(130, 0, 0, 0);
if (dte.RegistryRoot.Contains("14.0"))
{
return new Version(140, 0, 0, 0);
}
return new Version(130, 0, 0, 0);
https://github.com/ErikEJ/SqlCeToolbox/blob/master/src/GUI/SSMSToolbox/Package/SqlCeToolboxPackage.cs#L67

dte.Version returns 2015.0130 for SSMS 2016 and 2017.0140 for SSMS 17.

Related

VS 2017 Debugger variable preview is wrong

I have a strange behavior when debugging in Visual Studio 2017 with the preview of variables, if a variable-name is used more than ones, in different scopes.
Here is a simple sample:
private void Test()
{
var values = new List<int> {1, 2, 3, 4, 5, 6, 7, 8};
if (values.Count > 20)
{
var a = 0;
a = values[5];
}
else
{
var a = 0;
a = values[5];
}
}
The bebugger preview told me, that "a" in the second scope is zero.
If i change the variable in the bottom scope to "b" everything works fine...
Is that the normal behavior of the debugger? Cant remember...
Seems like Fody caused this behavior. After deinstalling Fody, the debugger works as expected!
Fody (Version 1.29.4) / PropertyChanged.Fody (Version 1.52.1)

Excel 2013 with Visual Studio 2013 taking long time to generate excel file

Initially, My project was developed on MS 2003 with Visual Studio 2005 and MS Office 2007. It takes 5 - 6 minutes to create excel file with microsoft.office.interop.excel
Now, I have migrated my project on MS 2008 R2 SP1 with VS 2013 and MS Office 2013. For the same sheet above mentioned, it takes around two hours.
Following things I have tried:
Latest assemblies have been tried.
excelApp.Visible = false; excelApp.ScreenUpdating = false; excelApp.DisplayAlerts = false; (thse set up are not done before migration but was still fast)
Tried installing Excel 2007, Excel 2010 and Excel 2013. (Both Office 32 bit and 64 version tried)
It's being more than 5 days, I am at the same problem.
Sample Code is as below:
Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
excelApp.Visible = false;
excelApp.ScreenUpdating = false;
excelApp.DisplayAlerts = false;
Excel._Workbook excelBook = (Excel._Workbook)excelApp.Workbooks.Add(Excel.XlSheetType.xlWorksheet);
Excel._Worksheet excelWorksheet = (Excel._Worksheet)excelBook.ActiveSheet;
Excel._Worksheet excelWorksheet2 = (Excel._Worksheet)excelBook.Sheets.Add(System.Reflection.Missing.Value, excelWorksheet, 1, Excel.XlSheetType.xlWorksheet);
Excel._Worksheet excelWorksheet3 = (Excel._Worksheet)excelBook.Sheets.Add(System.Reflection.Missing.Value, excelWorksheet2, 1, Excel.XlSheetType.xlWorksheet);
Excel._Worksheet excelWorksheet4 = (Excel._Worksheet)excelBook.Sheets.Add(System.Reflection.Missing.Value, excelWorksheet3, 1, Excel.XlSheetType.xlWorksheet);
Excel._Worksheet excelWorksheet5 = (Excel._Worksheet)excelBook.Sheets.Add(System.Reflection.Missing.Value, excelWorksheet4, 1, Excel.XlSheetType.xlWorksheet);
Excel._Worksheet excelWorksheet6 = (Excel._Worksheet)excelBook.Sheets.Add(System.Reflection.Missing.Value, excelWorksheet5, 1, Excel.XlSheetType.xlWorksheet);
Excel._Worksheet excelWorksheet7 = (Excel._Worksheet)excelBook.Sheets.Add(System.Reflection.Missing.Value, excelWorksheet6, 1, Excel.XlSheetType.xlWorksheet);
//****************** For the Day Summary Report (Sheet 1)*****************
Excel.Range oRng1;
... onwards updating excel sheets....
I dont know how to fix it.
Please help.

Grid Control : Run time Error when run at Windows XP in Visual Studio 2008

OS : Windows 7 32 bit
Developping Tool : Visual Studio 2008
Problem :
When run at Windows 7 it's ok, but at XP there is assertion error at DEBUG mode, invisible grid control error at RELEASE mode. (like you can see it as pictures below)
Situation :
The grid control class, I used for the program, was downloaded from code-project. (I think I can't upload the file in stackoverflow? If you need it, plz tell me.)
I used to use this class in VS 6.0. It's my first time using it in VS 9.0. There was no error when I used it in VS 6.0.
There is no compiling error when I compile the program in Windows 7 and XP.
On Windows 7, it runs well both at DEBUG and RELEASE mode.
On Windows XP, running exe file in the DEBUG folder gives an assertion error. And when I run exe file in the RELEASE folder, the grid control doesn't show up.
And I also tried to compile on XP with Visual Studio to see if there is any error, but it only gives run-time error.
Error :
Debug Assertion Failed! Program : ...
File : .../gridctrl_src/gridcell.cpp
Line : 228
For information on how your program
can cause an assertion failure, see
the Visual C+ documentation on
asserts.
The below is gridcell.cpp source code at the error line.
/////////////////////////////////////////////////////////////////////////////
// CGridDefaultCell
CGridDefaultCell::CGridDefaultCell()
{
#ifdef _WIN32_WCE
m_nFormat = DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX;
#else
m_nFormat = DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX | DT_END_ELLIPSIS;
#endif
m_crFgClr = CLR_DEFAULT;
m_crBkClr = CLR_DEFAULT;
m_Size = CSize(30,10);
m_dwStyle = 0;
#ifdef _WIN32_WCE
LOGFONT lf;
GetObject(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), &lf);
SetFont(&lf);
#else // not CE
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(NONCLIENTMETRICS);
VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0));
SetFont(&(ncm.lfMessageFont));
#endif
}
Thank you in advance!!
I encountered the same issue with CGridCtrl while porting a project from VC6 to VS2012.
In your project set _WIN32_WINNT to the lowest target platform you want your application to support. That's 0x0501 for XP SP1.
No code changes should be required in CGridDefaultCell.
Related discussion on MSDN
Answer my own question...
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ...) problem
// Initially use the system message font for the GridCtrl font
NONCLIENTMETRICS ncm;
memset(&ncm,0,sizeof(NONCLIENTMETRICS));
ncm.cbSize = sizeof(NONCLIENTMETRICS);
#if (WINVER >= 0x0600)
ncm.cbSize -= 4; //<== ADD HERE!!
#endif
BOOL f = SystemParametersInfo(SPI_GETNONCLIENTMETRICS,sizeof(NONCLIENTMETRICS), &ncm, 0);
VERIFY(f);
if(f){
memcpy (&m_LogFont, &ncm.lfMessageFont, sizeof (LOGFONT));
m_LogFont.lfHeight = -MulDiv (11, dc.GetDeviceCaps (LOGPIXELSY), 72);
m_LogFont.lfWeight = FW_NORMAL;
m_LogFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
m_LogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
m_LogFont.lfQuality = DEFAULT_QUALITY;
m_LogFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
m_LogFont.lfCharSet = ANSI_CHARSET;
_tcscpy (m_LogFont.lfFaceName, _T ("Courier New"));
}

Image Processing In c#,.net

I want to create a small application that allows me to insert an image on top of another image.And also i want to insert some text as well.
So can someone points me out where to start.Is there any open source libraries that allows me to do this task?.
I am after a solution that can be implemented in C#,Visual Studio .net.
Thanks.
You need to use the Graphics class.
For example:
using(var oldImage = Bitmap.FromFile(path))
using(var newImage = new Bitmap(250, 250))
using(var graphics = Graphics.FromImage(newImage)) {
graphics.DrawImage(oldImage, 10, 15);
graphics.DrawString("Hello, world!", SystemFonts.DefaultFont, Brushes.Red, 0, 0);
newImage.Save(path);
}
Try ImageMagick.Net. Lotsa stuff in there.
You should be OK using System.Drawing.Graphics if you don't need anything too fancy.

How can I set the size of the cmd.exe window from my Perl program?

I have a Perl script running in windows, that displays to screen very long lines.
I don't want to fix my console size permanently. I just want it to be big in case this script is running.
Is there a way to define the console's size from within the Perl script that runs inside this window?
You can set the console size of a running console with the mode command:
mode con lines=50 cols=200
The change will only persist until the console window is closed.
See Win32::Console. The sample program has a resize demonstration that works on my Windows XP SP3. I haven't tried it anywhere else.
Also, using a simple GUI consisting simply of a text-box might be easier.
Here is an adaptation of testWindow from the sample script:
use strict; use warnings;
use Win32::Console;
my $OUT = Win32::Console->new(STD_OUTPUT_HANDLE);
my $IN = Win32::Console->new(STD_INPUT_HANDLE);
$IN->Mode(ENABLE_MOUSE_INPUT|ENABLE_WINDOW_INPUT);
$OUT->Size(180, 200);
my ($maxx, $maxy) = $OUT->MaxWindow;
$OUT->Cls;
$OUT->Cursor(-1, -1, -1, 0);
$OUT->FillAttr($BG_YELLOW|$FG_BLUE, $maxy * $maxx, 0, 0);
$OUT->FillChar('X', $maxy*$maxx, 0, 0);
$OUT->Window(1, 0, 0, $maxx, $maxy);
while ($maxx>1 and $maxy>1) {
$maxx -= 5;
$maxy -= 5;
$OUT->Window(1, 0, 0, $maxx, $maxy);
sleep 1;
}
$OUT->Window(1, 0, 80, 50);
$OUT->Cls;

Resources