|
X86, I use hash because i need fast performance, this informations already has a database.
thanks
|
|
|
|
|
If you aren't using any components that force you to keep building for x86, then go for x-64 (or "Any CPU"), and take advantage of the huge address space it offers. Mind you, each process must be homogeneous, you can't mix x86 and x-64 code in one build.
|
|
|
|
|
On top of what OriginalGriff said, it also depends on what you're doing. If you're resizing the HashTable to get to this point, you've fragmented the Large Object Heap. This will give you a problem. The Large Object Heap is never defragmented (for performance reasons).
So, if you started with a small(ish) HashTable, then exand it to accomodate more entries, you're actuall creating a new HashTable object with greater capacity, copying the references in old object to the new one, then destroying the old HashTable. Do this enough and you'll end up fragmenting the Large Object Heap to the point where you've got, say 5GB of memory available, but no free blocks of memory big enough to hold your new expanded HashTable all in one shot. There is no way to force a defrag of the Large Object Heap.
To get minimize this, try specifying the expected capacity of the HashTable when you create an instance of it.
|
|
|
|
|
There is no limit of 2GB for all information in .NET - but there is a limit of 2GB for any one object in .NET
What that means is that each object you create must be less than 2GB - you can have an array of 536,870,912 strings, each string of which can be 1GB in size, but you cannot have an array of 536,870,913 strings (assuming each reference is 32 bits, that would take teh total size of the array over 2GB - for 64 bit references the size is halved).
This doesn't mean that you won't get "out of memory" errors - it depends on how much virtual memory is available to .NET and your system in general, and you may run out of memory if the garbage collector can't free up a big enough chunk to fill a request.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
william ormundo wrote: but when I go to do other process I can't do because it's give me Exception
System.out.of.memory
Only way I can see that happening is if you have turned off virtual memory. And that has nothing to do with C#, it is an OS configuration issue.
|
|
|
|
|
I have a grid with 3 defined columns. Is there a way to divide column 1 into 3 grid rows without affecting the other 2 columns? I've tried defining RowDefinitions, but it spans all 3 columns. I don't want that. I only want it to affect the 1 column.
|
|
|
|
|
Sutton Mehaffey wrote: affecting the other 2
No
Sutton Mehaffey wrote: I don't want that
Then put another grid with 3 rows in column one.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Pick a forum and stick with it.
|
|
|
|
|
Hello All,
I have a problem with Exchange server 2007. I was trying to execute the following query get-mailbox | FL. This query was working when I tried it in the Exchange server's power shell console after executing following query Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin.
But I need it to be executed from a remote machine, so I have executed it from my powershell console , as follows...
$server='192.168.1.23';$pwd= convertto-securestring '123' -asplaintext -force;$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist 'exchangeserver\Administrator',$pwd; invoke-command -computername $server -credential $cred -scriptblock {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin get-mailbox | FL}
But, this query fails with the following error...
A positional parameter cannot be found that accepts argument 'get-mailbox'.
+CategoryInfo :InvalidArgument: {:} [Add-PSSnapin], ParameterBIndingException
+FullyQualifiedErrorId: PositionalParameterNotFound,Microsoft.Powershell.Commands.AddPSSnapinCommand
I have modified this query again and added a ; after the snapin add section.
$server='192.168.1.23';$pwd= convertto-securestring '123' -asplaintext -force;$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist 'exchangeserver\Administrator',$pwd; invoke-command -computername $server -credential $cred -scriptblock {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin; get-mailbox | FL}
This is also fails with the following error.
Active Directory server exchangeserver.xxxxxx.local is not available. Error message: The supplied credential is invalid.
+ CategoryInfo : NotSpecified: <0:int32> [Get-MailBox],ADOperationException
+ FullyQualifiedErrorId : A2B6F75B,Microsoft.Exchange.Management.RecipientTasks.GetMailbox
Then I have removed the add-snap-in section from the command and executed again.
$server='192.168.1.23';$pwd= convertto-securestring '123' -asplaintext -force;$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist 'exchangeserver\Administrator',$pwd; invoke-command -computername $server -credential $cred -scriptblock {get-mailbox | FL}
Now it throws another error message.
The term 'get-mailbox' is not recognised as the name of a cmdlet, function, script file or operable program.
Check the spelling of the name, or if a path was included, verify that the path is corerct and try again.
+ CategoryInfo : ObjectNotFound: <get-mailbox:String> [],CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Can someone help me on this?
Thanks in advance
Sebastian
|
|
|
|
|
I have a collection class to hold the children of a control in a DIY user interface. The UI allows to add new controls by calling the Add() method of the collection. Nothing special and breakpoints in Add() are reached as long as the calls come from my own code. Everything is as it should be. Alternatively a view can also be loaded from XAML (using the XamlServices class). If that is done, the view is loaded correctly, but none of the breakpoints in any of the collection's methods are reached. As a result the parent control does not react to layout changes when children are added or removed. Still, XamlServices has successfully loaded the controls and their children, just none of my methods have been used and the layout has not been updated.
According to MSDN, XAML fills the collection with reflection (no real surprise) and looks for the IList interface to do that. I have implemented the complete IList interface and set breakpoints in all of the methods and properties, but they are only reached when the methods are called from my own code. Also, the collection may not be a generic list itself, but may be derived from a generic list. That is why I implemented my collection the following way:
public class ControlList : List<Control>, IList
{
public new void Add(cPraeComponent oComponent)
{
}
}
I am convinced that XAML calls the methods of the baseclass (the generic list) instead of mine. My only idea up to now is to wrap the whole collection in a wrapper class which does not inherit from anything and implements IList, but this would be one ugly workaround. Does anybody have a better idea?
Edit: I tried deriving the collection from (forgive me) ArrayList, but that also did not change anything. It really looks like XAML always ends up calling the baseclass and not my methods.
I'm invincible, I can't be vinced
|
|
|
|
|
CDP1802 wrote: public new void
|
|
|
|
|
I assume you are wondering about the order of the modifiers, not about the 'new' modifier itself. As far as I know the sequence of the modifiers is unimportant. You could write 'public new' or 'new public' without changing anything.
I'm invincible, I can't be vinced
|
|
|
|
|
I think he wanted to point out that override could work better than new here.
Ciao,
luker
|
|
|
|
|
Wrong assumption. IMO the compiler should generate a message when an interface method gets the new keyword, as it most probably defeats the purpose of the interface.
ControlList c1=new ControlList();
IList c2=c1;
c1.Add(new Control());
c2.Add(new Control());
|
|
|
|
|
They are not virtual or abstract methods, so 'override' will cause a compiler error. Indeed the compiler will also generate a warning if you don't use 'new'. But very obviously this also leads to the methods of the baseclass being taken as implementation of IList and not the new ones.
I'm invincible, I can't be vinced
|
|
|
|
|
new is not the solution as my code sample explained; what you want is override, and if the base method isn't virtual, you're in trouble.
Anyway, inheriting/implementing both List and IList looks quite fishy. If you insist on using List , you'll have to use aggregation, not inheritance, and provide each and every method you need yourself.
And then there is ObservableCollection as Pete pointed out.
|
|
|
|
|
Good morning!
Luc Pattyn wrote: new is not the solution as my code sample explained; what you want
is override, and if the base method isn't virtual, you're in trouble.
Yes, you are right. Everything would be ok if the methods were virtual.
Luc Pattyn wrote: Anyway, inheriting/implementing both List and IList
looks quite fishy. If you insist on using List , you'll have to use
aggregation, not inheritance, and provide each and every method you need
yourself.
I agree again. It is just that 'aggregating' a single class within another means wrapping one class into the other. That would also not have been very elegant, but it would have set all questions about the implementation of IList straight. ObservableList works fine for now, but I must be careful not to get a similar situation again and then I may yet have to wrap it up.
I'm invincible, I can't be vinced
|
|
|
|
|
In order for the Xaml to react, your custom collection must implement INotifyCollectionChanged. Take a look at ObservableCollection to see what this does, ad that is the standard collection class used with Xaml.
|
|
|
|
|
Thank you very much. I did not know about the ObservableCollection class and it appears to be designed for exactly what I am doing. I'm going to try it out right now.
Edit: A first quick test worked and, as a bonus, ObservableCollection also deals with reentrant changes to the collection. Needless to say that I already had my own mechanism in place to avoid that problem. Now it's time to clean up the code.
I'm invincible, I can't be vinced
modified 12-Mar-12 6:41am.
|
|
|
|
|
Not a problem. Glad I could help.
|
|
|
|
|
What about not inheriting from List<Control>? I.e.
public class ControlList : IList<Control>
Then you'll need to have the collection as a memeber variable, and forward calls to it, e.g.
protected List<Control> myList = new List<Control>();
public void Add(cPraeComponent oComponent)
{
myList.Add(oComponent);
}
That means writing a lot of code, but I think it's worth to try.
|
|
|
|
|
Thanks. That's what I meant with wrapping up the collection class. It would probably have worked, but also have been somewhat ugly and unelegant. I used the advice to derive the collection from ObservableCollection and it now works in both cases.
I'm invincible, I can't be vinced
|
|
|
|
|
Hi,
I have a gridview that is exported to Excel using C#.
This all works great. The GridView is populated after selecting from a dropdownlist to filter the results.
I would like to add a title to the worksheet so users know what the results refer to. I would like to use the value of the dropdownlist. Is this possible.
My code is
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="true" CodeFile="TeamVolumeSplitQ32011.aspx.cs" Inherits="Printing_Team_Usage_TeamVolumeSplit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="TeamNameSrc"
DataTextField="LongName" DataValueField="LedgerID"
AppendDataBoundItems="True" AutoPostBack="True">
<asp:ListItem Value = "">Please Make a Selection</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="TeamNameSrc" runat="server"
ConnectionString="<%$ ConnectionStrings:Docupro_ReportingConnectionString %>"
SelectCommand="SELECT [LedgerID], [LongName] FROM [tblLedger]">
</asp:SqlDataSource>
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" BackColor="White"
BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4"
DataSourceID="TeamVolumeSrc" ForeColor="Black" GridLines="Vertical"
ShowFooter="True"
EmptyDataText="There are no records to display"
onrowdatabound="GridView1_RowDataBound">
<PagerSettings Mode="NextPreviousFirstLast" NextPageText="Next"
PreviousPageText="Prev" />
<RowStyle BackColor="#F7F7DE" />
<Columns>
<asp:TemplateField HeaderText="User" SortExpression="User">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("User") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="lblUser" runat="server" Font-Bold="True" Text="Totals"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("User") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Colour" SortExpression="Colour">
<EditItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Colour", "{0:#,0}") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalColour" runat="server" Font-Bold="True" Text="Label"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Colour", "{0:#,0}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="B&W" SortExpression="B&W">
<EditItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("[B&W]", "{0:#,0}") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalBW" runat="server" Font-Bold="True" Text="Label"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("[B&W]", "{0:#,0}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total Clicks" SortExpression="Total">
<EditItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Eval("[Total Clicks]", "{0:#,0}") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalClicks" runat="server" Font-Bold="True" Text="Label"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("[Total Clicks]", "{0:#,0}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="TeamVolumeSrc" runat="server"
ConnectionString="<%$ ConnectionStrings:Docupro_ReportingConnectionString %>" SelectCommand="USE Docupro_Reporting
select
T5.DisplayName AS 'User',
0+COALESCE(SUM(CASE
WHEN T2.LongName LIKE '%Colour%' THEN T1.Quantity
END),0)AS Colour,
0+COALESCE(SUM(CASE
WHEN T2.LongName LIKE '%B&W%' THEN T1.Quantity
END),0)AS 'B&W',
SUM(T1.Quantity) AS 'Total Clicks'
FROM tblTransaction T1
JOIN tblItem T2 ON T1.ItemID = T2.ItemID
JOIN tblLedger T3 ON T1.LedgerID = T3.LedgerID
JOIN tblTender T4 ON T1.TenderID = T4.TenderID
JOIN tblCustomer T5 ON T4.CustomerID = T5.CustomerID
WHERE (TransactionDateTime BETWEEN '2011-10-01' AND '2012-01-01')
AND
(T2.LongName <> 'Scan 2' AND T2.LongName <> 'Scan 1')
AND T3.LedgerID = @LedgerID
GROUP BY
T5.DisplayName
ORDER BY T5.DisplayName">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="LedgerID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<asp:Button ID="btnExcelExport" runat="server" Text="Export To Excel"
onclick="btnExcelExport_Click" />
<br />Paging Enabled?
<asp:RadioButtonList ID="rbPaging" runat="server">
<asp:ListItem Text = "Yes" Value = "True" Selected = "True">
</asp:ListItem>
<asp:ListItem Text = "No" Value = "False"></asp:ListItem>
</asp:RadioButtonList>
<br />
</asp:Content>
Code behind is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;
using System.Configuration;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
public partial class Printing_Team_Usage_TeamVolumeSplit : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
int totalColour = 0;
int totalBW = 0;
int totalClicks = 0;
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
totalColour += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Colour"));
totalBW += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "B&W"));
totalClicks += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Total clicks"));
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lblColour = (Label)e.Row.FindControl("lblTotalColour");
Label lblBW = (Label)e.Row.FindControl("lblTotalBW");
Label lblClicks = (Label)e.Row.FindControl("lblTotalClicks");
lblColour.Text = totalColour.ToString("#,#");
lblBW.Text = totalBW.ToString("#,#");
lblClicks.Text = totalClicks.ToString("#,#");
}
}
protected void btnExcelExport_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition",
"attachment;filename=GridViewExport.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
PrepareForExport(GridView1);
Table tb = new Table();
TableRow tr1 = new TableRow();
TableCell cell1 = new TableCell();
cell1.Controls.Add(GridView1);
tr1.Cells.Add(cell1);
TableCell cell2 = new TableCell();
cell2.Text = " ";
TableRow tr2 = new TableRow();
tr2.Cells.Add(cell2);
TableRow tr3 = new TableRow();
tb.Rows.Add(tr1);
tb.Rows.Add(tr2);
tb.Rows.Add(tr3);
ClearControls(GridView1);
tb.RenderControl(hw);
string style = @"<style>.textmode{mso-number-format:\@;}</style>";
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
protected void PrepareForExport(GridView Gridview)
{
Gridview.AllowPaging = Convert.ToBoolean(rbPaging.SelectedItem.Value);
Gridview.DataBind();
Gridview.HeaderRow.Style.Add("background-color", "#FFFFFF");
for (int k = 0; k < Gridview.HeaderRow.Cells.Count; k++)
{
Gridview.HeaderRow.Cells[k].Style.Add("background-color", "green");
}
for (int i = 0; i < Gridview.Rows.Count; i++)
{
GridViewRow row = Gridview.Rows[i];
row.BackColor = System.Drawing.Color.White;
row.Attributes.Add("class", "number");
if (i % 2 != 0)
{
for (int j = 0; j < Gridview.Rows[i].Cells.Count; j++)
{
row.Cells[j].Style.Add("background-color", "#C2D69B");
}
}
}
}
private void ClearControls(Control control)
{
for (int i = control.Controls.Count - 1; i >= 0; i--)
{
ClearControls(control.Controls[i]);
}
if (!(control is TableCell))
{
if (control.GetType().GetProperty("SelectedItem") != null)
{
LiteralControl literal = new LiteralControl();
control.Parent.Controls.Add(literal);
try
{
literal.Text =
(string)control.GetType().GetProperty("SelectedItem").
GetValue(control, null);
}
catch
{ }
control.Parent.Controls.Remove(control);
}
else if (control.GetType().GetProperty("Text") != null)
{
LiteralControl literal = new LiteralControl();
control.Parent.Controls.Add(literal);
literal.Text =
(string)control.GetType().GetProperty("Text").
GetValue(control, null);
control.Parent.Controls.Remove(control);
}
}
return;
}
public override void VerifyRenderingInServerForm(Control control)
{
}
}
Many thanks
Andy
|
|
|
|
|
private void btnvalidate_Click(object sender, EventArgs e)
{
string adress;
Validateuradress vadrs = new Validateuradress();
adress = (dgv1.SelectedCells[0].Value.ToString());
if (vadrs.validate(adress))
{
DataGridViewImageColumn img = new DataGridViewImageColumn();
Image image = Image.FromFile(@"Valide.png");I have a problem at this level, never accepts the path of the image
dgv1.Columns.Add(img);
img.HeaderText = "Validate";
img.Name = "img";
}
|
|
|
|
|
That is probably because you aren't specifying one.
"Valide.png" does not have any path information, so it will be looked for in the current folder - which is likely to be the one the original EXE was run from, unless it has been changed in the meantime.
I would strongly suggest that you specify the path, at least relative to where the EXE started:
string appPath = Path.GetDirectoryName(Application.ExecutablePath); If your image file is in a floder below that, add the folder name on, and you should be able to get to your file.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|