|
Encoding.ASCII.GetString(byte[] bytes)
or
Encoding.ASCII.GetBytes(string input)
|
|
|
|
|
I need to convert text to asci and asci to hex
|
|
|
|
|
Try string.format("{0:X2}", asciByte); which converts asciByte to a two digit Hex string.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
No It didnt work.......
Lets take an example
string data "3F 50"
after conversion i should get "? P"
but i am not getting any thing
|
|
|
|
|
Look at
Parse(str, System.Globalization.NumberStyles.HexNumber)
You will have to use it a few times and skip the spaces, but it will convert hex "3F" to byte '?'
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi all
I made a custom control. I use it programatically in another project. the problem is I get change the label content(the text that appear)
any idea?
question 2:
I have a grid. I want only part of the grid to be scrolable.so that the first row and culomn are fixed. just like the header of a browser-is fixed and the rest of the page can be scrol. is it posible in the same grid?
I prefer to use 1 grid so the culomn size are the same
question3:
can any one direct me to a window 3 layer sample project, that is working by "best practise" ?
thanks
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MyCustomControl}" >
<Border Background="{TemplateBinding Background}" >
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<TranslateTransform/>
</transformgroup>
<Border.RenderTransform>
<Label Name="lbl" >cool</label>
</border>
</controltemplate>
</setter.Value>
</setter>
|
|
|
|
|
I guess your question is not posted correctly. Please check this Chekbox "Do not interpret HTML tags (good for code snippets)" Before post the code.
And this is C# Forum. Please Post it on WPF Forum.
|
|
|
|
|
I'm creating a static ContextMenu at runtime in program.cs, which works fine except that it has a slightly different visual style to ContextMenus created at design-time (doesn't highlight properly, menu items won't check, etc.) despite having all properties manually set to the default design-time specs.
Suggestions?
|
|
|
|
|
it works fine for me. probably you are using the old context menu from vs2003 ?
or you can copy and paste your code here..
|
|
|
|
|
I should've made that more clear - I'm creating a ContextMenuStrip, which replaces ContextMenu as far as I know. I create it as follows...
menu = new ContextMenuStrip();
ToolStripItem[] items = { ... };
menu.Items.AddRange(items);
menu.RenderMode = ToolStripRenderMode.Professional;
I've also tried messing around with other properties like the margins and so forth, but it's still different from the design-time result.
|
|
|
|
|
Hi,
All controls are created at run time and the designer just writes the code for you. If you can can create the desired appearance with the designer then do that and look in the *.designer.cs file to see how it was done.
Alan.
|
|
|
|
|
I've done this as well, both for the ContextMenuStrip, and all the ToolStripItems contained in it - doesn't work.
Basically I'm still getting this. Only the text area is detected as a clickable region, and instead of showing checked items as ticked in the margin, they're just highlighted like the top item seen there.
|
|
|
|
|
i want to print a webpage using
system.Drawing.Printing namespace.i dont want to use javascript.
i want to set the settings of the page to landscape.
how can i do it
pls help
.
|
|
|
|
|
Is this a website you wrote ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
Then here are the reasons your question is stupid
1 - it's not even in the ASP.NET forum
2 - if you knew anything about ASP.NET, you'd understand that the only code that runs on the client, is javascript
3 - and javascript can't set the print mode, all it can do is start the print dialog
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
well my friend i think somebody made a fool out of u .who made u a
MVP
have u heard about system.Drawing.Printing Namespace
|
|
|
|
|
Whatever code you write using this namespace will be executed on the server. How is your server going to identify the printer connected to the client and configure its properties?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
|
I have a process running on a 64bits server OS.
It does use a lot of memory and I sometimes get outOfMemory exception....
However, at best, I'm using a few tens of Megabytes at once, say 60Mb. Or even 200 Mb (if memory representation of disk data takes more space)
How come I have out of memory?
I understand there could be memory fragmentation and such, but our server have 8GB, plus, with virtual memory, process should have something like 16GB of available memory, or so I believed.
That leaves plenty of room...
Can anyone explain to me what's probably going on or how much memory is available to .NET process?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
It means that you're using too much memory in a process. What is the app doing ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I'm between a rock and a hard place.
What I'm doing is:
Reading data in a DataTable
Writing the DataTable in a "MapXtreme Table".
Writing to MapXtreme is godamn slow and if I read line by line in the reader and directly write line by line in the MapXtreme table, I will certaimnly reduce memory consumption. But it might take up to half an hour to write all the data in a MapXtreme table, and I have SQL Timeout.
My SQL timeout is already 10 minute and I'm not eager to increase it more.
So I decided to read all the data in a DataTable first (quick), close the SQl connection and then write it to MapXtreme.
I have OutOfMemory of the DataTable.Load()...
Mmhh... I'm thinking I can load my data in chunk perhaps? tricky but feasible..
But then I also get out of memory in MapXtreme Table.Write (Row i.e. Feature)
I can't really do anything there... MapXtreme support is appealing so I won't get much help from their either
But anyway, the MapXtreme files are, at most, about 30~40 Mb, so it stands to reason that the memory used can't be much more than that.
40Mb is not that much in a 64bit server with 8GB memory + virtual memory, why do I get that?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
I once worked on a Win App using vb.net. Well i got that problem and when i get back in my app, i found out that there was a prt of my code that was in a infinite loop. Variable and objects were created and never used. I suggest you go back to your code and check if you are not misusing the memory from there. another thing after you use object just set them to null in the Finally block. if you don't have finally block you must consider using it.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi,
This is a standard text of mine, as the question pops up regularly:
----------------------------------------------------
I know of three ways to get an OOM Exception:
1.
the most surprising one: some method throw OOM on bad inputs, most notoriously: Image.FromFile().
2.
you are really running out of memory; typically that means you are preventing objects from being collected. You can watch your app grow, roughly through Task Manager; more correctly by incorporating a display of Environment.WorkingSet in your app.
One way of keeping objects around is by storing references to lots of, or all, objects you create; maybe for debugging, for statistical information, as a cache, whatever. If so, consider the WeakReference class.
3.
you have objects larger than 80KB; those get allocated on the "large-object-heap", which never gets compacted, and hence could become fragmented, resulting in an OOM even when lots of free memory is still around (but each chunk is smaller than the size needed).
Remember: lots of collections (ArrayList, List< T>, etc) are stored as arrays, and such arrays get doubled in size and copied each time their capacity gets exceeded.
IMO you can't reliably design a long running .NET app if you need large objects, unless you:
- either make them all the same size;
- or perform the entire memory management for large objects yourself.
Both of which may be tedious. A third possibility is making your app restart periodically all by itself.
----------------------------------------------------
As you say your app is both small and slow, there must be something really wrong. Why don't you show all relevant code (in PRE tags!)? My best guess is you are building very long strings (or collections) and your app's memory is getting fragmented. That is possible, no matter what Windows version, Framework version and amount of memory/virtual memory you have.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I guess I'm hitting problem number 3.
The code is hard to share if only because I extensively using a 3rd party GIS library called MapXtreme, which is damn slow to write its data files.
Sometimes I can get tens of thousands row in a select, and then I write a feature table with same size. In fact I'm generating (spatial) report in the background and I will get many such case.
Here is relevant method.
Which is invoked continuously in a never ending process until all trucks travel for the period (usually day) have been accounted for.
static void AddFeatures(ReportTask report, Guid taskId, out int nRow, out Table table)
{
table = null;
nRow = 0;
var miStyle = TabUtility.MakeMapInfoStyle(report.Style);
var dbtable = new DataTable();
try
{
using (var cmd = new SqlCommand())
using (var conn = Config.GetOpenedConnection())
{
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = Config.SqlTimeout;
cmd.CommandText = report.StoredProc;
cmd.AddParameter("uidTaskID", SqlDbType.UniqueIdentifier, taskId);
using (var reader = cmd.ExecuteReader())
{
if (reader.HasRows)
dbtable.Load(reader);
}
}
}
catch (Exception ex)
{
ex.Data["ReportName"] = report.Name;
ex.Data["ReportSP"] = report.StoredProc;
throw;
}
try
{
long TotalWKBRead = 0;
foreach (DataRow row in dbtable.Rows)
{
try
{
var wkb = row[GeomColumnName] as byte[];
if (wkb == null || wkb.Length == 0)
continue;
var geom = WKB.ToFeatureGeometry(wkb);
if (geom == null)
continue;
TotalWKBRead = wkb.Length;
if (table == null)
{
table = CreateTable(report.BasePath, report.Name, miStyle, dbtable);
table.BeginAccess(TableAccessMode.Write);
}
var feature = new Feature(table.TableInfo.Columns);
feature.Geometry = geom;
feature.Style = miStyle;
TabUtility.SetFeatureValues(feature, row);
table.InsertFeature(feature);
nRow++;
}
catch (Exception ex)
{
var wkb = row[GeomColumnName] as byte[];
ex.Data["TaskID"] = taskId;
ex.Data["ReportName"] = report.Name;
ex.Data["table.Row.Count"] = nRow;
ex.Data["WKB.Length"] = wkb != null ? wkb.Length : 0;
ex.Data["TotalWKB.Length"] = TotalWKBRead;
throw;
}
}
}
finally
{
if (table != null)
table.EndAccess();
}
}
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|