469,356 Members | 1,999 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Dispose method: Converting from C# to VB .NET

I've been trying to convert the following C# Dispose to VB .NET:
protected override void Dispose(bool disposing)

{

if (excelThread != null)

{

excelThread.Join();

}

if (disposing)

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose(disposing);

}
Using the code below following, I get the error:

Method 'Dispose' has multiple definitions with identical signatures

What am I doing wrong?
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If Not (excelThread Is Nothing) Then

excelThread.Join()

End If

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub
--
http://www.standards.com/; See Howard Kaikow's web site.
Nov 21 '05 #1
8 8000
Howard,

"Howard Kaikow" <ka****@standards.com> schrieb:
I've been trying to convert the following C# Dispose to VB .NET:
protected override void Dispose(bool disposing)

{

if (excelThread != null)

{

excelThread.Join();

}

if (disposing)

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose(disposing);

}
Using the code below following, I get the error:

Method 'Dispose' has multiple definitions with identical signatures

What am I doing wrong?
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)


Where did you add the 'Dispose' method? Typically, forms, usercontrols,
etc. have an automatically generated 'Dispose' method which is part of the
"designer generated code" region. You may want to add the code to the
'Dispose' method of the designer generated code instead of adding your own
'Dispose' method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
I thought about doing that, but the C## code did not do that, so I didn't
try.

I guess VB .NET could be doing things differently, I'll take a look.

--
http://www.standards.com/; See Howard Kaikow's web site.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eX**************@TK2MSFTNGP12.phx.gbl...
Howard,

"Howard Kaikow" <ka****@standards.com> schrieb:
I've been trying to convert the following C# Dispose to VB .NET:
protected override void Dispose(bool disposing)

{

if (excelThread != null)

{

excelThread.Join();

}

if (disposing)

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose(disposing);

}
Using the code below following, I get the error:

Method 'Dispose' has multiple definitions with identical signatures

What am I doing wrong?
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)


Where did you add the 'Dispose' method? Typically, forms, usercontrols,
etc. have an automatically generated 'Dispose' method which is part of the
"designer generated code" region. You may want to add the code to the
'Dispose' method of the designer generated code instead of adding your own
'Dispose' method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
Ayup, that was the problem.

I guess the original C# may also have had a Dispose in the Designer, but the
author may have removed the critter.

In any case anyone's interested, I took an extra dose of my masochist
medication, I am working thru Andrew Whitechapel's book MSFT .NET
Development for MSFT Office and converting the code to VB .NET. Al the
book's code is C#, other than, as I recall, 2 examples/

A very painful exercise.
But I'm learning a lot.

--
http://www.standards.com/; See Howard Kaikow's web site.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eX**************@TK2MSFTNGP12.phx.gbl...
Howard,

"Howard Kaikow" <ka****@standards.com> schrieb:
I've been trying to convert the following C# Dispose to VB .NET:
protected override void Dispose(bool disposing)

{

if (excelThread != null)

{

excelThread.Join();

}

if (disposing)

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose(disposing);

}
Using the code below following, I get the error:

Method 'Dispose' has multiple definitions with identical signatures

What am I doing wrong?
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)


Where did you add the 'Dispose' method? Typically, forms, usercontrols,
etc. have an automatically generated 'Dispose' method which is part of the
"designer generated code" region. You may want to add the code to the
'Dispose' method of the designer generated code instead of adding your own
'Dispose' method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
It appears that C# does not hide the Dispose in the Designer, instead the
dispose is generated outside the Designer.

VB .NET just does this the other way.

Seems like quite a needless difference between the two languages for code
generation.
--
http://www.standards.com/; See Howard Kaikow's web site.
"Howard Kaikow" <ka****@standards.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Ayup, that was the problem.

I guess the original C# may also have had a Dispose in the Designer, but the author may have removed the critter.

In any case anyone's interested, I took an extra dose of my masochist
medication, I am working thru Andrew Whitechapel's book MSFT .NET
Development for MSFT Office and converting the code to VB .NET. Al the
book's code is C#, other than, as I recall, 2 examples/

A very painful exercise.
But I'm learning a lot.

--
http://www.standards.com/; See Howard Kaikow's web site.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eX**************@TK2MSFTNGP12.phx.gbl...
Howard,

"Howard Kaikow" <ka****@standards.com> schrieb:
I've been trying to convert the following C# Dispose to VB .NET:
protected override void Dispose(bool disposing)

{

if (excelThread != null)

{

excelThread.Join();

}

if (disposing)

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose(disposing);

}
Using the code below following, I get the error:

Method 'Dispose' has multiple definitions with identical signatures

What am I doing wrong?
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)


Where did you add the 'Dispose' method? Typically, forms, usercontrols,
etc. have an automatically generated 'Dispose' method which is part of the "designer generated code" region. You may want to add the code to the
'Dispose' method of the designer generated code instead of adding your own 'Dispose' method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #5
Howard,

"Howard Kaikow" <ka****@standards.com> schrieb:
It appears that C# does not hide the Dispose in the Designer, instead the
dispose is generated outside the Designer.

VB .NET just does this the other way.

Seems like quite a needless difference between the two languages for code
generation.


ACK. I would prefer the way C# handles it in VB.NET too :-).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #6
Clear evidence of a lack of proper design/review/control processes within
MSFT.
--
http://www.standards.com/; See Howard Kaikow's web site.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O8**************@TK2MSFTNGP14.phx.gbl...
Howard,

"Howard Kaikow" <ka****@standards.com> schrieb:
It appears that C# does not hide the Dispose in the Designer, instead the dispose is generated outside the Designer.

VB .NET just does this the other way.

Seems like quite a needless difference between the two languages for code generation.


ACK. I would prefer the way C# handles it in VB.NET too :-).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #7
Howard,

Bellow are the standard conponent disposes methods from VBNet and C#. I do
not see any difference. With the exception that it is in VBNet hidden in the
windows for designer code and in C# outside that.

I hope this helps?

Cor

\\\
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub _
Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
///
\\\
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
///
Nov 21 '05 #8
Thanx.

The problem was that the author of the C# code had removed the Dispose in
the DEsigner, so when I was converting the code to VB .NET, I missed that
there might be a Dispose in the Designer.

Oh well, we have Disposed this topic.

--
http://www.standards.com/; See Howard Kaikow's web site.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:OV**************@TK2MSFTNGP15.phx.gbl...
Howard,

Bellow are the standard conponent disposes methods from VBNet and C#. I do
not see any difference. With the exception that it is in VBNet hidden in the windows for designer code and in C# outside that.

I hope this helps?

Cor

\\\
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub _
Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
///
\\\
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
///

Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by RiteshDotNet | last post: by
3 posts views Thread by Maxim | last post: by
1 post views Thread by Billy | last post: by
6 posts views Thread by Teresa | last post: by
156 posts views Thread by Dennis | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.