Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 29th, 2004, 09:29 AM
Authorized User
 
Join Date: Dec 2003
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DolphinBay
Default LoadFrom Invoke Member... Method not found

Good morning,

I am trying to call a method from a DLL being created at runtime. I am using the LoadFrom and InvokeMember members of the reflection class. Can someone please tell me why the method is not being found. I am including the code from the DLL, the invoke member, and the error message I am receiving.

Thanks in advance.

Eric

ERROR MESSAGE
Method subLic.reg.fName not found.
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
at subrep.WebForm1.Page_Load(Object sender, EventArgs e) in D:\test\temp.aspx.vb:line 40 (The invokeMember line)

CODE CREATING THE DLL:
        Public Shared Sub createSubLic()
            Dim sb As New System.Text.StringBuilder
            Dim provider As Microsoft.VisualBasic.VBCodeProvider
            Dim compiler As System.CodeDom.Compiler.ICodeCompiler
            Dim cp As System.CodeDom.Compiler.CompilerParameters
            Dim results As System.CodeDom.Compiler.CompilerResults

            With sb
                .Append("Namespace subLic")
                .Append(vbCrLf)
                .Append(" Public Class reg")
                .Append(vbCrLf)
                .Append(" Public Shared Function fName()")
                .Append(vbCrLf)
                .Append(" return ""Test""")
                .Append(vbCrLf)
                .Append(" End Function")
                .Append(vbCrLf)
                .Append(" End Class")
                .Append(vbCrLf)
                .Append("End Namespace")
            End With
            cp = New System.CodeDom.Compiler.CompilerParameters
            cp.ReferencedAssemblies.Add("System.dll")
            cp.ReferencedAssemblies.Add("System.Web.dll")
            cp.GenerateExecutable = False
            cp.GenerateInMemory = True
            cp.OutputAssembly = "D:\test\bin\subLic.dll"
            Try
                provider = New Microsoft.VisualBasic.VBCodeProvider
                compiler = provider.CreateCompiler
                results = compiler.CompileAssemblyFromSource(cp, sb.ToString)
                If results.Errors.Count > 0 Then
                    Dim i As Integer
                    For i = 0 To results.Output.Count - 1
                        sStatus += results.Output(i) & vbCrLf
                    Next i
                    For i = 0 To results.Errors.Count - 1
                        sStatus += ((i.ToString() + ": " + results.Errors(i).ToString())) & vbCrLf
                    Next i
                End If

                sStatus += sb.ToString

            Catch ex As Exception
                sStatus = ex.Message
            End Try
        End Sub
    End Class

CODE CALLING THE DLL:
        Dim result As Object
        Try
            Dim asm As [Assembly] = [Assembly].LoadFrom("D:\test\bin\subLic.dll")
            Dim t As Type = asm.GetTypes()(0)
            Dim o As Object = asm.CreateInstance(t.FullName)
            result = t.InvokeMember("fName", BindingFlags.Default Or BindingFlags.InvokeMethod Or BindingFlags.Instance, Nothing, o, Nothing)
            If Not result Is Nothing Then
                 txt2.Text = CType(result, String)
            End If
        Catch ex As Exception
            txt2.Text += ex.Message & vbCrLf & ex.StackTrace
        End Try



Dolphin Bay, Inc. -- turning visions into eReality(tm) -- West Palm Beach, FL
Website Design, Internet Strategy, Search Engine Marketing

www.DolphinBay.biz





Similar Threads
Thread Thread Starter Forum Replies Last Post
complile error : method or data member not found! Tasha Access VBA 6 May 1st, 2007 03:49 PM
Method or Data Member not Found Related to Crystal ishqvj Beginning VB 6 0 November 29th, 2006 03:49 AM
Method or data member not found Subuana Beginning VB 6 1 March 6th, 2006 03:32 PM
Method or Data member not found Anup Gavate VB How-To 2 March 25th, 2005 04:50 PM
LoadFrom Invoke Member... Method not found DolphinBay VB.NET 2002/2003 Basics 1 April 29th, 2004 10:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.