Experience in C++, C#, Java and Process : Living in Montreal

* What is my technical experience as a software developer

* What I have learned in the software business

* Where I am heading to in my career

* How to process in a project

Monday, December 20, 2004

Show a form as a dialog box in C#

About about = new About();

// Show it as a diaglog
about.ShowDialog();

// Show it as a form
about.Show();

Sunday, December 19, 2004

VS.NET Setup Project : Issues and Solutions

Environment:
Microsoft Visual Studio.NET 2003
Windows XP SP2
DELL Inspiron 8200, CPU P4-M 1.6M ,512MB 15.4LCD, 40G, 3COM Wireless, DVD+CDRW, Logitech MX310

Project:


  1. During the install process , the setup asks users to give a project name [ProjectName]. If the user select Link.NET Example, the setup will install a [defult database]; if not, the database will not be installed.
  2. The [defult database] contains a few of folders up to 20.
  3. Add an Uninstall menu along with the main program menu.

Solutions & Problems:

  1. Add a new dialog Textboxes (B) in the user interface editor, press F4 to show its property window. Assign "EDIT_PROJECTNAME" as Edit1Property and "Link.NET Example" as Edit1Value, so [EDIT_PROJECTNAME] can be used anywhere to represent "Link.NET Example".
  2. Drag/drop a database folder to the Application Folder in the File System. VS.NET will add the whole folder hiberarchy to the setup folder. [Problem] If you wnat to delete the folders from the setup project, it would be nightmare. The root folder can not be deleted if each of its subfolders contains any files. To remove the whole folder, first of all, you have to remove all files in each folder, by hands! I have tried to move the database file to a MSM file, but it never works.
  3. Show the database folder property, set the Condition property as "[EDIT_PROJECTNAME] == "Link.NET Example"". During the setup procedure, this Condition will be checked to determine if the database should be installed.
  4. [More about Condition] Add a provision that allows users to create a shortcut to the FormattingApplication in their desktops. As before, you'll need to add the shortcut to the User's Desktop folder. Right-click on Primary output from the FormattingApplication (Active) item in the Application folder and select Create Shortcut to Primary output from FormattingApplication (Active) from the context menu. Rename the shortcut Formatting Application. Drag and drop it in the User's Desktop folder. However, you want this shortcut to be installed only if the user wants to install it. Therefore, set the Condition property of the User's Desktop folder to SHORTCUTDEMO. This ensures that the shortcut will be installed only if this condition is set to true. Later in this article, you will create a dialog box where this property can be set. Web like help
  5. VS.NET setup project does not encourage to add a uninstallation menu along with the application invoking menu. To do that, you have to add a shortcut for "msiexec /x [productcode]". But, you have to add msiexec into your application folder first before creating the shortcut.
  6. I can create a menu with static name during the setup, but I want to assign the menu name with user's own defined project name. It is impossible to do it in VS.NET setup project.

Friday, December 17, 2004

Add a new link for Employment

Wednesday, December 15, 2004

C# Practise: System.Diagnostics.Process.Start

The following two code blocks are same:
1.
System.Diagnostics.Process.Start("http://www.glinknet.com");
return;

2.
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "http://www.glinknet.com";
p.StartInfo.Verb = "Show";
p.StartInfo.CreateNoWindow = true;
p.Start();

Tuesday, December 14, 2004

Use IE as references in C# project

You may need both references:

SHDocVw = Microsoft Internet Controls : the DOM

1. Add references ...
2. Choose COM tab, select Component Name as Microsoft Internet Controls.
3. Done


Mshtml = Microsoft HTML Object Library : The IE core engine
1. Add references ...
2. Select Microsoft.mshtml assembly under the .NET tab.
3. Add

How they work together ?
  • IHTMLDocument (or IHTMLDocument2) interface is defined at mshtml and it must be retrieved from the shdocvw interface
  • SHDocVw.IWebBrowser2 IEHost = (SHDocVw.IWebBrowser2)this.Explorer;
  • mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2) IEHost.Document;

Solve "strong name" error in C# project

Error:

Assembly generation failed -- Referenced assembly 'Interop.Project1' does not have a strong name

Problem:
1. Add ShDocVw reference in my C# project
2. Make method calls
SHDocVw.IWebBrowser htmlDoc2 = (SHDocVw.IWebBrowser)this.Explorer;
string s = htmlDoc2.LocationURL;
3. Error when compiling

Solutions:
If a Visual C# .NET project references the COM Interop assembly, the COM Interop assembly is generated for you when you reference the COM dynamic-link library (DLL). You can specify the wrapper assembly key file in the Visual C# project properties as follows:

To strongly-name a VS-generated Interop assembly, you need to go to yourproject properties and in the Common -> General section, set the WrapperAssembly Key File to point to your SNK file. The path used is relative tothe csproj/vbproj file, so for a typical arrangement where the snk file iswith the sln file and the projects are in subdirs, then it'd be just"..\yourkey.snk"


Interesting Blog.

Saturday, December 11, 2004

choice is an illusion-