473,320 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem Creating DLL Entry Point

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.

Sep 4 '07 #1
2 2980
>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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Sep 4 '07 #2
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...

---
Patrice

"FFrozTT" <te**@millennium.ab.caa écrit dans le message de news:
11**********************@y42g2000hsy.googlegroups. com...
>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.

Sep 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Hal Vaughan | last post by:
I am using OpenOffice files in my app. They're stored in .zip format, so the zip format is much more important, in this case, than that they're OOo files (other than that the extension is .sxw and...
1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
4
by: Mike Woinoski | last post by:
(I'm new to VS, so please forgive me if this is a faq.) I'm writing some Java web services and need to test them with C++ clients. I can use either a Windows Form application or an MFC application....
8
by: nick | last post by:
I have a problem and I've been using a cheezy work around and was wondering if anyone else out there has a better solution. The problem: Let's say I have a web application appA. Locally, I set...
10
by: Bryce Calhoun | last post by:
Hello, First of all, this is a .NET 1.1 component I'm creating. SUMMARY ----------------------- This component that I'm creating is, for all intents and purposes, a document parser (I'm...
3
by: clsmith66 | last post by:
I hope this is just something stupid I'm missing and someone can easily point out my error. I'm trying to do a few turorials on windows services, and the couple I found so far just create an event...
3
by: Lynn McGuire | last post by:
I am creating a function prototype for a DLL entry point. I dynamically load the DLL at runtime and then map the entry points. typedef SP_STATUS SP_API (* myRNBOsproReadProc) ( SP_IN...
5
by: Vibhesh | last post by:
I am facing problem with TimeSpan structure when DirectX is used. Following is the sample code that causes the problem: ...
60
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
On May 3, 8:09 am, apati...@gmail.com wrote: A programmer that uses Vista? :O Vista is a hog of an operating system. Downgrade to Windows XP or get yourself a Linux distro.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.