|
I don't know why I didn't try this before. I had the client publishing it's IpcChannel with it's string uri only, and this won't work apparently if there's any kind of security needed. You need to specify the dictionary definitions when you create the channel as follows:
public static void Publish() {
var serverProvider = new BinaryServerFormatterSinkProvider();
var clientProvider = new BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
props["name"] = "Client";
props["portName"] = LogOnInformation.LogOnChannel;
props["typeFilterLevel"] = "Full";
props["exclusiveAddressUse"] = "false";
props["authorizedGroup"] = "Everyone";
props["rejectRemoteRequests"] = "true";
var chan = new IpcChannel(props, clientProvider, serverProvider);
ChannelServices.RegisterChannel(chan, false);
client = new LocationViewProxy(LogOnInformation);
RemotingServices.Marshal(client, LogOnInformation.LogOnHost, typeof(LocationViewProxy));
}
Thanks to those of you who looked.
Scott P.
"Simplicity carried to the extreme becomes elegance."
-Jon Franklin
|
|
|
|
|
Hi there,
I am reading a (rather large) MS-SQL stored procedure into C# using the SqlDataReader. I expect this to return slightly over 8,000,000 records, but it consistently maxes out at 726,301. I cannot for the life in me see why - when running the stored procedure (which has no input parameters) in SQL Server Management Studio it returns the correct number of records.
I am running VS 2008 Professional with SQL Server 2008 Developer Ed. The code is paraphrased as follows:
// Set up a list of data type Record (my own) to hold the output of the sp
List<record> records = new List<record>();
System.Data.SqlClient.SqlConnection Connection = new
System.Data.SqlClient.SqlConnection(ConnectionString);
System.Data.SqlClient.SqlCommand Command;
try
{
Connection.Open();
{
Command = new System.Data.SqlClient.SqlCommand("StoredProcedure", Connection);
Command.CommandType = CommandType.StoredProcedure;
System.Data.SqlClient.SqlDataReader Reader = Command.ExecuteReader();
while (Reader.Read())
{
Record NewRecord = new Record();
NewRecord.PAR1 = Reader.GetInt32(Reader.GetOrdinal("PAR1"));
NewRecord.PAR2 = Reader.GetInt32(Reader.GetOrdinal("PAR2"));... etc
records.Add(NewRecord);
}
}
}
catch
{
}
finally
{
Connection.Close();
}
Thanks a million for any help!
Ben
|
|
|
|
|
Hi,
why don't you catch an Exception and look at all its information, using Exception.ToString().
Chances are the problem has been reported but you showed no interest.
Could be a timeout, an out-of-memory condition, ...
Since the number of rows returns is constant, I do expect an OOM.
BTW: if 8 million is what you expect, how many records are there?
And if you were to want all existing records, why use a SP in the first place?
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:07 AM
|
|
|
|
|
Hi Luc,
Thanks for your reply. In answer to your questions: I don't get an exception - it just terminates the while(Reader.Read()) loop at 7263001 records. I have actually slightly increased the field count of the query (which makes it also take much longer) - but this doesn't affect the number of records it tops out at, which made me think that timeout and oom might not be the reason.
I used a sp in order to be able to test and maintain the query on the server rather than just having a long text string select statement in my C# code.
Cheers, Ben
|
|
|
|
|
Hi Ben,
Ben Cocker wrote: I don't get an exception
you may have misunderstood me. What I meant is your code (catch{}) just swallows exceptions if and when they occur, so it may seem you don't get any. Did you try a
...
catch(Exception exc) {
log(exc.ToString());
}
...
where log is some logging method, a Console.WriteLine, a MessageBox.Show, whatever you fancy.
Also, I'm not familiar with the Record class, is it standard .NET stuff or is it yours? any idea what the size of its objects is? I hope it isn't duplicating information, such as table metadata all over.
BTW: "only 1.5GB" (from your other reply) is a phrase I never used so far
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:07 AM
|
|
|
|
|
Hi Ben,
adding a field to the query does not change the memory situation if that field eventually gets stored in a value type inside Record, such as an int or Int32, since such members get allocated memory whether you fill them or not.
If adding some NEW members to the Record class still keeps it failing at record 726,301 then I might be inclined to say something is abnormal with that record (say a NULL value, so your GetInt32 fails).
My odds are still very much in favor of O-O-M though.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Thursday, March 5, 2009 2:34 PM
|
|
|
|
|
I have to agree with Luc, I think your running into a problem on that particular record, its throwing an exception, and the exception is getting swallowed. Stick a breakpoint in your catch clause and see what is going on.
|
|
|
|
|
... and never ever swallow exceptions like that.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:08 AM
|
|
|
|
|
....never ever.....ever.....ever.
|
|
|
|
|
Guys,
I've been astonished by the help I've received with this problem - thank you very much everyone.
I'm afraid to say that the problem was as stupid as me consuming the exception on a particular record. Best practice point to self, and I'm really sorry for wasting peoples time on such a simple thing. I normally go out of my way to Google for problems, but since 726301 is not a magic number/ceiling (as it was just an exception) I was really scratching my head over this one without seeing the obvious.
Anyway, thanks again for everyone's time, and for the suggestions.
Ben
|
|
|
|
|
Well, my guess is that the sheer number of records your processing in-memory is just flat out insane. :P
The problem is most likely not a row count limitation of SqlDataReader...but rather a memory limitation. You are trying to create a massive List of Record objects...the overhead for that is going to be fairly high compared to just displaying rows of text in, say, Sql Management Studio. Depending on exactly how many columns you are setting on your Record object, the data types of each, and the lengths of strings that may exist in your result set...you could be looking at GIGS of memory usage here.
I am not exactly sure what your doing or what your needs are...but you should look into batching your work. Either chunk it up into significantly smaller data sets (say, 10000 records each) and process them one at a time...or distribute those chunks out to a server farm to process them in parallel. If you absolutely need to process all 8 million records at once...then you are probably doing something that calls for LAPACK or some other matrix or vector processor that can efficiently handle large data sets.
|
|
|
|
|
Hi Jon,
Thanks for your reply, and the suggestions. Could I point you to my reply to Luc for a discussion of this out-of-memory limitation? And, I have been very careful to limit the number of fields I use and don't have any string columns, so although I take your point that 8 million rows is a beast, in SQL management studio the size of comma delimited output file is less than 1.5gig - I've got a 32 bit machine with maximum memory so I am skating on thin ice, but still I expected it to work out memory wise.
I'll look into LAPACK - thanks for the suggestion.
Ben
|
|
|
|
|
Ben Cocker wrote: SQL management studio the size of comma delimited output file is less than 1.5gig
So what? That's a file on disk that doesn't have the overhead of a storage class managing the data. THere is no limit on the Reader, since it only reads a single record at a time and returns the fields in that record. The real question is where is this data going?? Is it going into an ever-expanding collection?? If so, then you're running the machine out of memory.
|
|
|
|
|
Well, maybe you are confused about the datareader and dataset in ADO.net. DataReader object just go forward for ONE record each time. Generally, it will not take you too much memory for only one record, right?
I Love KongFu~
|
|
|
|
|
Ben - what could you possibly do with this many records? You certainly couldn't present this to a user - are you meant to be passing this to some other process (say to store to a file).
I suspect you've got two problems - one, the record at position 726,301 is invalid in some way which you aren't catching in your code and two, the number of records is too great. BTW - it's never a good idea to just consume exceptions. You should actually do something with it, even if it's only log the exception. I normally use a variation of this function to parse the items (I'm typing this from memory so it may need a bit of tidying up):
public static T ParseValue(this SqlDataReader reader, string fieldName)
{
int ordinal = reader.GetOrdinal(fieldName);
if (reader.IsDBNull(ordinal))
return default(T);
return (T)reader.GetValue(ordinal);
} Then you use this as
NewRecord.PAR1 = Reader.ParseValue("PAR1");
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys
|
|
|
|
|
Hi All,
i'm try to take the VB script and Dll in this article http://support.microsoft.com/kb/935635
and make the functionality work with C#.
i can add the ExIpSec.dll type library and with the using statement (using EXIPSECLib) i can expose the Interfaces and i can some of them to work. but when i try to retrieve the list if IP addresses i just get System.object[]. i have tried converting this to a string[] but i get nothing back.
can anyone tell how to correct call this dll? - DllImport does seem to work either!!
Many Thanks,
Phil
|
|
|
|
|
You may want to start at the beginning to understand how COM Interop [^]works
Yusuf
|
|
|
|
|
Well, without more info, we can not do anything with it. But all you did so far seems correct.
In fact, .Net will wrap up the COM for you(if you add COM dll from the Visual Studio), we do not need to worry about the interface. I am intended to say maybe you miss something in your code, such as initialize certain parameter.
I Love KongFu~
|
|
|
|
|
the lines in the VB script are:
Set objDsIpSec = CreateObject("ExIpSec.ExIpSecurity")
objDsIpSec.BindToSmtpVsi "someSMTPserver", 1, "someDC"
objDsIpSec.GetRelayIpList
listToDisplayIp = objDsIpSec.IpGrant
listToDisplayIp appears to be a string array.
the lines in using in C# are:
ExIpSecurity ipsec = new ExIpSecurity();
string[] s;
ipsec.BindToSmtpVsi("someSMTPserver", 1, "someDC");
ipsec.GetRelayIpList();
s = ipsec.IPGrant.ToString().Split(' ');
foreach (string i in s)
{
MessageBox.Show(i.ToString());
}
if i run the VB script i get a list of IP address but if i run the C# code i get one popup box saying System.Object[]
what am i doing wrong?
|
|
|
|
|
lane0p2 wrote: ipsec.BindToSmtpVsi("someSMTPserver", 1, "someDC");
ipsec.GetRelayIpList();
s = ipsec.IPGrant.ToString().Split(' ');
Did you debug the code and check what the value of IPGrant is?
I Love KongFu~
|
|
|
|
|
hello,
done it!
when debugging i could see all the entries in IPGrant, the problem was converting the object array into a string array, i managed this with:
ExIpSecurity ipsec = new ExIpSecurity();
ipsec.BindToSmtpVsi(someSMTPserver, 1, "someDC");
ipsec.GetRelayIpList();
object[] o = (object[])ipsec.IPGrant;
string[] s = new string[o.Length];
Array arr = s;
o.CopyTo(arr, 0);
s = (string[])arr;
foreach (string i in s)
{
sw.WriteLine(i);
}
thanks for your help mate,
have a good weekend.
Phil
|
|
|
|
|
Hi all, can someone help with the following issue I'm having.
I am returning a dataset with a list of names of screen objects for a form.
I am trying to loop round the dataset, pick up the name then get the type of the control.
As follows...
foreach (DataRow row in dataSet_Groups.sp091_load_user_screen_components_layout.Rows)
{
strObjectName = Convert.ToString(row["ScreenObjectName"]);
strXMLText = Convert.ToString(row["XMLText"]);
intX = Convert.ToInt32(row["X"]);
intY = Convert.ToInt32(row["Y"]);
intWidth = Convert.ToInt32(row["Width"]);
intHeight = Convert.ToInt32(row["Weight"]);
intPosition = Convert.ToInt32(row["Position"]);
ctrlOnForm = frmToProcess.strObjectName;
switch (ctrlOnForm.GetType().FullName)
{
case "textEdit":
break;
}
}
frmToProcess is the form in question. How do I get the the value out of strObjectName and link it onto the the form name so I can check it's properties (see bold part in code). It's almost as if I need to perform Macro substitution (from my old FoxPro days)!
Sorry if my description is confusing.
Thanks.
|
|
|
|
|
this.Controls.Find(strObjectName, true);
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
|
Hi all, I need help
I have a IE toolbar menu button: Generate
My flow is
After i click the Generate button, the link on my current website will appear in a:
Form1 > textBoxWebPageURL
Form the Form1.Designer.cs
this.textBoxWebPageURL.Location = new System.Drawing.Point(238, 13);
this.textBoxWebPageURL.Name = "textBoxWebPageURL";
this.textBoxWebPageURL.Size = new System.Drawing.Size(328, 20);
this.textBoxWebPageURL.TabIndex = 5;
this.textBoxWebPageURL.Text = "http://www.codeproject.com"; <-- Whereby i have to hardcode it
How do i make it auto capture the current website that i am browsing and the textbox will display the current website ?
Thank You
|
|
|
|
|