Before I dig deeper into the rabbit hole… a quick question…
is it possible?
We have this legacy system created in Visual Basic 6 and we are starting to port it to .NET and we want it to be unsigned. The problem is we have to sign our common libraries each time we have updates. (Common libraries is shared across different products).
Since we can’t port everything in an instant, we started porting the server first. Currently we designed the client interfaces to be COM visible so that Visual Basic UIs can invoke them.
Common framework dlls that we have are unsigned which is currently utilized by many projects. But for this product, we need to re-sign them which is too much work to do.
If this is not possible, will there be any other way, like wrapper, or some techniques to workaround this problem?
Thanks.
I think this is going to be tricky because of two things (that I guess you have probably already discovered):
Maybe someone has a better idea but given those two constraints I think the only thing you can do is something nasty with reflection…
Say you have a class in an unsigned library that you want to expose to COM that looks like this:
You can reference a signed assembly from an unsigned one so the first step could be to create an interface for just the bits of your classes you wish to expose to COM and put those interfaces in a new assembly that is signed. In our case say we define the interface thus (you can fiddle with the various COM attributes to make it to your liking):
Now reference that new assembly from your original one and change the class definition so that it implements the interface.
Now, go back to your signed assembly and add a little helper factory that looks like this (it is optional to do this but I think doing this in one place is a good idea):
The last step would be to create a wrapped up version of your class that you can expose to COM like so:
Now register your signed assembly for COM using regasm and that should do it. Massively tedious but given your constraints it is the only thing I can think of.
Suggested reading: