开发者

How do I clone a OLE/COM registry entry for use with different settings

I have written a C# program that is to interface with Catia v5.18开发者_开发知识库 via OLE/COM. It is going to be a common case where the machine the program is ran on will have multiple versions of Catia installed on it. Both older and newer and installed in any funky order. The last one installed gets to put its settings in the registry.

I'm trying to setup the registry to use a new handle to connect only to a 5.18 CNEXT server. I found the Catia.Application entry in HKEY_CLASSES_ROOT and the CLSID entry. I made copies of these and provided a new UUID for CLSID and came up with the following registry import file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CATIA.Application.v518]
@="OLE CATIA.Application"

[HKEY_CLASSES_ROOT\CATIA.Application.v518\CLSID]
@="{ba3ca493-05fb-4188-a767-f40c03db2672}"

[HKEY_CLASSES_ROOT\CLSID\{ba3ca493-05fb-4188-a767-f40c03db2672}]
@="OLE CATIA.Application" "AppID"="{ba3ca493-05fb-4188-a767-f40c03db2672}"

[HKEY_CLASSES_ROOT\CLSID\{ba3ca493-05fb-4188-a767-f40c03db2672}\LocalServer32]
@="\"C:\\Program Files\\Dassault Systemes\\B18\\intel_a\\code\\bin\\CNEXT.exe\" -env \"CATIA_PLM_Express.V5R18.B18\" -direnv \"C:\\Documents and Settings\\All Users\\Application Data\\DassaultSystemes\\CATEnv\""

[HKEY_CLASSES_ROOT\CLSID\{ba3ca493-05fb-4188-a767-f40c03db2672}\ProgID]
@="CATIA.Application.v518" 

[HKEY_CLASSES_ROOT\CLSID\{ba3ca493-05fb-4188-a767-f40c03db2672}\VersionIndependentProgID]
@="CATIA.Application" 

I verified that the import worked, but when I run my application I come accross the following error when I try to connect to it.

System.Runtime.InteropServices.C OMException (0x80080005): Retrieving the COM class factory for component with CLSID {BA3CA493-05FB-4 188-A767-F40C03DB2672} failed due to the following error: 80080005 Server execution failed (Exceptio n from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)

I'm able to run this program fine on the normal installs using "CATIA.Application" and "CATIA.Application.1", but here is the code I use to connect to the Application if it matters:

public CatiaApplication() {

  Type catia_program_id = Type.GetTypeFromProgID( "CATIA.Application.v518" );

  try {
    this._instance = (Application)Activator.CreateInstance( catia_program_id );
  }
  catch( Exception ex ) {
    throw new ApplicationException( "Failed to access Catia Application: " + ex.ToString());
  }
}

Anybody have any ideas? I haven't tried to reboot the box but so far it looks like the changes take effect immediately.


Shouldn't it be this instead?

[HKEY_CLASSES_ROOT\CATIA.Application.v518]
"CLSID"="{ba3ca493-05fb-4188-a767-f40c03db2672}"

where you wrote it:

[HKEY_CLASSES_ROOT\CATIA.Application.v518\CLSID]
@="{ba3ca493-05fb-4188-a767-f40c03db2672}"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜