Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add methods to a class without changing the COM+ Class ID

I am writing some code in a dll that must conform to certain specs. One of those, is that it can only use the methods, enums, classes, etc that it currently has.

The specification of all one method is enforced by an application that I "submit" the dll to. If it doesn't conform to the specs, it rejects it.

Update: This is specifically happening in C#. The documentation regarding the spec states: "If any code other than the four public functions is changed, the COM+ Class ID could change and the object safety script will not work, causing the BSTCustomValidation.dll validation component to not run."

like image 401
TruthOf42 Avatar asked Dec 20 '22 23:12

TruthOf42


2 Answers

Given the requirement is to only have one exported function then it is easy to fulfill that by not exporting the other 19.

like image 170
JensG Avatar answered Jan 19 '23 16:01

JensG


Sounds like you should define an explicit interface.

Because COM interop generates a class interface automatically, post-version changes to your class can alter the layout of the class interface exposed by the common language runtime. Since COM clients are typically unprepared to handle changes in the layout of an interface, they break if you change the member layout of the class.

Combining that with declaring everything private or internal as necessary should be sufficient.

like image 23
Bobson Avatar answered Jan 19 '23 17:01

Bobson