Click here to Skip to main content
15,920,503 members
Home / Discussions / C#
   

C#

 
GeneralRe: DataGrid Event Pin
Mazdak22-Mar-02 7:51
Mazdak22-Mar-02 7:51 
GeneralRe: DataGrid Event Pin
Andres Manggini22-Mar-02 8:09
Andres Manggini22-Mar-02 8:09 
GeneralRe: DataGrid Event Pin
James T. Johnson22-Mar-02 14:37
James T. Johnson22-Mar-02 14:37 
GeneralRe: DataGrid Event Pin
Mazdak22-Mar-02 18:36
Mazdak22-Mar-02 18:36 
GeneralRe: DataGrid Event Pin
James T. Johnson22-Mar-02 21:20
James T. Johnson22-Mar-02 21:20 
GeneralRe: DataGrid Event Pin
Mazdak23-Mar-02 3:17
Mazdak23-Mar-02 3:17 
GeneralRe: DataGrid Event Pin
James T. Johnson23-Mar-02 14:34
James T. Johnson23-Mar-02 14:34 
GeneralValue null was found where an instance of an object was required Pin
Bob Plymale22-Mar-02 4:04
Bob Plymale22-Mar-02 4:04 
I am going to try this again. I have a dll which I can call in VB6 with no
problem. I am trying to convert all my code to c# but I am running into a
big problem with accessing dlls'.

The first time I posted this question no one could answer why I was getting
the error, so I will ask what is the error exactly. I have researched all
the wox books, microsoft and cannot find out what this error actually means
to give me a starting point for my resolution.

Here is my code:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace WindowsApplication20
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
[DllImport("Mydll.dll")]
public static extern int myOpen(string sFileName);

private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label1;


///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

public Form1()
{

//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(32, 88);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(408, 20);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "textBox1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(32, 48);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(104, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(32, 120);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(400, 20);
this.textBox2.TabIndex = 2;
this.textBox2.Text = "textBox2";
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 160);
this.label1.Name = "label1";
this.label1.TabIndex = 3;
this.label1.Text = "label1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(496, 373);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label1,
this.textBox2,
this.textBox1,
this.button1});
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

}

private void button1_Click(object sender, System.EventArgs e)
{
OpenFileDialog fdlg = new OpenFileDialog();
fdlg.Title = "C# Corner Open File Dialog" ;
fdlg.InitialDirectory = @"c:\" ;
fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*" ;
fdlg.FilterIndex = 2 ;
fdlg.RestoreDirectory = true ;
if(fdlg.ShowDialog() == DialogResult.OK)
{
label1.Text = myOpen(fdlg.FileName).ToString();
}

}
}
}

I am getting into the DLL with no problem, but once the call is made i
receive the:
"value null was found where an instance of an object was required"

The dll basically opens the file and will return a number 0-99, 0 meaning
unsuccessful and non 0 is successful.

I know I can open file in c# many different ways but I have several other
calls in the dll I use, but this is the simplest to diagnose.

Here is the header for vb6:
Declare Function myOpen& Lib "mydll.DLL" Alias "MYOPEN" (Filename$).

Any help would be appreciated, this is very frustrating.

Thanks,

Bob
QuestionClearing the console? Pin
Chris Masiero21-Mar-02 17:38
Chris Masiero21-Mar-02 17:38 
AnswerRe: Clearing the console? Pin
David Wengier21-Mar-02 17:46
David Wengier21-Mar-02 17:46 
GeneralRe: Clearing the console? Pin
Chris Masiero21-Mar-02 17:45
Chris Masiero21-Mar-02 17:45 
QuestionCreate guid in C#? Pin
21-Mar-02 11:54
suss21-Mar-02 11:54 
AnswerRe: Create guid in C#? Pin
Andres Manggini21-Mar-02 13:15
Andres Manggini21-Mar-02 13:15 
AnswerRe: Create guid in C#? Pin
James T. Johnson21-Mar-02 17:42
James T. Johnson21-Mar-02 17:42 
GeneralRe: Create guid in C#? Pin
Nish Nishant23-Mar-02 3:22
sitebuilderNish Nishant23-Mar-02 3:22 
QuestionDataList Multiple Selection? Pin
21-Mar-02 11:52
suss21-Mar-02 11:52 
GeneralListBox Multiple Selection Pin
21-Mar-02 10:53
suss21-Mar-02 10:53 
GeneralRe: ListBox Multiple Selection Pin
Andres Manggini21-Mar-02 11:24
Andres Manggini21-Mar-02 11:24 
GeneralRe: ListBox Multiple Selection Pin
21-Mar-02 11:59
suss21-Mar-02 11:59 
GeneralRe: ListBox Multiple Selection Pin
James T. Johnson21-Mar-02 17:46
James T. Johnson21-Mar-02 17:46 
GeneralRe: Thanks All, I got it work! Pin
22-Mar-02 2:54
suss22-Mar-02 2:54 
General.NET Benchmark Challenge Pin
Chris Maunder20-Mar-02 14:44
cofounderChris Maunder20-Mar-02 14:44 
GeneralRe: .NET Benchmark Challenge Pin
Andres Manggini20-Mar-02 15:43
Andres Manggini20-Mar-02 15:43 
GeneralRe: .NET Benchmark Challenge Pin
Chris Maunder21-Mar-02 0:11
cofounderChris Maunder21-Mar-02 0:11 
Generalcreating a control as a container (like SSTabs) Pin
20-Mar-02 5:32
suss20-Mar-02 5:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.