468,107 Members | 1,446 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

Dynamically create instance of class

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
Jul 26 '07 #1
0 1069

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Steven D'Aprano | last post: by
4 posts views Thread by Ray | last post: by
2 posts views Thread by macca | last post: by
7 posts views Thread by pmclinn | last post: by
15 posts views Thread by =?Utf-8?B?VG9tIENvcmNvcmFu?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.