lmspcdhvm
lmspcdhvm

Reputation: 25

How to prevent old versions of C# dlls from running

I have a Library Projects that gets used in a variety of other Programs and I want to prevent old versions of the Library to run. Is it possible to include a code snippet that gets called every time the dll is being loaded?

Or do you have any other idea how to prevent older versions from being called in programs?

To be more precise I want to prevent future old versions from running, older versions that are being used right now can not be affected.

Upvotes: 1

Views: 56

Answers (1)

Rubens Farias
Rubens Farias

Reputation: 57936

You can define that in the config file:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json"
                          publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect  oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
      </dependentAssembly>

That way, whenever you have an assembly that matches that identity, the framework will use that other version you provided.

Upvotes: 2

Related Questions