473,396 Members | 1,917 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,396 software developers and data experts.

Calling a VB.NET-DLL FROM VB6

hi,

I've writte a DLL in VB.NET which is called from VB6.

When I try to call some methods of the DLL in a sub Procedure I get the following error: "Object reference not set to an instance of
an object."

this is my code in VB6 (simplified)

Sub Main
Dim myDLL as new Wrapper.Wrapper

'this works
myDLL.CallMethod
End Sub

But when i try this, I get an error:

Sub Main

Dim myDLL as new Wrapper.Wrapper

Call callMethodFromDLL
End Sub

Sub callMethodFromDLL(ByRef myDLL as Wrapper.Wrapper)

'here i get the error
myDLL.CallMethod

End Sub

Has anyone an idea?

br
Peter

Sep 6 '06 #1
4 5308
Peter Piry wrote:
I've writte a DLL in VB.NET which is called from VB6.

When I try to call some methods of the DLL in a sub Procedure I get the
following error: "Object reference not set to an instance of an object."
Do you get this error on /some/ methods, or on *all* of them?
But when i try this, I get an error:

Sub Main

Dim myDLL as new Wrapper.Wrapper

Call callMethodFromDLL

End Sub

Sub callMethodFromDLL(ByRef myDLL as Wrapper.Wrapper)

'here i get the error
What error???
/You've/ seen it - /we/ haven't ...
myDLL.CallMethod

End Sub
Are you /sure/ that's where the error is?
The above code won't even compile.

callMethodFromDLL requires one argument - a reference to your Wrapper
object. According to the above, you haven't supplied one.

Sub Main
Dim myDLL as new Wrapper.Wrapper
Call callMethodFromDLL( myDLL )
End Sub

HTH,
Phill W.
Sep 6 '06 #2

"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-kwrote in message news:ed**********@south.jnrs.ja.net...
Peter Piry wrote:
>I've writte a DLL in VB.NET which is called from VB6.

When I try to call some methods of the DLL in a sub Procedure I get the
following error: "Object reference not set to an instance of an object."

Do you get this error on /some/ methods, or on *all* of them?
>But when i try this, I get an error:

Sub Main

Dim myDLL as new Wrapper.Wrapper

Call callMethodFromDLL

End Sub

Sub callMethodFromDLL(ByRef myDLL as Wrapper.Wrapper)

'here i get the error

What error???
/You've/ seen it - /we/ haven't ...
>myDLL.CallMethod

End Sub

Are you /sure/ that's where the error is?
The above code won't even compile.

callMethodFromDLL requires one argument - a reference to your Wrapper
object. According to the above, you haven't supplied one.
yes, sorry, i've forgotten to write the Argument. The right line: Call callMethodFromDLL(mydll). i have this line in my code.
>
Sub Main
Dim myDLL as new Wrapper.Wrapper
Call callMethodFromDLL( myDLL )
End Sub

HTH,
Phill W.
Sep 6 '06 #3
I know we're only working with pseudocode here, but is the problem that
you haven't called your constructor?
I've dug out the one time I ever used a COM object in VB6, and the code
there says, basically:

dim namedCOMObject as COMObject
namedCOMOBJECT = new COMObject

If you're calling methods to the COM object directly, they may work
without you having an instance of the object, but if you want to use
information from an instance of the object, I'm fairly certain you have to
spread constructing it over two lines, as above.

I'm only a student though. I might be talking nonsense

KF

On Wed, 06 Sep 2006 15:28:56 +0100, Peter Piry <pe********@reflex.at
wrote:
>
"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-kwrote in message
news:ed**********@south.jnrs.ja.net...
>Peter Piry wrote:
>>I've writte a DLL in VB.NET which is called from VB6.
When I try to call some methods of the DLL in a sub Procedure I get
the following error: "Object reference not set to an instance of an
object."
Do you get this error on /some/ methods, or on *all* of them?
>>But when i try this, I get an error:
Sub Main
Dim myDLL as new Wrapper.Wrapper
Call callMethodFromDLL
End Sub
Sub callMethodFromDLL(ByRef myDLL as Wrapper.Wrapper)
'here i get the error
What error???
/You've/ seen it - /we/ haven't ...
>>myDLL.CallMethod
End Sub
Are you /sure/ that's where the error is?
The above code won't even compile.
callMethodFromDLL requires one argument - a reference to your Wrapper
object. According to the above, you haven't supplied one.

yes, sorry, i've forgotten to write the Argument. The right line: Call
callMethodFromDLL(mydll). i have this line in my code.
> Sub Main
Dim myDLL as new Wrapper.Wrapper
Call callMethodFromDLL( myDLL )
End Sub
HTH,
Phill W.


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Sep 6 '06 #4
"Kristian Frost" <kf****@gmail.comwrote in message news:op***************@rndskycomwin.domain...
I know we're only working with pseudocode here, but is the problem that
you haven't called your constructor?
I've dug out the one time I ever used a COM object in VB6, and the code
there says, basically:

dim namedCOMObject as COMObject
namedCOMOBJECT = new COMObject

If you're calling methods to the COM object directly, they may work
without you having an instance of the object, but if you want to use
information from an instance of the object, I'm fairly certain you have to
spread constructing it over two lines, as above.

I'm only a student though. I might be talking nonsense

KF

On Wed, 06 Sep 2006 15:28:56 +0100, Peter Piry <pe********@reflex.at>
wrote:
>
"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-kwrote in message
news:ed**********@south.jnrs.ja.net...
>Peter Piry wrote:
>>I've writte a DLL in VB.NET which is called from VB6.
When I try to call some methods of the DLL in a sub Procedure I get
the following error: "Object reference not set to an instance of an
object."
Do you get this error on /some/ methods, or on *all* of them?
>>But when i try this, I get an error:
Sub Main
Dim myDLL as new Wrapper.Wrapper
Call callMethodFromDLL
End Sub
Sub callMethodFromDLL(ByRef myDLL as Wrapper.Wrapper)
'here i get the error
What error???
/You've/ seen it - /we/ haven't ...
>>myDLL.CallMethod
End Sub
Are you /sure/ that's where the error is?
The above code won't even compile.
callMethodFromDLL requires one argument - a reference to your Wrapper
object. According to the above, you haven't supplied one.

yes, sorry, i've forgotten to write the Argument. The right line: Call
callMethodFromDLL(mydll). i have this line in my code.
> Sub Main
Dim myDLL as new Wrapper.Wrapper
Call callMethodFromDLL( myDLL )
End Sub
HTH,
Phill W.


Hi,

I've solved the problem. It was a writing protection on the document, which the sub procedure opens.

Mysteriously it works at the first time.

br
Peter
Sep 7 '06 #5

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

Similar topics

0
by: Elrond Bishop | last post by:
Hi I am having a problem calling a .Net object and passing an object to it from normal asp. the normal asp keeps seing the object I want to pass as a "string" variant type instead of an object....
3
by: Neil Penn | last post by:
I need to be able to call some .NET code from an old VB application. Looking around on MSDN it looks like I should expose the .NET code as a COM object and access the COM object from Visual...
1
by: Bobby | last post by:
Hello, I'm seeing strange behavior experimenting with calling .NET. If I create a project in .NET 2k3 and select 'interop assembly' it will create the CCW for me, correct? I created a class...
9
by: Eddie J | last post by:
I'm getting an intermittent error when calling a .NET web service from a .NET console application. Both are using v.1.1.4322 of the framework. Any ideas on what could be causing this? It can...
1
by: ecydba | last post by:
When attempting to use a web service that has NTFS permissions to the Domain Users group and Anonymous access turned off in IIS on a WinXP machine with the following classic ASP code: Dim oSoap...
1
by: Scott Yen | last post by:
Hi, I'm using the following Axis java client to invoke a .Net web service hosted my localhost. Although the username and password is set on the "call", client gets (401) Access Denied"...
0
by: =?Utf-8?B?QWRhbUM=?= | last post by:
Hi, I'm wondering if you can help. We have a classic asp application that creates and posts some XML using the SOAP format to a .NET WebService. The WebService and the asp are on the same IIS...
4
by: gengyue | last post by:
Hi, I need to call .Net webservice from my JSP page. My application is Struts application. It is deployed on Oracle application server. Here is the whole process. I have a login form. When user...
4
by: gengyue | last post by:
Hi, I need to call .Net webservice from my JSP page. My application is Struts application. It is deployed on Oracle application server. Here is the whole process. I have a login form. When user...
0
by: gengyue | last post by:
Hi, Refer to my previous post "Calling web serive from JSP", I found an article on msfn2.microsoft.com. "Using the WebService behavior, it is not possible to call a remote method directly on a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.