|
Why are you using a RegEx when you can easily separate the tokens of the message with the String.Split() [^] method? Perhaps if you explain exactly what you are trying to do we can make some more informed suggestions.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
There is a Regular Expression forum.
Perhaps you should provide more examples and the results you want.
If you want to separate the message part from the number part, perhaps something like this might help:
@"(?'message'[^\d]*)(?'number'[\d]*)"
or
@"(?'message'.*?) message (?'number'.*)"
|
|
|
|
|
Good Morning,
Please,
Is there a limit memory on the Windows to an application c#?
Ex: I have a program that carry different informations and that information are equals 2 GB for example
but when I go to do other process I can't do because it's give me Exception System.out.of.memory
how can I change this limit?
thanks
William
|
|
|
|
|
Not enough information.
How much memory is in the machine? Which version of Windows are you running? What code is throwing this exception? How big is the object you're allocating?
Under .NET, OutOfMemory exceptions cover a lot of things, some of which have nothing to do with running out of memory.
Also, no single object in .NET can be larger than 2GB. So, if you're trying to allocate say, an array of integers greater than 512 million elements, it's going to fail.
|
|
|
|
|
I'm using 8GB of Memory Ram, Windows 7 Professional 64 bits. Virtual Memory 6144 MB.
I carry a HashTable With 5 000 000 of records, this equivalent 2GB, but when I go to create other array of 25000 positions give me System out of memory exception.
If I stop the code in this section and instantiate the array in another application works perfect, so I have memory on the machine, so I see that the problem is the limitation of each application
thanks
|
|
|
|
|
Three thoughts:
1. is your app running in x-64 mode? how did you build it: x-86, x-64, or "Any CPU"?
2. could it be a fragmentation problem: objects larger than 80KB go in the Large Object Heap, which never gets compacted, hence could fragment when many different sized objects get allocated and freed in random order.
3. do you really need/want that big a hash table, wouldn't a database be more appropriate? or a completely different algorithm? (we don't know what it is your app is doing...)
|
|
|
|
|
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.
|
|
|
|