Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I split a .net DLL without having to recompile other DLLs that reference the original one?

I have a C# project that builds into a single DLL with two classes, ClassA and ClassB. For project management reasons, I'd like to move ClassB into a separate DLL, leaving the original DLL with ClassA only.

The problem is that I have other DLLs (also compiled from C#) that reference ClassA and ClassB in their original DLL. ClassA is fine but calling ClassB ends up with a TypeLoadException.

(I could recompile all of those other DLLs with their new project references, but I'd rather not do that, again for project management reasons.)

Is there a way I could deploy my new split DLLs and have the other DLLs continue to work? Or, do I really need to bite the proverbial bullet and plan to deploy new versions of all these files?

like image 810
billpg Avatar asked Nov 25 '25 09:11

billpg


1 Answers

You achieve this using Type forwarding. This enables moving a type to another assembly. In the original assembly, you add a TypeForwardedTo-attribute to signal that the type has been moved.

See this link for detailed information.

like image 74
Markus Avatar answered Nov 27 '25 21:11

Markus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!