0

I have inherited a vb.net app that is a few years old now and have to update it to send orders to 2 versions of a 3rd party system.

  • Project A (existing) uses 3rd party dll in .net framework 3.5.
  • Project B (new clone of A) uses a newer version of 3rd party dll in .net 4.7.

  • Project Main (new) references Projects A & B plus 3 other projects in the solution; Entities, DataAccess & Core. Project Main has a SendTo function that either sends to the Project A or Project B SendTo function.

  • Project Core (new) References Entities & Data Access projects as well as the new 3rd party dll.

It has an interface:

Imports Entities
Public Interface IOrderService
Function SendTo(...) as Order
End Interface

which references the Entities project (.net 4.7)

And another interface:

Public Interface IClientSessionProvider
Function LogonService() as LogonService
...
End Interface

etc. which references the new 3rd party dll.

If I try and use the new .dll in Project A & make that .net framework 4.7 I get an 'Error in Application' error when using one of the .dll functions. This function works perfectly in Project B (which uses the new .dll).

How can I best organise the code so that Project A remains 3.5, everything else remains 4.7 & my solution can talk to both .dll's as required?

Is it possible to keep my interface so the code can still call the method in Project A or B as necessary, or is there another way to solve this?

DxTx
  • 2,724
  • 2
  • 19
  • 32
Angela
  • 73
  • 4
  • Possible duplicate of [How can I load an older version of a .NET assembly?](https://stackoverflow.com/questions/7959843/how-can-i-load-an-older-version-of-a-net-assembly) – eddex Mar 20 '19 at 10:16

1 Answers1

0

I managed to get both dll's working by using Assembly.LoadFrom, here is an excerpt from my code:

Dim params() As Object = New Object() {configuration, orderSaverService}

Dim assembly As Assembly = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + "\\<dll name here>.dll")
Dim myType As Type = assembly.GetType("<dll name + namespace here>", True)
objOrder = System.Activator.CreateInstance(myType, params)
appDomainOrder = AppDomain.CreateDomain()
iexecute = DirectCast(objOrder, IExecute)

where IExecute is my new interface which I implement in both Projects A & B.

Angela
  • 73
  • 4