473,670 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.myFuncti on()

[...]
End Class

If i declare the library with:
Declare Function calcular_firma Lib "c:\VInetRT\com ponentes\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\compone ntes\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 2511
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******** ******@tk2msftn gp13.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******** ******@TK2MSFTN GP12.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.ne t> wrote in message
news:#R******** ******@TK2MSFTN GP10.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(Unman agedType.(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
1463
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, regardless of their filename. Also, fdups ignores symbolic links and is able to detect and ignore hardlinks, where available. In contrast to similar programs, fdups does not rely on md5 sums or
3
8759
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
303
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 to the API call SetupDiGetDeviceInterfaceDetail() I can get it to actully not fail, and it actully tells me that it returned 87 bytes which is correct, but it never fills my structure of DeviceInterfaceDetail, and of course return value is a failure...
15
11762
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 performs the query is contained in a delegate function that I execute via a second thread. On 1 or 2 of the 600+ servers the query hangs. I've tried to use Thread.Join() coupled with a Thread.Abort() but this does not kill the thread. Based on...
1
1572
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
1962
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
1172
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 is my code: Public Class Win32
5
479
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
2815
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, messages, etc: // If this parameter is NULL, // GetModuleHandle returns a handle of the file used // to create the calling process. hInstExe = GetModuleHandle( NULL ); if( hInstExe!=NULL )
0
8466
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8384
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8659
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7412
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4388
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
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
2
1791
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.