Problem Creating DLL Entry Point


F

FFrozTT

I am having a problem creating a DLL with an entry point. I've been
trying sub Main, DllMain, and I get nothing. When I run dumpbin -
exports mydll.dll I see no entry points, also the dll when executed by
rundll32 is not giving expected results. I have the project set to
Class Library with Sub Main as the startup object, which I can't
change to anything else anyway without modifying the .vbproj file
which also seems to have no effect. Also there seems to be a circular
error where
I get
Sub Main = "No accessible 'Main' method witha n appropriate signater
was found in 'MyDLL'."

Public Sub Main = "No accessible 'Main' method witha n appropriate
signater was found in 'MyDLL'."

Public Shared Sub Main = "Cannot refer to an instance member of a
class from within a shared method or shared member initializer without
an explicit instance of the class" -- Where it is referring to the
call to MyFunction which I have tryed as subs and functions and can't
seem to get out of this error without moving all my code to a module,
instead of a class. I don't really care if it is a module or a class
because I don't have to instantiate this object, just execute it but
everywhere I read people say to use Classes now, modules are just for
backward compatability with VB6.

Here is basically my code...

Option Explicit On
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.Reflection
Imports System.Threading
Imports System.IO

Public Class MyDLL
Public Const DLL_PROCESS_DETACH = 0
Public Const DLL_PROCESS_ATTACH = 1
Public Const DLL_THREAD_ATTACH = 2
Public Const DLL_THREAD_DETACH = 3

Public Function DllMain(ByVal hinstDLL As Long, ByVal fdwReason As
Long, ByVal lpwReserved As Long) As Boolean
Select Case fdwReason
Case DLL_PROCESS_DETACH
' No per-process cleanup needed
Case DLL_PROCESS_ATTACH
DllMain = True
Case DLL_THREAD_ATTACH
' No per-thread initialization needed
Case DLL_THREAD_DETACH
' No per-thread cleanup needed
End Select

Call MyFunction()
Do
Application.DoEvents()
Loop Until Not MyFunctionRunning()
End Function

Public Shared Sub Main()
Call MyFunction()
Do
Application.DoEvents()
Loop Until Not MyFunctionRunning()
End Sub

Public Sub MyFunciton()
....
End Function
Public Sub MyFunctionRunning()
.... Check if function still running.
End Function

Thanks in advance for any assistance with this problem.
 
Ad

Advertisements

M

Mattias Sjögren

I am having a problem creating a DLL with an entry point.

I'm not surprised. VB doesn't support that so you can stop trying now.

I have the project set to
Class Library with Sub Main as the startup object,

The startup object is only relevant for EXEs.


Mattias
 
Ad

Advertisements

P

Patrice

How will you consume this DLL ? You can't export DLL functions with .NET
using the old win32 style. You can consume them from other .NET or COM
applications.

If you really need to create an "old style" DLL you should likely use C++
or any other programming tool that supports that...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top