|
Hi!
I suggest you don't rely on a certain order of finalization (which is almost always a bad idea) but rather implement IDisposable and perform your cleanup in Dispose() .
Regards,
mav
|
|
|
|
|
Bob Stanneveld wrote: How do I make sure that my object is finalized before the system resources?
That's not possible. In fact, members of an object might get finalized before the object itself.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi community!
I'd be happy if someone could give me some input on an idea I've been juggling with for some time:
I've got a single instance WindowsForms application (.NET 1.1) that's been working fine for quite some time now.
Now I'd have to make some of the functionality available for COM clients, but I can't seem to figure out how to start.
I know how to create a class library with COM visible classes, but instances of these classes will be created inside the calling process, so I can't call methods in my application to show some dialogs, for example.
As far as the idea has evolved, I'd have to make my application an out-of-process COM server, but I'm afraid I don't know how to achieve this.
Any input would be highly appreciated.
Thanks,
mav
|
|
|
|
|
Hi guys;
I have a flash object on a form and I have added a Class to my app.
I want to call the SetVariable() method of the flash object from the class and get some info from the flash obj.
there is a FScommand related to the flash obj when the SetVariable() is called flash transfers the data to the FScommand event of the flash obj inside my form.
Its all fine when I use the SetVariable() method from inside the form but when I call it from the class it just passes the command and nothing happens.
What should I do to get the FScommand event to work from the Class I have.
PLEASE HELP ITS VERY URGENT.
Thanks
Riazi
|
|
|
|
|
Hi
Using Microsoft.ink...I have to draw a image in the form and save that image in .jpeg format.....So i haveto install Microsoft Tablet pc.....
so finally I installed ... and i did a program with 2 buttons in the form namely SAVE and EXIT......
so now when i run this program..i can able to draw a image of my own in the form..now when i click save button...i should be able to save the image in .jpeg format.. BUT I couldnt save.. when i click the SAVE button..and give a name for the image .... an error is shown...
ERROR MESSAGE:
System.NullReferenceException: Object reference not set to an instance of an object.
at InkImage.Form1.button2_Click(Object sender, EventArgs e) in d:\inkimage\form1.cs:line 144..
ie, error in the last line of this program [ DrawArea.Save( sfd.FileName, format );]
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.Ink;
using System.IO;
namespace InkImage
{
public class Form1 : System.Windows.Forms.Form
{
// Declare the Ink Collector object
private InkCollector myInkCollector;
private const float ThinInkWidth = 50;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private Bitmap DrawArea;// make a persistent drawing area
private void Form1_Load(object sender, System.EventArgs e)
{
// Create a new ink collector and assign it to this form's window
myInkCollector = new InkCollector(this.Handle);
// Set the pen width to be a width
myInkCollector.DefaultDrawingAttributes.Width = ThinInkWidth;
// Turn the ink collector on
myInkCollector.Enabled = true;
}
//EXIT BUTTON
private void button1_Click(object sender, System.EventArgs e)
{
myInkCollector.Enabled = false;
this.Dispose();
}
//SAVE BUTTON
private void button2_Click(object sender, System.EventArgs e)
{
ImageFormat format = ImageFormat.Jpeg;
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "JPEG Files(*.jpg)|*.jpg";
if (sfd.ShowDialog() == DialogResult.OK)
{
// now save the image in the DrawArea
DrawArea.Save( sfd.FileName, format );
}
}
}
}
please help me to get the solution......
D h o l
|
|
|
|
|
I am using a library built by some other person. It has various arguments......
The below mentioned function had been implemented by someone in .NET and I am using that library:
list(java.lang.String userName, java.lang.String password,java.lang.String role, java.lang.String langpref,int parentid,int[] orderId,int[] resellerId,int[] customerId, boolean showChildOrders,java.lang.String[] domainType,java.lang.String[] currentStatus,java.lang.String description,java.lang.String creationDTRangStart,
java.lang.String creationDTRangEnd,java.lang.String endTimeRangStart,java.lang.String endTimeRangEnd,
int numOfRecordPerPage,int pageNum,java.lang.String[] orderBy)
The problem is that I have only one reseller ID that is 40...
when I provide the seventh argument as 40, then I get error as:
Argument '7': cannot convert from 'int' to 'int[]'
Plz suggest any way to convert int to int[]
Thanks,
Sandeep
+919891027854
|
|
|
|
|
Just wrap the int in an array.
Like this
int []arr = new int[] {resellerID};
I'm a 23 yrs old developer working with HCL Technologies, Chennai. I'm currently working in C#, C++, but I've done some Java programming as well.
You can read My Blog here. I've also done some open source software, like WinMacro - A open source macro recorder/player for Windows, A Chess Game with AI that I wrote in college and Winbots - a game for programmers.
|
|
|
|
|
Hi i am pasting my code belo which is giving error
System.NullReferenceException' occurred in
Additional information: Object reference not set to an instance of an object.
it breaks on line
if(cl[i].status==true) in listen class
code for listen class
public class listen
{
TcpListener server=null;
Thread tcpthread=null;
client[] cl=new client[5];
public listen()
{
//
// TODO: Add constructor logic here
//
}
public void startlisten()
{
Int32 port = 3310;
IPAddress localAddr = IPAddress.Parse("192.168.0.5");
// TcpListener server = new TcpListener(port);
server = new TcpListener(localAddr, port);
// Start listening for client requests.
server.Start();
// Enter the listening loop.
// for(int i=0;i<5;i++)
// {
// cl[i].status=true;
// }
Boolean flag;
while(true)
{ flag=false;
// Perform a blocking call to accept requests.
// You could also user server.AcceptSocket() here.
for(int i=0;i<5;i++)
{
if(cl[i].status==true)
{
cl[i]= new client(server.AcceptTcpClient());
tcpthread=new Thread(new ThreadStart(cl[i].getClient));
tcpthread.Start();
flag=true;
break;
}
}
if(flag!=true)
{
//display error message
}
}
}
}
code for client class
public class client
{
TcpClient tcpClient;
public Boolean status;
// Buffer for reading data
Byte[] bytes = new Byte[256];
String data = null;
public client()
{ //
// TODO: Add constructor logic here
//
//status=true;
}
public client(TcpClient Client)
{
tcpClient =Client;
//
// TODO: Add constructor logic here
//
status=false;
}
public void getClient()
{
try
{
data = null;
// Get a stream object for reading and writing
NetworkStream stream = tcpClient.GetStream();
int i;
// Loop to receive all the data sent by the client.
while((i = stream.Read(bytes, 0, bytes.Length))!=0)
{
// Translate data bytes to a ASCII string.
data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
// Process the data sent by the client.
string replyMsg = data;
clamdCommand x=new clamdCommand();
replyMsg=x.Command(replyMsg);
byte[] msg = System.Text.Encoding.ASCII.GetBytes(replyMsg);
// Send back a response.
stream.Write(msg, 0, msg.Length);
//Console.WriteLine(String.Format("Sent: {0}", data));
}
}
catch(Exception se)
{
MessageBox.Show(se.ToString());
}
// Shutdown and end connection
tcpClient.Close();
status=true;
}
}
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Please format your code snippets using PRE and CODE blocks. It makes it easier for people to help you.
The problem is that client[] cl=new client[5]; merely creates an array of 5 references to client objects. It does NOT create 5 client objects. So, before you do anything at all with your array, you should do
for(int i = 0; i < cl.Length; i++)
{
cl[i] = new client();
}
Typically, this code should go in the ctor of the class which contains the array, in this case, listen .
Cheers,
Vikram. "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
|
|
|
|
|
Tthanks
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
well here is the description of my problem
I have a component in which all the methods are static let
the skeleton is like below
public Class Component
{
.............
.........
.......
public static void St_F1(--,--,--)
{
--- -
---
--
}
public static void St_F2(--,--,--)
{
--- -
---
--
}
public static void St_F3(--,--)
{
--- -
---
--
}
public static void St_F4(--)
{
--- -
---
--
}
}
//////////////////
now these functions are called in other class MyClass in
the delegate MyDlg that is called when the Capture event
occurs
public Class MyClass
{
----
----
private Scanner myobj=new Scanner();
myobj.Capture+=new CaptureEventHandler(MyDlg);
private void MyDlg(---,--,---)
{
Componet.St_F4(--);
Componet.St_F1(--,--,---);
if(myobj.id==1)
Componet.St_F3(---,--);
if(myobj.id==2)
Componet.St_F2(--,--);
}
}
////////////////////////
Now i make 2 objects of MyClass each of them has a unique
value of myobj.id
MyClass ClassObj1=new MyClass();
MyClass ClassObj2=new MyClass();
Now both of these instances of the MyClass have to call
event myobj.Capture+=new CaptureEventHandler(MyDlg);
implicitly nad may be event occurs from both objects at a time i want to make the call to the each Static Function called in the body of MyDlg synchronized. So as Only one object may call the Static function at a time. How to achieve this. Plz help Me
Thnx in Advance
|
|
|
|
|
Does locking/Monitor.Enter(), Monitor.Exit()[^] on a static object solve your problem?
public class Component
{
private static object syncObject = new object();
public static void ST_F1()
{
lock(syncObject)
{
...
}
}
public static void ST_F2()
{
lock(syncObject)
{
...
}
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Actually i forgot to mention one more thing , The component class is only a sketch to understand , in real i m using these static function form a dll named Component. for which i dont have acess to implementation code of these Static function.i m just using the functionality.
So if there is any other possibility plz let me know.
Thnx
|
|
|
|
|
You can create a static object in the event handler class instead.
Something like
class XYZ
{
static object syncObject = new object();
void SomeMethod()
{
abc.SomeEvent += new SomeEvent(SomeEventHandler);
}
void SomeEventHandler(...)
{
lock(syncObject)
{
Component.Method1();
...
}
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Well!
First of all thnx for Reply. Ok i m already calling these functions in the delegate MyDlg that is called whenevr Capture event occurs then how can i add an other event handler and call these functions. may i do this as below
myobj.Capture+=new CaptureEventHandler(MyDlg);
static object syncObject = new object();
private void MyDlg(---,--,---)
{
lock(syncobject);
Componet.St_F4(--);
lock(syncobject);
Componet.St_F1(--,--,---);
if(myobj.id==1)
lock(syncobject);
Componet.St_F3(---,--);
if(myobj.id==2)
lock(syncobject)
Componet.St_F2(--,--);
}
|
|
|
|
|
If you lock each function call, then at any point in time, only one thread could be executing a function. Which is what you want, so yes, it works. But there is a difference between the behavior of
private void MyDlg(---,--,---)
{
lock(syncObject)
{
Componet.St_F4(--);
Componet.St_F1(--,--,---);
Componet.St_F3(---,--);
}
}
and your code. The code above makes sure that at one point, only one thread can execute the whole sequence of functions (F4, F1, F3...). So if you have two threads, they will run like
Thread1
-------
Component.ST_F4
Component.ST_F3
Component.ST_F1
Thread2
-------
Component.ST_F4
Component.ST_F3
Component.ST_F1
With your code, the behaviour *could* be
Thread1
-------
Component.ST_F4
Thread2
-------
Component.ST_F4
Thread1
-------
Component.ST_F3
Component.ST_F1
Thread2
--------
Component.ST_F3
Component.ST_F1
Or in any order. If you're fine with that, go ahead.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thnx for reply!
I m almost very near to my solution. Ok What i want is that two threads could have acess to static functions at one time but these function should be different. that means let thread t1,t2 may have acess to static function Componet.St_F4(--);
Componet.St_F1(--,--,---); respectively. that is
t1---->Componet.St_F4(--);
t2--->Componet.St_F1(--,--,---);
is it so as i did b4. or how to achieve this
|
|
|
|
|
My DataGrid has DataSource with 2 related data tables:
A --> B. When I expand A's row, DataGrid display relation name, then I click on Relation name, Data Grid display ralated B's rows.
But I don't want to display relation name before display related child table's rows.
How can I do?
dhtuan
|
|
|
|
|
I'm writing an app in C# .net 2.0. I want to have a TreeView where the first
level of nodes would have check boxes, but their subsequent children would
not have check boxes.
Is this achievable using the .net controls? If not, how can I make this
possible?
Thanks,
Andy
|
|
|
|
|
Simple question really, I am fairly certain the answer is no.
Are there any cryptography systems out there that support skeleton keys?
i.e. A group of users all have there own "private key" which is used to encrypted data, but an administrator has a skeleton key that is capable of decrypting anything encrypted by the users regardless of the private key they use.
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
Have you google'd around on this? I am not sure if it is possible...
PC
|
|
|
|
|
Does anyone have a method for retrieving the 'real' hardware serial number of a hd without requiring administrator rights?
There is an article on this site which uses win32_physicalmedia to obtain the serial, but this doesn't work without admin rights.
I have heard that its possible through a windows api? but how?
Any help much appreciated.
|
|
|
|
|
Hi, Im developing a localizable aplication, so I add language support to my forms a and dialog messages whit resx files.
all is good but if I change something in my forms i miss some messages and control language definations in resx files.
So, what can i do?
Ho do you implement localizable languanges in your applications.
I use VS.c# 2005 express.
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
For serious use buy a localization tool. It will track deltas, carry over resize, protect against changes on data that is not localizable (as Microsoft pretty much managed to make one of the worst beginner misktakes when designing the resx format - they did not separate translatable strings from strings that should be changed by engineers/programmers).
If it is a small home project you probably have to do it the hard way - manually. VS really isn't meant as a localization environment for anything but small hobby use.
|
|
|
|
|
Thank you!
Is sad to hear that but I think is true too.
My project is a framework for business aplications, so I will study the tools that are n market or I will make somethig for my needs (read, write, import, export resx files for control.text properties,tooltips,helpstrings and custom messages strings)
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|