Im trying to use an external DLL and extract data from the dll. my code is as follows:
myMethod should return a Zero "0". but when I run it I get an error message "vshost.exe has stopped working". - namespace WindowsFormsApplication1
-
{
-
public partial class Form1 : Form
-
{
-
[DllImport("c:\\Program Files\\DHI\\Calibration\\muEpanet2.dll")]
-
public static extern long myMethod (ref string F1, ref long F2, ref long F3);
-
-
-
public Form1()
-
{
-
InitializeComponent();
-
}
-
-
private void button1_Click(object sender, EventArgs e)
-
{
-
long errorCode;
-
string fileLocation = "c:\\base_zk-M1.res";
-
long secondParameter = 13;
-
long thirdParameter = 0;
-
-
-
errorCode = myMethod (ref fileLocation, ref secondParameter, ref thirdParameter);
-
}
-
-
}
thanks so much for your help.
7 2461 tlhintoq 3,525
Recognized Expert Specialist TIP: When you first created your question you were asked to wrap your code with [code] tags. It really does help a bunch. Look how much easier it is to read now that someone has done it for you. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
I am trying to get a method out of a C++ dll in C#. Can anybody help me I can't extract the method myDll which takes 3 parameters (string, long, long). I get an error message "vshost.exe stopped working " Can anybody tell me what's wrong with the code below. - namespace WindowsFormsApplication1
-
{
-
public partial class Form1 : Form
-
{
-
// here I call the external dll including its method MUEpanet_RES_Load2Mem_InitHeader
-
[DllImport(@"c:\Program Files\DHI\Calibration\muEpanet2.dll")]
-
private static extern long myDll(string F1, long F2, long F3);
-
-
public Form1()
-
{
-
InitializeComponent();
-
}
-
-
private void button1_Click(object sender, EventArgs e)
-
{
-
long errorCode;
-
string fileLocation = @"c:\list.xml";
-
long secondParameter = 13;
-
long thirdParameter = 0;
-
-
errorCode = myDll(fileLocation, secondParameter, thirdParameter);
-
}
-
}
-
}
Thanks in advance.
I have the following code in VBA I would like to convert the same code to C#. the VBA codes calls a c++ dll which includes method myMethod. Thanks so much for your help. - Private Declare Function myMethod Lib "c:\myDLL.dll" (ByVal F1 As String, ByVal F2 As Long, ByVal F3 As Long) As Long
GaryTexmo 1,501
Recognized Expert Top Contributor
I think this might be the same as [DllImport] in C#. Try googling that :)
Actually, your other thread uses it... so while I'm not 100% sure, that VB code looks to be the equivalent.
@GaryTexmo
Yes, I google it and my code is OK... but I just can't see what it doesn't work.
@danmoran
@GaryTexmo Yes, I google it and my code is OK... but I just can't see why my code doesn't give me the results I expect from the DLL
tlhintoq 3,525
Recognized Expert Specialist
Please don't TRIPLE-post your questions. It divides attempts to help you in an organized and cohesive manner. Your threads have been merged
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: public heath vb developer |
last post by:
We have a solution with 29 projects including a main menu and 28 dlls. One of the projects (Project B) was created by copying an existing project (Project A), making changes including the assembly...
|
by: Rudy Ray Moore |
last post by:
How can I modify the project build order of a multi-project workspace under
"Visual Studio .net 2003 7.1 c++"?
I tried to modify the .sln by hand to influence the build order, but it
didn't seem...
|
by: Jerad Rose |
last post by:
Hello,
I have searched all over for the answer to this, to no avail. I have a web
project already set up and running on a remote server, that I created from
my home computer. I am now trying...
|
by: Dave |
last post by:
I copied the project files from an ASP.NET project on one computer and want
to create the project on another computer,
There is no connection between the two computers so I simply copied the...
|
by: Brad |
last post by:
I'm not one to rant or flame....so please excuse me while I do so for this
once. I've now spent a bit of time working with VS2005 beta 2 to see how it
functions for web development, especially how...
| |
by: Mantorok |
last post by:
Hi all
We have an ASP.Net project (and the Solution) under source-control.
Here is the example - I create the Solution, I create an ASP.Net project and
then check it all in to source control,...
|
by: liu |
last post by:
Hi all,
in my vb.net solution, i have 3 project:
1. Main-this is the startup or the base of my window application.
2. Sales-this is the project that contains all the sales info
3. Product-this...
|
by: Anubhav Jain |
last post by:
Hi,
I am having few .net source files(.cs or .vb) and I want to dynamically generate the corresponding .net project file(.csproj or .vbproj) for them without using visual studio.So that I could...
|
by: Jerad Rose |
last post by:
This is regarding Visual Studio 2003 (framework 1.1). We have several
projects/libraries. Of course, many of these reference each other. If we
only had one solution, we would simply add all of...
|
by: Tony Girgenti |
last post by:
Hello.
I'm developing and testing a web application using VS.NET 2003, VB, .NET
Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2
computer. I'm using a web form.
How do I...
|
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,...
| |
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...
|
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...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |