473,401 Members | 2,068 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,401 software developers and data experts.

Calling a Win32 Dll

Hi,

I need a function call in my xml web service. I have an old win32 dll and i
have created a class to have my declaration in.

Imports System.Runtime.InteropServices

[...]

Public Class Win32
<Declaration>
End Class
Public Class myClass
Dim objW32 as new Win32()
sRet = objW32.myFunction()

[...]
End Class

If i declare the library with:
Declare Function calcular_firma Lib "c:\VInetRT\componentes\libtpv.dll" (
....params...) as short

i get ERROR: 91 "Referencia a objeto no establecida como instancia de un
objeto."
mmm ... i guess this is like: "Object not set ..."

And if i use the declaration:
<DllImport("c:\VInetRT\componentes\libtpv.dll")> _
Public Function calcular_firma( ...params... ) As Short
End Function

i get: ERROR 5: "Error: el elemento PInvoke (campo,método) debe ser
estático."
Something like "PInvoke element must be static"
Did anybody deales with this ??
Thank you in advance
Jul 21 '05 #1
5 2490
Max
> i get: ERROR 5: "Error: el elemento PInvoke (campo,método) debe ser
estático."
Something like "PInvoke element must be static"


All functions with DllImport attribute must be declared with "Shared"
keyword
Jul 21 '05 #2
Thank you for your answer,

I added de "Shared" keyword, but the problem remains
:(

91 "Referencia a objeto no establecida como instancia de un
objeto."
my translation: "Objet reference nos stablished as an object instance"

Best
"Max" <te**@you.later> escribió en el mensaje
news:#W**************@tk2msftngp13.phx.gbl...
i get: ERROR 5: "Error: el elemento PInvoke (campo,método) debe ser
estático."
Something like "PInvoke element must be static"


All functions with DllImport attribute must be declared with "Shared"
keyword

Jul 21 '05 #3
Max
> Thank you for your answer,

I added de "Shared" keyword, but the problem remains
:(

91 "Referencia a objeto no establecida como instancia de un
objeto."
my translation: "Objet reference nos stablished as an object instance"

Show your code, maybe we will find the solution
Jul 21 '05 #4
The problem were that the function needed one of the params as s fixed
length string, and when i used the migration wizard from VB6, this was
modified.

I did a little routine form dimension the string to a size needed, and it
works !
So the sentence "Declare Function" was enough, but ..

How can i define a fixed lenght string in VB.NET ??? :-)

Thank you for your help.
"Max" <te**@you.later> escribió en el mensaje
news:Ox**************@TK2MSFTNGP12.phx.gbl...
Thank you for your answer,

I added de "Shared" keyword, but the problem remains
:(

91 "Referencia a objeto no establecida como instancia de un
objeto."
my translation: "Objet reference nos stablished as an object instance"

Show your code, maybe we will find the solution

Jul 21 '05 #5
Max

"nbotw" <nb***@world.net> wrote in message
news:#R**************@TK2MSFTNGP10.phx.gbl...
The problem were that the function needed one of the params as s fixed
length string, and when i used the migration wizard from VB6, this was
modified.

I did a little routine form dimension the string to a size needed, and it
works !
So the sentence "Declare Function" was enough, but ..

How can i define a fixed lenght string in VB.NET ??? :-)

Try to experiment with MarshalAs attribute
Don't know how to write it in VB, so C#: [MarshalAs(UnmanagedType.(try here
some variations), SizeConst=8)]
Jul 21 '05 #6

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

Similar topics

8
by: Patrick Useldinger | last post by:
Hi all, I am looking for beta-testers for fdups. fdups is a program to detect duplicate files on locally mounted filesystems. Files are considered equal if their content is identical,...
3
by: gerald.maher | last post by:
I am trying to run an Corba example using Python and i get the follwing error: import _omnipy ImportError: No module named _omnipy Where can i find this Module ?
0
by: Dale McGorman | last post by:
The following is some code that I am trying to bring over from VB 6.0, that I have working there. I am trying to get to where I can talk to a USB device. I am stuck on how to correctly pass params...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
1
by: Wilfried Mestdagh | last post by:
Hi, I have a few related questios: 1. if I pass a string to win32 api (or other dll not written in .net), is it possible GC cleans up while function is still busy ? eg: public class Win32...
11
by: j23 | last post by:
I have library (static) testlib.cpp: #include <stdarg.h> void xxx(...) { char buf; va_list args; va_start(args, buf); va_end(args); }
0
by: Scott Gunn | last post by:
Hello I'm trying to scroll a region of graphics, the best way I can see is to use the ScrollWindowEx API because it is designed for doing this However it doesn't work correctly, Why? Here...
5
by: nbotw | last post by:
Hi, I need a function call in my xml web service. I have an old win32 dll and i have created a class to have my declaration in. Imports System.Runtime.InteropServices Public Class Win32
2
by: Daniel Lidström | last post by:
I'm using a library called fyba. This library reads and writes files in a format called sosi. fyba uses the following code to determine if the calling process has own methods to handle errors,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.