I am working to a VB.NET windows forms projet in .NET 1.1. And I have this type of architecture, very simplified.
Public MustInherit Class BaseTestLogic
Private _TimerPoll As Timer
Public Sub New(ByVal sym As SymbolFileMng, ByVal cfg As LampTestConfig, ByVal daas As DaasManager, ByVal mcf As Elux.Wg.Lpd.MCFs.VMCF)
AddHandler ...
For simplicity.
I have a window, with a bindable usercontrol
<UserControl Content="{Binding Path = BindingControl, UpdateSourceTrigger=PropertyChanged}">
I have two user controls, ControlA, and ControlB, Both UserControls have their own Datacontext ViewModel, ControlAViewModel and ControlBViewModel.
Both ControlAViewModel and Contr...
Hi,
I have query regarding the disposing of an object. The scenario is as follows.
In a Desktop Appication, developed in C#, I have a function in which a object in created like this.
namespace Class 1
{
variables section;
....
....
Function1()
{
local variables;
try
{
Objec...
I used to be pretty sure the answer is "no", as explained in Overriding the Finalize method and Object.Finalize documentation.
However, while randomly browsing through FileStream in Reflector, I found that it can actually call just such a method from a finalizer:
private SafeFileHandle _handle;
~FileStream()
{
if (this._handle != ...
The Repository class has singleton behavior and the _db implements the disposable pattern. As excepted the _db object gets disposed after the first call and because of the singleton behavior any other call of _db will crash.
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class Repository : IRepository
{
...
How can I ensure the following code is disposing of all objects in a better fashion? Currently, Code Analysis is telling me
Error 45 CA2202 : Microsoft.Usage : Object 'ns' can be disposed more than once in method 'CPCommunicator.GetResults(string)'. To avoid generating a System.ObjectDisposedException you should not call Dispose mor...
I am trying to develop a Windows Mobile 6 (in WF/C#) application. There is only one form and on the form there is only a PictureBox object. On it I draw all desired controls or whatever I want.
There are two things I am doing. Drawing custom shapes and loading bitmaps from .png files.
The next line locks the file when loading (which i...
Hi folks,
What's the proper way of disposing resources when a method in the controller returns filestream or file or filecontentresult objects ?
For ex when doing something like below:
using CrystalDecisions.CrystalReports.Engine;
public ActionResult Report()
{
ReportClass rptH = new ReportClass();
rptH.FileName = Server....
I have a complex program in which I have to first create, then use wrappers around bitmaps and send them across a lot of different classes. The problem in the end is deciding which classes should dispose the bitmaps. Most of the time the end classes don't know if they can indeed dispose the bitmap as the same bitmap can be used in severa...
Hello,
I am returning the variable I am creating in a using statement inside the using statement (sounds funny):
public DataTable foo ()
{
using (DataTable properties = new DataTable())
{
// do something
return properties;
}
}
Will this Dispose the properties variable??
After doing this am still getting th...
We have Best practices on using disposable object in SharePoint.
But i`m thinking - can I skip these when using Console Application? That's some code I want to execute once and after that process has finished. Do or don't SPSite and SPWeb's remain opened somwhere?
Why i`m asking this? I just don't want to stress when using something l...
Should I call .Dispose() after returning an object that implements IDisposable?
myDisposableObject Gimme() {
//Code
return disposableResult;
disposableResult.Dispose();
}
In other words, is the object I return a copy, or is it the object itself? Thanks :)
...
Hi all,
I have an problem and would like to know if it is common problem or jsut with me. I am using Wpf with Prism and Unity, all with the pattern MvvM.
I am loading a viewModel that has a reference to a dropdown with few items, my idea is that each time that the user click in some place to open the view that has this dropdown is that...
"Collection was modified; enumeration operation may not execute." appears to be a common error with foreach loops, but I can't figure mine out. I have two classes of forms. One is begun on startup, and a button creates new instances of the second form, and displays them. When I close the secondary forms, I get an InvalidOperationExceptio...
According to [http://msdn.microsoft.com/en-us/library/system.threading.timer.aspx][1] you need to keep a reference to a System.Threading.Timer to prevent it from being disposed.
I've got a method like this:
private void Delay(Action action, Int32 ms)
{
if (ms <= 0)
{
action();
}
System.T...
I have a Visual Studio 2008 C# .NET 2.0CF application. I'm using a component base from which two concrete components are derived. The application first attempts to use SomeDisposableComponent. Its constructor throws an exception because it requires a feature that isn't available. Then, the application tries SomeOtherDisposableComponent. ...
If I have the following code, I have no runtime or compilation problems:
if (ConsoleAppBase.NORMAL_EXIT_CODE == code)
{
StdOut.WriteLine(msg);
}
else
{
StdErr.WriteLine(msg);
}
However, in trying to make this more concise, I switched to the following code:
(ConsoleAppBase.NORMAL_EXIT_CODE == code
? StdOut
: StdErr
).W...
C#: do you need to dispose of objects and set them to null, or will the garbage collector clean them up when they go out of scope?
...
The question I have might be more to do with semantics than with the actual use of IDisposable. I am working on implementing a singleton class that is in charge of managing a database instance that is created during the execution of the application. When the application closes this database should be deleted.
Right now I have this de...
I have a client-server application, in which I use classic Sockets and threads for receiving/sending data and listening for clients.
The application works fine, but after some random time I get the ObjectDisposedException:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'MainForm'.
at System.Windows.For...