I want to dynamically create instance of class stored in other application.
I am writing the following code for this purpose:
Here in the AssemblyFunc() I am loading the assembly of TariffClass application which is loaded successfully. In objectCreate() I am creating object of class present in TariffClass application. But I am getting the following error
'Could not load file or assembly 'file:///C:\Inetpub\wwwroot\QuickQuote\TariffClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.'
Private Function objectCreate(ByVal Classnm As String) As Object
Dim objHandle2 As ObjectHandle
Dim objClient As Object
Dim clientType As String
Dim assemblyName As String
'-----Creating the runtime instances for client class---------
assemblyName = AssemblyFunc()
clientType = "TariffClass." + Classnm
objHandle2 = Activator.CreateInstanceFrom(assemblyName, clientType)
objClient = objHandle2.Unwrap
'-------instance created--------
Return objClient
End Function
Public Function AssemblyFunc() As String
'---------Creating Assembly to load the WebApplication6.dll----------
Dim assem As [Assembly]
assem = [Assembly].LoadFile("C:\Inetpub\wwwroot\QuickQuote\Classes\T ariffClass\bin\Release\TariffClass.dll")
Dim assemName As String
assemName = assem.ToString
Return assemName
End Function