473,854 Members | 1,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Joi n();

}

if (disposing)

{

if (components != null)

{

components.Disp ose();

}

}

base.Dispose(di sposing);

}
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.Joi n()

End If

If disposing Then

If Not (components Is Nothing) Then

components.Disp ose()

End If

End If

MyBase.Dispose( disposing)

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

"Howard Kaikow" <ka****@standar ds.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.Joi n();

}

if (disposing)

{

if (components != null)

{

components.Disp ose();

}

}

base.Dispose(di sposing);

}
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******** ******@TK2MSFTN GP12.phx.gbl...
Howard,

"Howard Kaikow" <ka****@standar ds.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.Joi n();

}

if (disposing)

{

if (components != null)

{

components.Disp ose();

}

}

base.Dispose(di sposing);

}
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******** ******@TK2MSFTN GP12.phx.gbl...
Howard,

"Howard Kaikow" <ka****@standar ds.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.Joi n();

}

if (disposing)

{

if (components != null)

{

components.Disp ose();

}

}

base.Dispose(di sposing);

}
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****@standar ds.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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******** ******@TK2MSFTN GP12.phx.gbl...
Howard,

"Howard Kaikow" <ka****@standar ds.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.Joi n();

}

if (disposing)

{

if (components != null)

{

components.Disp ose();

}

}

base.Dispose(di sposing);

}
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****@standar ds.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******** ******@TK2MSFTN GP14.phx.gbl...
Howard,

"Howard Kaikow" <ka****@standar ds.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.Disp ose()
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.Disp ose();
}
}
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******** ******@TK2MSFTN GP15.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.Disp ose()
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.Disp ose();
}
}
base.Dispose( disposing );
}
///

Nov 21 '05 #9

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

Similar topics

3
6094
by: faktujaa | last post by:
Hi All, A small confusion. I have defined a connection class that has System.Data.IDbConnection as a member variable and implements IDisposable interface. I have implemented Dispose method to call Dispose method of IDbConnection. This Dispose method is called from a destructor. In the dispose method, i also call GC.SuppressFinalize(this) so as to avoid finalizer. All this was OK untill i came across one article that says - not to call...
4
1939
by: RiteshDotNet | last post by:
..net Frame work 1. Dispose Method what it does ? A. who its call / when it calls ? B. Is it fire automatically ? c. When dispose method is call what it does ? D. Release a Object from memory or release refrence from memory ? E. If it release object from memory then what GC does ? 2. Which class can have dispose method ? class which is member of IDispose Inteface 3. Where we should use abstract / Interface ?
16
4280
by: Daniel Mori | last post by:
If an object implements the IDisposable interface (regardless if its a framework object or a user object), should I always dispose of that object out of principle?
3
2083
by: Maxim | last post by:
Hi! According to documenation, if we need to release some umanaged resources manually, we need to implement IDisposable interface with single Dispose method. I am just wondering, what will happen if I just create my own Dispose (or any other name) mehtod, without implementing the IDisposable interface. In all the examples, which I found, this Dispose method called from my user code (not by GC). What do I miss? Thanks.
1
1737
by: Billy | last post by:
Hello... I'm trying to make a database access class for an asp.net application. When I run my application, the Garbage Collecter doesn't seems to unload the memory attributed to my SQLConnection. My db access class has a method that returns a dataset and one that executes a non-reader request. It also has a dispose method (to release the connection) that I call in the finalize method of my aspx pages(as learn in "Implementing...
7
2101
by: Scott M. | last post by:
In a typical class, do I need to indicate that it implements the IDisposable interface and then create a Dispose method that implements the Dispose required by the IDisposable interface or can I just make a Sub Dispose() and the CLR will know that this is the Dispose method to call when the object falls out of scope? Thanks.
6
1817
by: Teresa | last post by:
1) If I do want to keep an object alive throughout the live of an application, how can I ensure that the GC doesn't clean it up? 2a) How do I determine if an object is a managed or an unmanged resource? I understand the basic definition for managed resources are resources that the CLR manage and unmanged resources are resources that the CLR doesn't manage, however, I haven't been able to find a concrete answer as to what resources are...
156
5955
by: Dennis | last post by:
Ok, I'm trying to dispose of every object that I create that has a dispose method based on advice from this newsgroup. However, I'm not sure how to dispose of the following object that was created inside a method call. dim myvar as new object1 object1.dosomethingmethod(new object2) Note that object 2 has a dispose method but how do I dispose of it unless I do the following:
71
10786
by: active | last post by:
In the main program I check to see if a certain form has been disposed. Does it make sense in that form's FormClosed event to do: Me.Dispose to make sure it is disposed the next time I check. Or is that automatic? Thanks
0
9901
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
9751
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
11024
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
9510
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...
1
7910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5738
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
5937
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4550
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
3
3183
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.