Share via


Register the Visual C# Smart Tag DLL [Office 2003 SDK Documentation]

Next, make the SimpleCSharpST DLL known to other Windows applications (namely all smart tag supporting applications) by registering it. Before registering, be sure to quit Word, Excel, PowerPoint, Access, Outlook and Internet Explorer if they are currently running. Also make sure there are no hidden instances of these applications running by checking processes in the Task Manager.

Registration using Namespace.ClassName

A managed smart tag DLL is registered using its fully qualified class name which is Namespace.ClassName in HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Recognizers\<Namespace.ClassName>

and

HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Actions\<Namespace.ClassName>

Under those keys, there are two values you need to write:

Managed -- A DWORD value. A data value of one (1) will enable the managed registry key, signaling that the Visual Studio Tools for Office loader should be used to load that particular assembly. If you don't want to use the Visual Studio Tools for Office loader, set the value to zero (0).

Filename -- A String value. This string value would be the path to where the managed smart tag DLL is located.

Note  You won't need to register the managed smart tag DLL for com-interop at HKEY_CLASSES_ROOT since you are using the Visual Studio Tools for Office loader.

To register the SimpleCSharpST.dll, follow these steps:

To start the registry Editor go to the Start menu, click Run and type regedit in the Open box.

Caution  Be extra cautious when in the registry environment as accidentally editing a configuration value (which is not what you are supposed to do in this tutorial) can cause your system to become unstable or unusable.

Caution  Modifying the Microsoft Windows® registry in any manner, whether through the Registry Editor or programmatically, always carries some degree of risk. Incorrect modification can cause serious problems that may require you to reinstall your operating system. It is a good practice to always back up a computer's registry first before modifying it. If you are running Microsoft Windows NT® or Microsoft Windows 2000, you should also update your Emergency Repair Disk (ERD). For information about how to edit the registry, view the "Changing Keys and Values" Help topic in the Registry Editor (Regedit.exe) or the "Add and Delete Information in the Registry" and "Edit Registry Information" topics in the Registry Editor (Regedt32.exe).

Step 1. In the Actions folder at

HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Actions

create a new key: right-click on the Actions key, point to New, and then click Key.

Step 2. Enter the action handler's Namespace.ClassName which in this example is SimpleCSharpST.CSharpSTAction as the new key value.

Step 3. Right click on the SimpleVBNetST.VBNetSTAction key, point to New, and then click String value. Type Filename as its name.

Step 4. Right click on Filename and click Modify. The Value data should be the path to your managed smart tag DLL. In this example, it would be C:\SimpleCSharpST\SimpleCSharpST\bin\Debug\SimpleCSharpST.dll

Step 5. Right click on the SimpleCSharpST.CSharpSTAction key again, point to New, and then click DWORD value. Type Managed as its name.

Step 6. Right click on Managed and click Modify. The Value data should be 1 to signal you want to use the Visual Studio Tools for Office loader to load your managed smart tag DLL.

Step 7. Repeat Steps 1 to 6 for the recognizer at

HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Recognizers

where the Namespace.ClassName of the recognizer is SimpleCSharpST.CSharpSTRecognizer

The SimpleCSharpST.dll is now registered.

Alternate Method to Register

Instead of opening the registry and manually writing the keys, you can also create a .reg file. You can do this by copying and pasting the following syntax onto Notepad and save it as a .reg file. For your convenience, a sample RegSimpleCSharpST.reg has been included in this SDK for your reference. It is located in the same folder as this sample (which is also included in this SDK for your reference). To locate it, return to the SDK installation directory.

Note  For display purposes, overly long lines of code in this topic have been broken to new lines and indented four spaces. If you copy and paste the code, you may need to remove the line breaks in these lines of code or the code sample will not function properly.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Office\Common
    \Smart Tag\Actions\SimpleCSharpST.CSharpSTAction]
"Filename"="C:\\SimpleCSharpST\\SimpleCSharpST\\bin
    \\Debug\\SimpleCSharpST.dll"
"Managed"=dword:00000001

[HKEY_CURRENT_USER\Software\Microsoft\Office\Common
    \Smart Tag\Recognizers\SimpleCSharpST.CSharpSTRecognizer]
"Filename"="C:\\SimpleCSharpST\\SimpleCSharpST\\bin
    \\Debug\\SimpleCSharpST.dll"
"Managed"=dword:00000001

If you want to remove the registration later on, you could create a .reg file to do so. The syntax is as follows:

Windows Registry Editor Version 5.00

[-HKEY_CURRENT_USER\Software\Microsoft\Office\Common
    \Smart Tag\Actions\SimpleCSharpST.CSharpSTAction]
"Filename"="C:\\SimpleCSharpST\\SimpleCSharpST
    \\bin\\Debug\\SimpleCSharpST.dll"
"Managed"=dword:00000001

[-HKEY_CURRENT_USER\Software\Microsoft\Office\Common
    \Smart Tag\Recognizers\SimpleCSharpST.CSharpSTRecognizer]
"Filename"="C:\\SimpleCSharpST\\SimpleCSharpST
    \\bin\\Debug\\SimpleCSharpST.dll"
"Managed"=dword:00000001

A sample of the above .reg file (UnRegSimpleCSharpST.reg) is included in the SDK in the same folder as this sample.

Note  If you saved the sample in a different directory, adjust the path to your managed smart tag DLL as appropriate.