Search Results

Search found 6 results on 1 pages for 'financialraddeveloper'.

Page 1/1 | 1 

  • Binary stream 'NN' does not contain a valid BinaryHeader. Possible causes are invalid stream or obje

    - by FinancialRadDeveloper
    I am passing user defined classes over sockets. The SendObject code is below. It works on my local machine, but when I publish to the WebServer which is then communicating with the App Server on my own machine it fails. public bool SendObject(Object obj, ref string sErrMsg) { try { MemoryStream ms = new MemoryStream(); BinaryFormatter bf1 = new BinaryFormatter(); bf1.Serialize(ms, obj); byte[] byArr = ms.ToArray(); int len = byArr.Length; m_socClient.Send(byArr); return true; } catch (Exception e) { sErrMsg = "SendObject Error: " + e.Message; return false; } } I can do this fine if it is one class in my tools project and the other class about UserData just doesn't want to know. Frustrating! Ohh. I think its because the UserData class has a DataSet inside it. Funnily enough I have seen this work, but then after 1 request it goes loopy and I can't get it to work again. Anyone know why this might be? I have looked at comparing the dlls to make sure they are the same on the WebServer and on my local machine and they look to be so as I have turned on versioning in the AssemblyInfo.cs to double check. Edit: Ok it seems that the problem is with size. If I keep it under 1024 byes ( I am guessing here) it works on the web server and doesnt if it has a DataSet inside it.k In fact this is so puzzling I converted the DataSet to a string using ds.GetXml() and this also causes it to blow up. :( So it seems that across the network something with my sockets is wrong and doesn't want to read in the data. JonSkeet where are you. ha ha. I would offer Rep but I don't have any. Grr

    Read the article

  • Sending large serialized objects over sockets is failing only when trying to grow the byte Array, bu

    - by FinancialRadDeveloper
    I have code where I am trying to grow the byte array while receiving the data over my socket. This is erroring out. public bool ReceiveObject2(ref Object objRec, ref string sErrMsg) { try { byte[] buffer = new byte[1024]; byte[] byArrAll = new byte[0]; bool bAllBytesRead = false; int iRecLoop = 0; // grow the byte array to match the size of the object, so we can put whatever we // like through the socket as long as the object serialises and is binary formatted while (!bAllBytesRead) { if (m_socClient.Receive(buffer) > 0) { byArrAll = Combine(byArrAll, buffer); iRecLoop++; } else { m_socClient.Close(); bAllBytesRead = true; } } MemoryStream ms = new MemoryStream(buffer); BinaryFormatter bf1 = new BinaryFormatter(); ms.Position = 0; Object obj = bf1.Deserialize(ms); objRec = obj; return true; } catch (System.Runtime.Serialization.SerializationException se) { objRec = null; sErrMsg += "SocketClient.ReceiveObject " + "Source " + se.Source + "Error : " + se.Message; return false; } catch (Exception e) { objRec = null; sErrMsg += "SocketClient.ReceiveObject " + "Source " + e.Source + "Error : " + e.Message; return false; } } private byte[] Combine(byte[] first, byte[] second) { byte[] ret = new byte[first.Length + second.Length]; Buffer.BlockCopy(first, 0, ret, 0, first.Length); Buffer.BlockCopy(second, 0, ret, first.Length, second.Length); return ret; } Error: mscorlibError : The input stream is not a valid binary format. The starting contents (in bytes) are: 68-61-73-43-68-61-6E-67-65-73-3D-22-69-6E-73-65-72 ... Yet when I just cheat and use a MASSIVE buffer size its fine. public bool ReceiveObject(ref Object objRec, ref string sErrMsg) { try { byte[] buffer = new byte[5000000]; m_socClient.Receive(buffer); MemoryStream ms = new MemoryStream(buffer); BinaryFormatter bf1 = new BinaryFormatter(); ms.Position = 0; Object obj = bf1.Deserialize(ms); objRec = obj; return true; } catch (Exception e) { objRec = null; sErrMsg += "SocketClient.ReceiveObject " + "Source " + e.Source + "Error : " + e.Message; return false; } } This is really killing me. I don't know why its not working. I have lifted the Combine from a suggestion on here too, so I am pretty sure this is not doing the wrong thing? I hope someone can point out where I am going wrong

    Read the article

  • ExecuteNonQuery on a stored proc causes it to be deleted

    - by FinancialRadDeveloper
    This is a strange one. I have a Dev SQL Server which has the stored proc on it, and the same stored proc when used with the same code on the UAT DB causes it to delete itself! Has anyone heard of this behaviour? SQL Code: -- Check if user is registered with the system IF OBJECT_ID('dbo.sp_is_valid_user') IS NOT NULL BEGIN DROP PROCEDURE dbo.sp_is_valid_user IF OBJECT_ID('dbo.sp_is_valid_user') IS NOT NULL PRINT '<<< FAILED DROPPING PROCEDURE dbo.sp_is_valid_user >>>' ELSE PRINT '<<< DROPPED PROCEDURE dbo.sp_is_valid_user >>>' END go create procedure dbo.sp_is_valid_user @username as varchar(20), @isvalid as int OUTPUT AS BEGIN declare @tmpuser as varchar(20) select @tmpuser = username from CPUserData where username = @username if @tmpuser = @username BEGIN select @isvalid = 1 END else BEGIN select @isvalid = 0 END END GO Usage example DECLARE @isvalid int exec dbo.sp_is_valid_user 'username', @isvalid OUTPUT SELECT valid = @isvalid The usage example work all day... when I access it via C# it deletes itself in the UAT SQL DB but not the Dev one!! C# Code: public bool IsValidUser(string sUsername, ref string sErrMsg) { string sDBConn = ConfigurationSettings.AppSettings["StoredProcDBConnection"]; SqlCommand sqlcmd = new SqlCommand(); SqlDataAdapter sqlAdapter = new SqlDataAdapter(); try { SqlConnection conn = new SqlConnection(sDBConn); sqlcmd.Connection = conn; conn.Open(); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.CommandText = "sp_is_valid_user"; // params to pass in sqlcmd.Parameters.AddWithValue("@username", sUsername); // param for checking success passed back out sqlcmd.Parameters.Add("@isvalid", SqlDbType.Int); sqlcmd.Parameters["@isvalid"].Direction = ParameterDirection.Output; sqlcmd.ExecuteNonQuery(); int nIsValid = (int)sqlcmd.Parameters["@isvalid"].Value; if (nIsValid == 1) { conn.Close(); sErrMsg = "User Valid"; return true; } else { conn.Close(); sErrMsg = "Username : " + sUsername + " not found."; return false; } } catch (Exception e) { sErrMsg = "Error :" + e.Source + " msg: " + e.Message; return false; } }

    Read the article

  • Excel VBA Application.OnTime. I think its a bad idea to use this... thoughts either way?

    - by FinancialRadDeveloper
    I have a number of users I support that are asking for things to happen automatically ( well more automagically but that's another point!). One want events to happen every 120 secs ( see my other question ) and also another wants 1 thing to happen say at 5pm each business day. This has to be on the Excel sheet so therefore VBA as addins etc will be a no no, as it needs to be self contained. I have a big dislike of using Application.OnTime I think its dangerous and unreliable, what does everyone else think?

    Read the article

  • VBA Macro On Timer style to run code every set number of seconds, i.e. 120 seconds

    - by FinancialRadDeveloper
    I have a need to run a piece of code every 120 seconds. I am looking for an easy way to do this in VBA. I know that it would be possible to get the timer value from the Auto_Open event to prevent having to use a magic number, but I can't quite get how to fire off a timer to get something to run every 120 seconds. I don't really want to use an infinite loop with a sleep if I can avoid it. EDIT: Cross-post based on an answer provided is at: http://stackoverflow.com/questions/2341762/excel-vba-application-ontime-i-think-its-a-bad-idea-to-use-this-thoughts-eit

    Read the article

  • Send A DataSet via Sockets in .NET

    - by FinancialRadDeveloper
    I had written a Web Service to return a DataSet back to my ASP.Net site and this was working fine. However due to security issues and also the ability to get certain references installed, I have to move this to an App Server and so doing it as a Windows Service and communicating with the ASP.Net site now via sockets. Is there a way I can easily give the Website a serialized DataSet via Sockets from my App Server so I can read this in and then just carry on using the code I currently have to bind this to a GridView?

    Read the article

1