473,569 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Reflecti on
Imports System.Threadin g
Imports System.IO

Public Class MyDLL
Public Const DLL_PROCESS_DET ACH = 0
Public Const DLL_PROCESS_ATT ACH = 1
Public Const DLL_THREAD_ATTA CH = 2
Public Const DLL_THREAD_DETA CH = 3

Public Function DllMain(ByVal hinstDLL As Long, ByVal fdwReason As
Long, ByVal lpwReserved As Long) As Boolean
Select Case fdwReason
Case DLL_PROCESS_DET ACH
' No per-process cleanup needed
Case DLL_PROCESS_ATT ACH
DllMain = True
Case DLL_THREAD_ATTA CH
' No per-thread initialization needed
Case DLL_THREAD_DETA CH
' No per-thread cleanup needed
End Select

Call MyFunction()
Do
Application.DoE vents()
Loop Until Not MyFunctionRunni ng()
End Function

Public Shared Sub Main()
Call MyFunction()
Do
Application.DoE vents()
Loop Until Not MyFunctionRunni ng()
End Sub

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

Thanks in advance for any assistance with this problem.

Sep 4 '07 #1
2 2993
>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**@millenniu m.ab.caa écrit dans le message de news:
11************* *********@y42g2 00...legr oups.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.Reflecti on
Imports System.Threadin g
Imports System.IO

Public Class MyDLL
Public Const DLL_PROCESS_DET ACH = 0
Public Const DLL_PROCESS_ATT ACH = 1
Public Const DLL_THREAD_ATTA CH = 2
Public Const DLL_THREAD_DETA CH = 3

Public Function DllMain(ByVal hinstDLL As Long, ByVal fdwReason As
Long, ByVal lpwReserved As Long) As Boolean
Select Case fdwReason
Case DLL_PROCESS_DET ACH
' No per-process cleanup needed
Case DLL_PROCESS_ATT ACH
DllMain = True
Case DLL_THREAD_ATTA CH
' No per-thread initialization needed
Case DLL_THREAD_DETA CH
' No per-thread cleanup needed
End Select

Call MyFunction()
Do
Application.DoE vents()
Loop Until Not MyFunctionRunni ng()
End Function

Public Shared Sub Main()
Call MyFunction()
Do
Application.DoE vents()
Loop Until Not MyFunctionRunni ng()
End Sub

Public Sub MyFunciton()
...
End Function
Public Sub MyFunctionRunni ng()
... 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
1957
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 not .zip). (I know these code sections use outside variables, but it's probably pretty clear what the outside variables are -- if not, I can...
1
4012
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 same way a menu does. To do this my control needs to get notified when the user tried to click off of it. The Leave and LostFocus events of the...
4
3912
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. I used VS.NET 2003 to create a C# client that successfully processes SOAP messages to and from the Java service. However, I'm having problems with...
8
3373
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 it up as C:\domains\appA. Locally, my IIS root points to C:\domains. I don't point it to C:\domains\appA since if I have an appB under C:\domains I...
10
2528
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 actually deserializing a SOAP document into an object and parsing out the fields, but that's fairly immaterial to this
3
1391
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 log and write an entry on start and stop. I build the projects and install them fine, but when I run the service it starts and stops instantly. ...
3
2981
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 RBP_SPRO_APIPACKET packet, SP_IN RB_WORD address, SP_OUT RBP_WORD data ); myRNBOsproReadProc myRNBOsproRead;
5
1987
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: *************************************************************************************************************** { ........................... PrintTimeSpanProblem(); device = new Device(0, DeviceType.Hardware, this,...
60
4033
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
7701
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.