Windows Phone Developers

Sunday, January 25, 2009

How to Add Resources to C# Windows Application

How to add images as resources to C# Windows Application


Resources can be added to the C# Project using Resource Page in the Project Designer (Project à Project Properties)

The Resources page of the Project Designer hosts an instance of the Resource Designer that stores and maintains resources in a single location (Resources.resx).

The Resource Designer is language-neutral and supports projects in all Visual Studio languages. Items that you add to the project by using the Resource Designer are placed in the Resources directory for your project. The designer information is stored in a file named Resources.resx, and code for the resource is stored in Resources.Designer.cs, Resources.Designer.vb, or Resources.Designer.jsl.










Right Click the Resources section in the solution explorer and Select Add à Existing Item and select the Image files that need to be added






The images will be added as shown below






Drag the images to the Resources page – Rename the resource names if needed




Now you can use the Resources in your Form. Select the BackGroundImage from the Form’s properties box – Click on the ellipsis next to the BackGroundImage property. This will open the Select Resource dialog Box





Select appropriate resource from the list



The same can be set through code using

this.BackgroundImage = Properties.Resources.User_Single

For linkedresources see - Create HTML Message with Embedded Images in VB.NET / Embed images in HTML mail message using VB.NET









































Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Cannot find wrapper assembly for type library "Microsoft.Office.Core".

Cannot find wrapper assembly for type library "Microsoft.Office.Core".


Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

There are updated custom wrappers available for the following referenced components: Office.

There are updated custom wrappers available for the following referenced components: Office.



Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

The referenced component 'Microsoft.Office.Core' could not be found.

The referenced component 'Excel' could not be found.

The warning occurs when you open the C#/ VB.Net Solution referring a different version of Microsoft Excel / Office. For example, If you open the Project, which refers Excel 2003 (Excel 11.0 Library) in Excel 2007 machine



Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

How to remove the Word from memory using C#

How to delete the leftover Word object using C#.

Closing Word Runtimes not removed by Word.Quit / Application.Quit

When Word crashes, it often takes with it the open documents. These documents will be write-locked and will appear as read-only to subsequent users. There are umpteen no. of reasons to crash a Word document and leave the ‘Winword.exe’ running in the memory. The following VB.NET code will remove the unused Word objects from memory.

Public Sub KillUnusedWordProcess()

Dim oXlProcess As Process() = Process.GetProcessesByName("Winword")

For Each oXLP As Process In oXlProcess

If Len(oXLP.MainWindowTitle) = 0 Then

oXLP.Kill()

End If

Next

End Sub

We have not tested the code in real-time. Our assumption was that any Word instance opened by user has a Window Title and programs using Word have been terminated. Check if the code is of any use and post the updations / suggestions to our ‘dud’ buddiesJ

automation does not close Microsoft Word, Application.Quit not closing Word

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Excel Runtimes not removed by Excel.Quit / Application.Quit

How to delete the leftover Excel object using VB.NET / Vb.NET delete Excel from memory

Excel runtimes that remain after the program is a nemesis. Many times this might be due to the leftover Excel objects in the program that causes Excel to remain in memory even after Application.Quit. Workbooks that are modified and left open often causes this problem. We have tried out one method to get rid of the Excel in memory using Vb.NET. We assumed that the programs that used Excel has been terminated and if any Excel remains in the memory it should be of the ‘legitimate’ application that the user has opened or the left over Excel.

We checked the presence of Title for Excel Application, which was present in all cases for the open instance of Excel. Left over instances didn’t had the title. The following code ‘kills’ the instances of Excel in memory that don’t have a WindowTitle.

Public Sub KillUnusedExcelProcess()

Dim oXlProcess As Process() = Process.GetProcessesByName("Excel")

For Each oXLP As Process In oXlProcess

If Len(oXLP.MainWindowTitle) = 0 Then

oXLP.Kill()

End If

Next

End Sub

Try if it works for you and post your suggestions or modifications

Keywords : automation does not close microsoft excel, Application.Quit not closing Excel

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Friday, January 16, 2009

No overload for method 'get_Range' takes '1' arguments

No overload for method 'get_Range' takes '1' arguments is error encountered by VB programmers trying to code in C#.

Excel.Workbook oWB = oXL.Workbooks.Open(sXLFileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing,missing );

// processing

Excel.Worksheet oWS = (Excel.Worksheet)oWB.Worksheets[1];

oWS.get_Range("A1").Value2 = "No";

This occurs when get_Range method is supplied with only one argument. Instead use any of the following:

oWS.get_Range("A1","A1").Value2 = "No";

or

Object missing = System.Type.Missing;

oWS.get_Range("A1",missing ).Value2 = "No";




Error Dialog
Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon