Click here to Skip to main content
15,435,593 members
Articles / Programming Languages / C#
Posted 29 Jan 2018


6 bookmarked

Registration Free Activation of .NET Assembly with fox-pro Application through COM and SXS

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
29 Jan 2018CPOL2 min read
Step by step procedure to xcopy deploy .NET assembly into fox-pro application


Step by step instructions to achieve the registration free activation of the .NET assembly side by side with fox-pro application through COM, SXS and CLR.

Using the code

Step 1 - Create a .NET assembly as COM Sever

  • Create a .NET class and Include the namespace System.Runtime.InteropServices;
  • Generate and apply a guid attribute for the class. I didn't apply the ClassInterfaceType attribute, as the default is AutoDispatch. You can change the ClassInterfaceType to none, if you want to expose functionality through interfaces implemented explicitly by the class.
using System.Runtime.InteropServices;
	namespace Netnamespace
	public class NetClass
	public string NetMethod(string input)
	//Implement the logic here..

Step 2 - Sign the .NET assembly

It's mandatory to sign the assembly with a strong name for registration free interoperability. Hence generate a key pair by execute the command sn -k keypair.snk in the command prompt. Edit the following assembly attributes in AssemblyInfo.cs and build the project.

//Enable the com visibility
	[assembly: ComVisible(true)]
	Note - This attribute can be applied on specific methods to avoid exposing entire assembly.
	//Point the keypair file for signing the assembly
	[assembly: AssemblyKeyFileAttribute("..\\..\\keypair.snk")]
	Note - Use the absolute or relative path to locate the .snk file.
	//Generate and apply a guid attribute for the type library
	[assembly: Guid("A67D75D0-7AE7-434F-8A41-2C1E0B48ADF3")]

Step 3 - Embed Sxs manifest into the .NET assembly

The .NET assembly must have a SxS manifest describing the COM registration information. Add a manifest file in your project and enter the assembly identity as below.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
name="<Assembly name>"
version="<Assembly version>"
publicKeyToken="<Assembly PublicKey Token>" />

clsid="<GUID applied over the .Net class>"
runtimeVersion="<CLR Version>" >

Download the and extract the GenMan32.exe. Execute the below command in the command prompt to embed the manifest.

genman32.exe "..\bin\Release\assemblyname.dll" /add /manifest:"..\assemblyname.dll.manifest"

Note - Alter the relative path according to your project or use absolute path in the command.

Step 4 - Create external manifest for the foxpro application(COM client)

Download the and extract the projecthookex.vct. Edit getdefaultmanifest method of moduleresourceeditor as below through fox-pro. Then Hook the edited projecthookex.vct as a Project Class in the Project Info of fox-pro. The project class is applied only after close and reopen the fox-pro application. Build the fox-pro application will generate an external manifest.

LOCAL lcReturn
	*!* The following is the default manifest in a compiled VFP app
	TEXT TO m.lcReturn textmerge noshow
<?xml version="1.0" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
name="<Foxpro EXE Name>"
<description><Description about Foxpro EXE></description>
name="<.Net Assembly name>"
version="<.Net Assembly version>"
publicKeyToken="<.Net Assembly publickey token>"
	RETURN (m.lcReturn)

Step 5: Call the .Net class from foxpro application(COM Client)

objVFP = CreateObject("<progId>")
	lresult = objVFP.NetMethod("")

Note - progid configured in .NET assembly manifest.

Step 6 - SXS Trace to trace the COM activation error

If the COM activation failed due to invalid configuration in manifest, then the fox-pro application launch shows the following error.

"The application has failed to start because its side by side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail".

Execute the below command in the command prompt to start the trace.

C:\Windows\System32>SxsTrace Trace -logfile:SxsTrace.etl

Launch the foxpro application(COM client) and execute the event to trigger the activation of .NET assembly. Stop the tracing in the command prompt.

Execute the following command to output the error:

C:\Windows\System32>SxsTrace Parse -logfile:SxsTrace.etl -outfile:SxsTrace.txt

Find the generated SxsTrace.txt in C:\Windows\System32 explains about the invalid configuration of the manifest.

Reference Links

Points of Interest

SxsTrace tool is interesting to trace the COM activation issues.


  • 25-Jan-2018 - Created the article.
  • 27-Jan-2018 - Updated the License and also formatted the xml content.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Software Developer (Senior) ABSS
Malaysia Malaysia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

Questionthanks for the article Pin
FabianSilva24-Sep-18 7:57
MemberFabianSilva24-Sep-18 7:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.