|
Thanks a lot Dear Friend. I really need it. Now I'll check it that how optimized that control is because I've seen a pannel control before that had some threading problem......
Any way really thanks for ur assistance.
God Bless You.
Syed Shahid Hussain
|
|
|
|
|
What would be the output of following question
<code>
using System;
namespace Statements
{
class Class1
{
public int Value = 0;
}
class Test
{
static void Main()
{
Class1 e = new Class1();
Class1 f = e;
e.Value = 1;
f.Value = 5;
Console.WriteLine(e.Value.ToString() + " " + f.Value.ToString());
Console.WriteLine((object)e.Value == (object)f.Value);
Console.WriteLine((object)e == (object)f);
Console.WriteLine(e == f);
Console.ReadLine();
}
}
}
</code>
try giving the output manually (i got it wrong )
And please explain your answer
|
|
|
|
|
When you instatiate f, f.value is = 0 and f acts as a pointer to object e.
e.Value = 1; does not have any impact and it Value takes the second assignment value.
therefore
e.Value = f.Value = 5
False
TREU
TRUE
|
|
|
|
|
Here's my answer (not tested):
5 5
False
True
True
5 5:
You instantiate one object, and reference it from two variables.
That's why when you change the Value field by either of the references the changes are "reflected" in the other reference variable.
False:
The Value field is a value-type member.
This means that casting it to an object, demands boxing, which results in the creation of two completly different objects, holding the same numeric value.
True:
It doesn't matter if you cast an object to its parent type.
It still points to the same object in memory.
So its simply doing a reference comparison.
True:
You set both reference variables to point to the same object in memory, and the "==" operator compares their references.
Corrections? Opinions?
Regards,
Shy.
|
|
|
|
|
Correct Answer is
5 5
False // here i was wrong
True
True
Thanks for Explanation
Regards
Amar
|
|
|
|
|
Hello,
If I serialize multiple objects to the same file, is it possible to somehow deserialize them not in the same order?
Thanks in advance,
Shy.
|
|
|
|
|
hi
i'm having a issue with memory management in a COM which uses MSXML (cause of memory leak)
if i use a c# wrapper around the COM which is then called from .net webservice will CLR take care of memory management for me( essentially Garbage collection)
if not by design can i force GC to take care of memory leaks in COM
this is very urgent, please help !
sorry i'm posting it in different forums at a time but hope you will see a desparation :->
|
|
|
|
|
The GC does not re-claim unmanaged memory.
Regards,
Shy.
|
|
|
|
|
thanks for the reply,
but can i force it in anyway, is it possible if i use COM as RCW
|
|
|
|
|
You cannot force the GC to collect objects from unmanaged memory.
The GC works only on objects created by the CLR.
Hence the expression "UNMANAGED memory".
If your COM object contains cleanup methods, use them.
logicaldna wrote: is it possible if i use COM as RCW
Sorry, but I don't think I know what RCW means...
Maybe someone else here can help you with that.
|
|
|
|
|
shyagam wrote: If your COM object contains cleanup methods, use them
i have tried all and even COuninitialize is not cleaning the memory dam this MSXML
thanks anyways
sagar
|
|
|
|
|
When using COM objects in C# setting an object to null isn't all that's required to signal it ready for Garbage Collection. First a call must be made to Marshal.ReleaseComObject(aComObjectVariable) to decrement it's reference counter in the RCW.
MSDN[^]
|
|
|
|
|
logicaldna wrote: i'm posting it in different forums at a time
That's not polite and it gets people ticked off and less likely to respond.
"You will see a delete button on each of your posts. Press it." - Colin Angus Mackay
|
|
|
|
|
Hi All,
I am new to c# and i am currently facing a problem in writing to a app config file.I am able to write to a config file if its read only access property is removed.Is there any way to give write permissions to the config file programatically.
Regards
DilipRam
|
|
|
|
|
try
File.SetAttributes(fileName, FileAttributes.Normal);
|
|
|
|
|
Thanks very much..Its working now
Regards
Dilip
Regards
DilipRam
|
|
|
|
|
HI,
i like to know two things :
1. how do i add an Attribute to the Propety grid.
2. how do i add the + in a specific Attribute.
TNKS
kobkob
|
|
|
|
|
I have a service loader that issues Trace.Writeline as the servicehosts are loaded. When I ran it under Windows XP everything works as expected. When I run it under Vista in debug mode, dbgView does not see the trace messages.
Does anyone know what I have to do from a policy end to get these messages viewable?
Thanks.
|
|
|
|
|
I have recently created a custom DataGridView column type (with my own custom cell type and custom control type inside).
I am trying to make my own custom events to go with the cell/column type, but apparently, the DataGridView was implemented quite strangely, and I'm getting event handlers that should be attached once become attached multiple times, never, or in an inconsistent manner.
Has anyone ever run into this before, and is there any good resource that could help me with this?
|
|
|
|
|
Hello,
I'm writting an application which check the dependency of imports. I have to register some typelibs for this import. After the analysis i want to unregister these typelibs.
But it doesn't work and I don't know why.
This is the exception: "The structure must not be a value class"
Please help me.
Here is my code that doesn't work
<br />
[DllImport("oleaut32.dll", CharSet = CharSet.Unicode, PreserveSig = false)]<br />
private static extern void UnRegisterTypeLib(Guid libID,<br />
ushort wVerMajor,<br />
ushort wVerMinor,<br />
LCIDConversionAttribute lcid,<br />
System.Runtime.InteropServices.ComTypes.SYSKIND syskind);<br />
<br />
<br />
<br />
[StructLayout(LayoutKind.Auto)] <br />
struct Attr <br />
{<br />
public Guid libID;<br />
public ushort wMajorVerNum;<br />
public ushort wMinorVerNum;<br />
public LCIDConversionAttribute lcid;<br />
public System.Runtime.InteropServices.ComTypes.SYSKIND syskind;<br />
}<br />
<br />
<br />
<br />
typeLib.GetLibAttr(out ppTLibAttr);<br />
<br />
Attr structTlb = new Attr();<br />
<br />
<br />
Marshal.PtrToStructure(ppTLibAttr, structTlb);<br />
<br />
UnRegisterTypeLib(structTlb.libID, <br />
structTlb.wMajorVerNum, <br />
structTlb.wMinorVerNum, <br />
structTlb.lcid, <br />
structTlb.syskind);<br />
I hope it helps?!
|
|
|
|
|
Another one. I would like to know how to add animation on my web page.
I'm using ASP.Net 2.0 (C#)
khuzym
|
|
|
|
|
What type of animations? There are multiple sources:
1) Animated GIFs
2) SWF (Flash Movies)
3) Javascript DHTML effects
|
|
|
|
|
This should be moved the ASP.NET forum
only two letters away from being an asset
|
|
|
|
|
Hi
Please help me. I am new to C# and SQL Server 2005, especially the exception handling side of things. Let me cut thru the chase
How do I get SQL Server 2K5 to return the details of errors that I generated with "RAISERROR" back to my C# app? When I run the application and a system error occurs, it's fine, I can catch it in my C# app, but I can't do the same with my custom errors. I hope this makes sense. Thank you.
|
|
|
|
|
To cite a RAISEERROR section from SQL Server 2005 online help:
"Calling RAISERROR with severity less than 20 from inside a remote stored procedure causes a statement abort error on the remote server. A TRY…CATCH construct on the local server handles remote batch abort errors only. If a remote stored procedure calls RAISERROR with severity less than 20 and the remote stored procedure is scoped within a TRY block on the local server, RAISERROR does not cause control to pass to the CATCH block of the TRY…CATCH construct. However, RAISERROR with severity 20 or greater on the remote server breaks the connection, and execution on the local server passes to the CATCH block."
Read following sections from SQL Server 2005 online help:
-RAISEERROR
-Using RAISERROR
-Database Engine Error Severities
OR
You can return custom error codes to your C# application using output parameters in stored procedures.
Decision is up to you.
|
|
|
|