Wednesday, July 16, 2008

How to update or refresh a Typed DataSet (xsd file) in the DataSet Designer in Visual Studio

I had this issue and had a mental fart and couldn't figure how to solve it.  I read some message boards where people said it was impossible, but the solution is simple.  If you have a typed dataset in the DataSet Designer and you make changes to the database in sql server (just say add a new column), you can refresh the Dataset by clicking on the Data Sources tab.  Then right click on your dataset or table and clicking "refresh'.

In my situation, my dataset was populated by a stored procedure.  So I had to go into Microsoft Sql Server Management Studio Express, Go the Programmability Folder/Stored Procedures and find my stored procedure.  right click it and select modify, then add the new column and execute it.

Then back in Visual Studio, I had to right click on my Dataset Table and select "Configure Dataset with Wizard" and expand the Stored Procedures, then find my stored procedure and at the bottom was the new column that I added.  Just check the column name and it was added to the dataset.

the above paragraph would probably also apply even if you didn't have a Stored Procedure by your main engine, as you could add and remove tables using the "Configure Dataset with Wizard".

-- Ted


Sunday, July 13, 2008

BannerBitmap conflicts with BannerText

I added a 500X70 banner bitmap to my setup application, however it seems to conflict with the BannerText.  And there doesn't seem to be a way to remove the BannerText.  The following website seems to have a solution.  I haven't tried it out, but it seems to run on the install file after you build your application. 

http://www.bokebb.com/dev/english/1993/posts/199395473.shtml


Add My App to the Open With Menu

I've had a VB.NET application which claim some file types.  When a user double-clicks on one of these file types the application is launched.  However when they right-click on it and select the "Open With" menu, my application comes up, but only the icon is shown.  There is no text with the icon.

I searched on the internets with no solution.  A fair number of people asked this question, like this person
http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic59830.aspx
but no answers.

I tried different things in the Setup part of the application with no luck.  Finally, I realized the issue was with the MUICache value in the Registry, however I did not want to run a .reg file after the install. 

Finally, I stumbled upon the answer, and it seems to be setting the AssemblyDescription value in the AssemblyInfo.vb file of your main executable.  What's odd is that in the recent past, I tried setting some values here and it didn't make a difference. 

The key might have to do is that fact that there was a blank values in the MUICache for my application, and once I deleted the key associated with my application from the MUICache then it registered.  On that note, it could be the AssemblyDescription, AssemblyTitle or AssemblyProduct values as they all have the same value.  I'll need to do more testing to verify exactly which one is the key value to be filled out.

Also, the MUICache values don't get removed when you uninstall your application.



Update
The above technique basically is crap. It only works if the entry doesn't exist in the MUICache. What I mean by that is if you have a blank entry in the MUICache, delete it, then install your application (or just launch it), a new entry will now be in the MUICache with the proper information. For some reason, a previous verison of mine entered a blank value into the MUICache, and now i can't get rid of it, or overwrite it through the install. I'd rather not remove it from my code, but I might end up having to.

Thursday, July 3, 2008

Constants for WND_Proc overrides

I know its possible to get these from some file on your machine, but whenever I need a constant I can't ever seem to find them.  Here is a list I found online:

   Public Const WM_USER As Integer = &H400
   Public Const WM_NULL As Integer = &H0
   Public Const WM_CREATE As Integer = &H1
   Public Const WM_DESTROY As Integer = &H2
   Public Const WM_MOVE As Integer = &H3
   Public Const WM_SIZE As Integer = &H5
   Public Const WM_ACTIVATE As Integer = &H6
   Public Const WM_SETFOCUS As Integer = &H7
   Public Const WM_KILLFOCUS As Integer = &H8
   Public Const WM_ENABLE As Integer = &HA
   Public Const WM_SETREDRAW As Integer = &HB
   Public Const WM_SETTEXT As Integer = &HC
   Public Const WM_GETTEXT As Integer = &HD
   Public Const WM_GETTEXTLENGTH As Integer = &HE
   Public Const WM_PAINT As Integer = &HF
   Public Const WM_CLOSE As Integer = &H10
   Public Const WM_QUERYENDSESSION As Integer = &H11
   Public Const WM_QUIT As Integer = &H12
   Public Const WM_QUERYOPEN As Integer = &H13
   Public Const WM_ERASEBKGND As Integer = &H14
   Public Const WM_SYSCOLORCHANGE As Integer = &H15
   Public Const WM_ENDSESSION As Integer = &H16
   Public Const WM_SHOWWINDOW As Integer = &H18
   Public Const WM_WININICHANGE As Integer = &H1A
   Public Const WM_DEVMODECHANGE As Integer = &H1B
   Public Const WM_ACTIVATEAPP As Integer = &H1C
   Public Const WM_FONTCHANGE As Integer = &H1D
   Public Const WM_TIMECHANGE As Integer = &H1E
   Public Const WM_CANCELMODE As Integer = &H1F
   Public Const WM_SETCURSOR As Integer = &H20
   Public Const WM_MOUSEACTIVATE As Integer = &H21
   Public Const WM_CHILDACTIVATE As Integer = &H22
   Public Const WM_QUEUESYNC As Integer = &H23
   Public Const WM_GETMINMAXINFO As Integer = &H24
   Public Const WM_PAINTICON As Integer = &H26
   Public Const WM_ICONERASEBKGND As Integer = &H27
   Public Const WM_NEXTDLGCTL As Integer = &H28
   Public Const WM_SPOOLERSTATUS As Integer = &H2A
   Public Const WM_DRAWITEM As Integer = &H2B
   Public Const WM_MEASUREITEM As Integer = &H2C
   Public Const WM_DELETEITEM As Integer = &H2D
   Public Const WM_VKEYTOITEM As Integer = &H2E
   Public Const WM_CHARTOITEM As Integer = &H2F
   Public Const WM_SETFONT As Integer = &H30
   Public Const WM_GETFONT As Integer = &H31
   Public Const WM_SETHOTKEY As Integer = &H32
   Public Const WM_GETHOTKEY As Integer = &H33
   Public Const WM_QUERYDRAGICON As Integer = &H37
   Public Const WM_COMPAREITEM As Integer = &H39
   Public Const WM_GETOBJECT As Integer = &H3D
   Public Const WM_COMPACTING As Integer = &H41
   Public Const WM_OTHERWINDOWCREATED As Integer = &H42
   Public Const WM_OTHERWINDOWDESTROYED As Integer = &H43
   Public Const WM_COMMNOTIFY As Integer = &H44
   Public Const WM_WINDOWPOSCHANGING As Integer = &H46
   Public Const WM_WINDOWPOSCHANGED As Integer = &H47
   Public Const WM_POWER As Integer = &H48
   Public Const WM_COPYDATA As Integer = &H4A
   Public Const WM_CANCELJOURNAL As Integer = &H4B
   Public Const WM_NOTIFY As Integer = &H4E
   Public Const WM_INPUTLANGCHANGEREQUEST As Integer = &H50
   Public Const WM_INPUTLANGCHANGE As Integer = &H51
   Public Const WM_TCARD As Integer = &H52
   Public Const WM_HELP As Integer = &H53
   Public Const WM_USERCHANGED As Integer = &H54
   Public Const WM_NOTIFYFORMAT As Integer = &H55
   Public Const WM_CONTEXTMENU As Integer = &H7B
   Public Const WM_STYLECHANGING As Integer = &H7C
   Public Const WM_STYLECHANGED As Integer = &H7D
   Public Const WM_DISPLAYCHANGE As Integer = &H7E
   Public Const WM_GETICON As Integer = &H7F
   Public Const WM_SETICON As Integer = &H80
   Public Const WM_NCCREATE As Integer = &H81
   Public Const WM_NCDESTROY As Integer = &H82
   Public Const WM_NCCALCSIZE As Integer = &H83
   Public Const WM_NCHITTEST As Integer = &H84
   Public Const WM_NCPAINT As Integer = &H85
   Public Const WM_NCACTIVATE As Integer = &H86
   Public Const WM_GETDLGCODE As Integer = &H87
   Public Const WM_SYNCPAINT As Integer = &H88
   Public Const WM_NCMOUSEMOVE As Integer = &HA0
   Public Const WM_NCLBUTTONDOWN As Integer = &HA1
   Public Const WM_NCLBUTTONUP As Integer = &HA2
   Public Const WM_NCLBUTTONDBLCLK As Integer = &HA3
   Public Const WM_NCRBUTTONDOWN As Integer = &HA4
   Public Const WM_NCRBUTTONUP As Integer = &HA5
   Public Const WM_NCRBUTTONDBLCLK As Integer = &HA6
   Public Const WM_NCMBUTTONDOWN As Integer = &HA7
   Public Const WM_NCMBUTTONUP As Integer = &HA8
   Public Const WM_NCMBUTTONDBLCLK As Integer = &HA9
   Public Const WM_KEYFIRST As Integer = &H100
   Public Const WM_KEYDOWN As Integer = &H100
   Public Const WM_KEYUP As Integer = &H101
   Public Const WM_CHAR As Integer = &H102
   Public Const WM_DEADCHAR As Integer = &H103
   Public Const WM_SYSKEYDOWN As Integer = &H104
   Public Const WM_SYSKEYUP As Integer = &H105
   Public Const WM_SYSCHAR As Integer = &H106
   Public Const WM_SYSDEADCHAR As Integer = &H107
   Public Const WM_KEYLAST As Integer = &H108
   Public Const WM_INITDIALOG As Integer = &H110
   Public Const WM_COMMAND As Integer = &H111
   Public Const WM_SYSCOMMAND As Integer = &H112
   Public Const WM_TIMER As Integer = &H113
   Public Const WM_HSCROLL As Integer = &H114
   Public Const WM_VSCROLL As Integer = &H115
   Public Const WM_INITMENU As Integer = &H116
   Public Const WM_INITMENUPOPUP As Integer = &H117
   Public Const WM_MENUSELECT As Integer = &H11F
   Public Const WM_MENUCHAR As Integer = &H120
   Public Const WM_ENTERIDLE As Integer = &H121
   Public Const WM_CTLCOLORMSGBOX As Integer = &H132
   Public Const WM_CTLCOLOREDIT As Integer = &H133
   Public Const WM_CTLCOLORLISTBOX As Integer = &H134
   Public Const WM_CTLCOLORBTN As Integer = &H135
   Public Const WM_CTLCOLORDLG As Integer = &H136
   Public Const WM_CTLCOLORSCROLLBAR As Integer = &H137
   Public Const WM_CTLCOLORSTATIC As Integer = &H138
   Public Const WM_MOUSEFIRST As Integer = &H200
   Public Const WM_MOUSEMOVE As Integer = &H200
   Public Const WM_LBUTTONDOWN As Integer = &H201
   Public Const WM_LBUTTONUP As Integer = &H202
   Public Const WM_LBUTTONDBLCLK As Integer = &H203
   Public Const WM_RBUTTONDOWN As Integer = &H204
   Public Const WM_RBUTTONUP As Integer = &H205
   Public Const WM_RBUTTONDBLCLK As Integer = &H206
   Public Const WM_MBUTTONDOWN As Integer = &H207
   Public Const WM_MBUTTONUP As Integer = &H208
   Public Const WM_MBUTTONDBLCLK As Integer = &H209
   Public Const WM_MOUSELAST As Integer = &H209
   Public Const WM_PARENTNOTIFY As Integer = &H210
   Public Const WM_ENTERMENULOOP As Integer = &H211
   Public Const WM_EXITMENULOOP As Integer = &H212
   Public Const WM_MDICREATE As Integer = &H220
   Public Const WM_MDIDESTROY As Integer = &H221
   Public Const WM_MDIACTIVATE As Integer = &H222
   Public Const WM_MDIRESTORE As Integer = &H223
   Public Const WM_MDINEXT As Integer = &H224
   Public Const WM_MDIMAXIMIZE As Integer = &H225
   Public Const WM_MDITILE As Integer = &H226
   Public Const WM_MDICASCADE As Integer = &H227
   Public Const WM_MDIICONARRANGE As Integer = &H228
   Public Const WM_MDIGETACTIVE As Integer = &H229
   Public Const WM_MDISETMENU As Integer = &H230
   Public Const WM_DROPFILES As Integer = &H233
   Public Const WM_MDIREFRESHMENU As Integer = &H234
   Public Const WM_CUT As Integer = &H300
   Public Const WM_COPY As Integer = &H301
   Public Const WM_PASTE As Integer = &H302
   Public Const WM_CLEAR As Integer = &H303
   Public Const WM_UNDO As Integer = &H304
   Public Const WM_RENDERFORMAT As Integer = &H305
   Public Const WM_RENDERALLFORMATS As Integer = &H306
   Public Const WM_DESTROYCLIPBOARD As Integer = &H307
   Public Const WM_DRAWCLIPBOARD As Integer = &H308
   Public Const WM_PAINTCLIPBOARD As Integer = &H309
   Public Const WM_VSCROLLCLIPBOARD As Integer = &H30A
   Public Const WM_SIZECLIPBOARD As Integer = &H30B
   Public Const WM_ASKCBFORMATNAME As Integer = &H30C
   Public Const WM_CHANGECBCHAIN As Integer = &H30D
   Public Const WM_HSCROLLCLIPBOARD As Integer = &H30E
   Public Const WM_QUERYNEWPALETTE As Integer = &H30F
   Public Const WM_PALETTEISCHANGING As Integer = &H310
   Public Const WM_PALETTECHANGED As Integer = &H311
   Public Const WM_HOTKEY As Integer = &H312
   Public Const WM_PRINT As Integer = &H317
   Public Const WM_PRINTCLIENT As Integer = &H318
   Public Const WM_PENWINFIRST As Integer = &H380
   Public Const WM_PENWINLAST As Integer = &H38F

Tuesday, July 1, 2008

System.IO.FileNotFoundException: Could not load file or assembly 'stdole, Version=7.0.3300.0

All of a sudden I started to get this error when deploying the application, without getting this error on the development machine.  It turns out that the problem has to do with .NET 2.0.  Apparently, the latest version does not include this file in the GAC.  And my application is looking for the file there .  There seems to be a number of possible fixes for this error.  The one that worked for me,  I got from the following website:

http://forums.msdn.microsoft.com/en/clr/thread/426dfa9c-1ab7-4b3e-9474-99edb377fcb6/

To summarize:
1.  Right click on the stdole.dll in the reference section of project and select local copy true. By default it will be false.  This will tell the application not to get it from the GAC.
2.  Add the file to your application.  In your setup application, go to View->Editor->File System.  In the pane that opens up, right click and select Add->Assembly.  Go to the following location:
C:\Program Files\Microsoft.NET\Primary Interop Assemblies and select stdole.dll.

Recompile your application and it should now work.

Below are some other suggestions:
- Remove the reference from your project (I couldn't do this as I use an old FlexGrid and it used it).
-
In "Project-Properties" - "Publish" - "Application Files..." - "stdole.dll" set "publish Status" to "Include". (I already had the file included when I got the problem).
- From the command-line run gacutil with the stdole.dll.  This is a workaround to get it up and running fast, but defeats the idea of having a setup application.

some other sites where people asked this question:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=9506&SiteID=1
http://forums.msdn.microsoft.com/en-US/vbgeneral/thread/17d097ae-9465-4a0d-82f1-5005b7dc26e0/