|
Are you asking how to get an instance variable's name? For instance, if I wrote:
public void DoSomething()<br />
{<br />
string myFoo = new FooType();<br />
}
would you want to know, at serialization time, that the variable name was 'myFoo '? If so, what advantage does that provide?
In any case, I don't think that's possible at runtime. A quick look at the ILDASM (Intermediate Language) representation of the class above makes it clear that locally scoped member variable names are discarded in the compilation to IL.
It is probably important to note that the names of field-level variables, method names etc., whether public or private, are preserved during compilation, so technically you could use reflection to get the names.
However, if your class(es) implement the ISerializable interface (as opposed, or in addition to being marked with [SerializableAttribute] ), then you are free to develop your own serialization and deserialization plans for the class(es). The ISerializable interface exists to deal with just this kind of issue (provide developers with a way to prevent deserialization exceptions caused by versioning), among other things.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
You would have to manually parse the debugging information; which, of course, does not exist in release builds.
The best you could hope for is the address (using the &[^] Operator in an unsafe[^] context).
PeterRitchie.com
|
|
|
|
|
Hello,
I am trying to fix a memory retention problem for the statement
'return Bitmap.FromStream(new MemoryStream(buffer)) as Bitmap;'.
Since 'new MemoryStream(buffer) is created within the return, it does not release the memory.
I tried the following, but it does not return the Bitmap
using( MemoryStream ms = new MemoryStream(buffer) )
{
return Bitmap.FromStream( ms ) as Bitmap;
}
Any ideas on how to fix the memory retention problem
Thanks in advance
Robert
//////////////////// Code \\\\\\\\\\\\\\\\\\\\\
private Bitmap GetBitMapFromFile( string imageFileName )
{
byte[] buffer = null;
Stream stream = null;
try
{
stream = new FileStream(
imageFileName, // String Path
FileMode.Open , // FileMode
FileAccess.Read , // FileAccess
FileShare.Read , // FileShare
4096 , // bufferSize
true ); // useAsync
buffer = new byte[stream.Length];
stream.Seek(0,SeekOrigin.Begin);
stream.Read(buffer,0,(int)stream.Length);
}
catch( )// make simple for posting
{
}
finally
{
if( stream != null )
{
stream.Close();
}
}
// Memory Retention
// The new MemoryStream cause memory retention
return Bitmap.FromStream(new MemoryStream(buffer)) as Bitmap;
}
|
|
|
|
|
You could try making a copy of the Bitmap and returning the copy.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
how do you know the memory isnt released? Have you just looked at the task manager? You have to keep in mind that the GC runs very unregulary. Ive tested you code in a for loop over somehundred images. Its true that at first the memory rises constantly but at some point it reduces itsself automatically to a normal level.
If you want to avoid this you can use GC.Collect() to manually start the garbage collector.
|
|
|
|
|
I am using SciTech's NetMemProfiler2 to locate undisposed memory. Since the method is part of must large soultion, I was trying to locate any problems in the area that the NetMemProfiler pointed me to.
I will take a look at the method that calls to this methos and sees what it does with the bitmap.
Robert
|
|
|
|
|
The Fix:
The bitmap was being stored in another class.
The code was written as:
GetBitMap.getbitmap(<information>).Paint(g);
Rewrote the code as:
GetBitMap newClass = GetBitMap.getbitmap(<information>);
newClass.Paint(g);
newClass.Clean(); // remove bitmap from memory
The actual code is a bit more complex than the above example.
The code was written by another software company.
Robert
|
|
|
|
|
rlinder wrote:
// Memory Retention
// The new MemoryStream cause memory retention
return Bitmap.FromStream(new MemoryStream(buffer)) as Bitmap;
}
can be:
dim MS as new memorystream(buffer)
dim BM as bitmap = bitmap.fromstream(ms)
ms.close
return bm
}
sorry its VB code
|
|
|
|
|
I am using Visual Studio.net 2003 with the bundled Crystal Reports. I want to use a selection formula to select data based on the current value on my form. At the moment I have a dataform which has datafields and text boxes on it together with a cyrstal reports viewer. I have a text box called txtYEID on my form and a corresponding field in my database (and thus shown on my Crystal Report) called anuYEID. The selection formula I have at the moment is:
Dim myformula As String
myformula = "{tblYearEnd.anuYEID}" = "& chr(39) & txtYEID.Text & chr(39)"
CrystalReportViewer1.SelectionFormula = myformula
However when I trigger the code my CRViewer doesn't show any data! I've done messagebox.show on both txtYEID and anuYEID and the first shows the current data, but the second is blank - which I presume means it isn't passing the data to the field???
Once I've acheived this (if ever...) I want to separate the data form from the CR viewer so that they are both on different forms, but when I open the data form and select certain data, when I click a button to open the form with the viewer it will only show my current data - is this possible?
Any help would be gratefully appreciated
|
|
|
|
|
I realised there was an error in my formula and have corrected it to show as:
Dim myformula As String
myformula = "{tblYearEnd.anuYEID} = " & Chr(39) & txtYEID.Text & Chr(39)
CrystalReportViewer1.SelectionFormula = myformula
The mssagebox.show results are still the same and my code now triggers the error that anuYEID requires a number - so I guess it still not passing the number from one box to the other.
I would appreciate any help
thanks
|
|
|
|
|
form numbers
CrystalReportViewer1.SelectionFormula ="{Customer.Cust_No } = " & CInt(txtCustNo.Text)
for string you have to use
CrystalReportViewer1.SelectionFormula ="{Customer.Cust_Name } = ' " & CInt(txtCustNo.Text) & "'"
James Kennelly
|
|
|
|
|
Thanks for your help - really appreciated
|
|
|
|
|
Does anyone know how big a .NET app can be. I'm interested, if there is a limit of the size of an application ..
for example, assume that there is no hardware limit - there are few/enough GBs of RAM (if not, the os will use the virtual ram) - available .. and now i'm filling in a for loop (for example) an array ...
Does there exist any limit or restrictions which are known or defined, other then "not enough RAM or similar"?
Im interested if the app will "crash" after it becomes bigger then (for example) 1GB?
Does anyone know that? If not, what is the best way to check it?
Im not sure if that above is clear enough, but i hope it is.
I'm thankful for every answer!
denis
|
|
|
|
|
I'd say you'll never reach the limit if there's one, so why bother?
|
|
|
|
|
Depending on what your doing and using, an array has an index limit of 2,147,483,647 on a 32-bit processor...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
As any process also .NET apps have some limitations in size.
On an normal Windows (not 64 bit) this limit is somewhere beyond 1 GB (in one of my projects I needed an decimal array with 80 million elements and I still know it was very near to the limit).
This is even simple to check: Just make an test app and create some kind of big array and make it bigger until the OutOfMemoryException comes
|
|
|
|
|
maybe i'll write an app to test this.
thanks@all
denis
|
|
|
|
|
hai
i am new to .Net
plz any one explains what is assembly?
and unboxing concept?
thanx..
|
|
|
|
|
An assembly basically is an executable file.
Boxing means "packing" a value type into a reference type. Unboxing is the "unpacking" of the value type.
(I hope I got that right...)
|
|
|
|
|
Hey, I am just wondering is there a way to turn off interpolating when drawing completely?
I am trying to draw an image in 2x size.
At the moment I am setting the Interpolating property to: System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor
This is the "lowest" setting I can find for it. With this it's fine, except there is a line in rightmost column & bottommost row. I tried to fix the solution by resizing the image adding 1 pixel to the width, and one to the height, and then I copied leftmost column to the rightmost, and topmost row to the bottommost. This works fine, but I am getting a feeling that this isn't a good way to solve this. There [b]has[/b] (I hope at least) to be a way to turn the interpolating off.
If there's not, I want to know if there's a better solution? Maybe I should write my own DrawImage method, but I am quite unsure which would be the best way to do this. Using SetPixel() and GetPixel() of Bitmap class would most likely be too slow. I could use LockBits() to retrieve the pixel data, and then play around a bit to copy the pixels to the destination Graphics. I want to stay away from "unsafe" code, as long as there is good enough design solution available.
Thanks.
|
|
|
|
|
Unless you draw your image in it's exact size (or a multiple of its size) interpolation *must* occur. If you're drawing the exact size, there's no interpolation.
PeterRitchie.com
|
|
|
|
|
Does anyone know of a good reference for this task?
I'm finally able to pull my development head out of the sand and look at the VS 2005 (beta 2), and I was blown away by the added complexity of doing something as simple as putting a few fields on a form (what ever happened to dialogs???) and then display a message. (AfxMessageBox? What's that??????)
|
|
|
|
|
If by C++.net you mean managed C++, I would start with a .NET introduction.
Most of the language-specific aspects of .NET documentation (i.e. books) aren't geared much towards C++--they concentrate on C# or VB.
PeterRitchie.com
|
|
|
|
|
I noticed some very stange values coming back from some calculations in a datatable and decided to investigate.
Has anyone come across the problem below
?CSng(.51) + 0.01
0.51999999046325684
?CSng(.57) + CSng(1)
1.56999993
I assume this is something to do with the way that the floating point value is held, but I've never seen it before.
I'm using VB.NET to do this, but has anyone else noticed similar behaviour in other flavours of .NET?
|
|
|
|
|