I am using the following code to execute a method of a class in an assembly
Public Shared Function NewPerson() As TZ_Interfaces.I Person
'This factory will return an instance of clsPerson with ID=intID
'from the BLL assembly defined in BLLCustomAssemb ly setting
Dim strType As String = BLLCustomAssemb ly '
My.Settings.BLL CustomAssembly
Dim objPerson As TZ_Interfaces.I Person = Nothing
Dim objAssembly As Assembly = Nothing
Dim objType As Type = Nothing
objAssembly = Assembly.LoadFr om(strType & ".dll")
objType = objAssembly.Get Type(strType & ".BLL.clsPerson ")
'Invoke the NewPerson shared method of clsPerson
Dim objMethodInfo As MethodInfo = objType.GetMeth od("NewPerson" ,
System.Reflecti on.BindingFlags .[Static] Or BindingFlags.[Public])
objPerson = objMethodInfo.I nvoke(objType, Nothing)
Return objPerson
End Function
If my calling code is a WinForms app, this code works as long as the DLL is
in the bin\debug directory of the WinForms assembly.
When I try the same thing with my calling code being an ASP.Net app I get
the following error, even if the relevant dll is in the bin directory of the
web app
Could not load file or assembly 'file:///C:\Program Files\Microsoft Visual
Studio 8\Common7\IDE\~ \Bin......
Advice appreciated
Public Shared Function NewPerson() As TZ_Interfaces.I Person
'This factory will return an instance of clsPerson with ID=intID
'from the BLL assembly defined in BLLCustomAssemb ly setting
Dim strType As String = BLLCustomAssemb ly '
My.Settings.BLL CustomAssembly
Dim objPerson As TZ_Interfaces.I Person = Nothing
Dim objAssembly As Assembly = Nothing
Dim objType As Type = Nothing
objAssembly = Assembly.LoadFr om(strType & ".dll")
objType = objAssembly.Get Type(strType & ".BLL.clsPerson ")
'Invoke the NewPerson shared method of clsPerson
Dim objMethodInfo As MethodInfo = objType.GetMeth od("NewPerson" ,
System.Reflecti on.BindingFlags .[Static] Or BindingFlags.[Public])
objPerson = objMethodInfo.I nvoke(objType, Nothing)
Return objPerson
End Function
If my calling code is a WinForms app, this code works as long as the DLL is
in the bin\debug directory of the WinForms assembly.
When I try the same thing with my calling code being an ASP.Net app I get
the following error, even if the relevant dll is in the bin directory of the
web app
Could not load file or assembly 'file:///C:\Program Files\Microsoft Visual
Studio 8\Common7\IDE\~ \Bin......
Advice appreciated
Comment