|
That's exactly what I was looking for Dave and your warning is duly noted.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I have been trying unsuccessfully to get serialization to work over a network stream. I can get serialization to work when using a Filestream, so I think this means I am doing the serialization/deserialization part correct. I have gone so far as to just serialize a 16 bit integer, and still I get the IO Exception on deserialization:
End of Stream encountered before parsing was completed.
I have checked the lengths of the Filestream and the Networkstream and they both are identical. I have printed byte by byte the data sent through the Networkstream, and the data Recieved from the client Networkstream. Here are examples of how I serialize then send, and read data and then deserialize.
**************************Send Code*************************************************
Dim Test As Int16 = 88
'This Is Just A Compare For The FileStream To The Networkstream, and servers no other puprose
Dim DataFile As New System.IO.FileStream("c:\del1.bin", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None)
Serializer.Serialize(DataFile, Test)
DataFile.Close()
'Note The Length Of The DataFile Stream Is 52
Dim memStream As New System.IO.MemoryStream()
Serializer.Serialize(memStream, Test)
Dim buffer As Byte() = memStream.GetBuffer()
Debug.Print("Send Length = " + memStream.Length.ToString)
'Displays: Send Length = 52
Dim tt As String = ""
For i As Int16 = 0 To memStream.Length - 1
tt = tt + buffer(i).ToString + ","
Next
Debug.Print(tt)
'Displays: 0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,4,1,0,0,0,12,83,121,115,116,101,109,46,73,110,116,49,54,1,0,0,0,7,109,95,118,97,108,117,101,0,7,88,0,11,
********************************************END SEND CODE**********************************************************************
********************************************Begin Receive Code*****************************************************************
Dim TCPClientsBytes(aryClients(intIndex).ReceiveBufferSize) As Byte
If aryClients(intIndex).GetStream.CanRead = True Then
intBytesRead = aryClients(intIndex).GetStream.Read(TCPClientsBytes, 0, CInt(aryClients(intIndex).ReceiveBufferSize))
End If
Dim Data As Int16 = 0
Dim Deserializer As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim mem As New System.IO.MemoryStream
mem.Write(TCPClientsBytes, 0, returndata.Length.ToString)
Debug.Print("Receive Length = " + mem.Length.ToString)
'Displays: Receive Length = 52
Dim tt As String = ""
For i As Int16 = 0 To mem.Length - 1
tt = tt + TCPClientsBytes(i).ToString + ","
Next
Debug.Print(tt)
'Displays: 0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,4,1,0,0,0,12,83,121,115,116,101,109,46,73,110,116,49,54,1,0,0,0,7,109,95,118,97,108,117,101,0,7,88,0,11,
Try
'The statement below will throw an exception.....
Data = CType(Deserializer.Deserialize(mem), Int16)
Catch ex As Exception
Debug.Print(ex.Message)
'The exception text is below......
'A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
'End of Stream encountered before parsing was completed.
End Try
********************************************EndReceive Code*****************************************************************
Any help would be greatly appreciated!!!!!
|
|
|
|
|
|
Hello all
I need help to count node and their respective id.
<People>
<Person ID="001"> 1 </Person>
<Person ID="002"> 2 </Person>
</People>
how can i count person node..?? and Person Id = 001 & 002
Thanx in advance..
Shazz here to help you...
|
|
|
|
|
Assuming that People is the root of the document, you can iterate the nodes like this.
- Assumes the ID's are integers, you can change it to String if you want.
- written without syntax checking. Sorry if its a bit off, but you can get the idea.
Imports System.Xml
Private Sub CountNodes(xmlDoc as XmlDocument)
Dim xNode as XmlNode
Dim nodeName as String
Dim nodeCount as Integer
Dim listOfIDs as New List(Of Integer)
For Each xNode in xmlDoc.DocumentElement.ChildNodes
If String.IsNullOrEmpty(xNode.Name) = False Then
nodeName = xNode.Name.Trim().ToLower()
If nodeName = "person" Then
nodeCount++
If node.Attributes("ID") IsNot Nothing Then
listOfIDs.Add(Convert.ToInt32(node.GetAttributeValue("ID")))
End If 'node attr
End If 'node name
End If 'node has name
Next 'xNode
End Sub
You can also use Xpath Query to do the same, or if the nodes can be nested you will need a recursive function.
|
|
|
|
|
Thanx for your refernce code.
Partially its working fine though I am using VB6.0 application and your mention code belong to vb.net.
I am slight confuse for declaration of `Node` because non of IXMLDom related datatype have properties of GetAtttributeValues("ID").
Please guide me how can I proceed. I had search and i tried many things help.
Refernece as I had used "Microsoft XML v6.0"
Thanx in advance. Awaiting for your reply.
Shazz here to help you...
|
|
|
|
|
Sorry, I no longer have VB6 available to help you with this exactly.
The GetAttributeValues() method will get the value of an XMLNode (element)'s attribute. I cant find any IXMLDom documentation to look for a similar function, but if you can post a link I can try to find it.
|
|
|
|
|
Hello guys!!!!
I want more information about API call any articles and notes is there plzz send that link.
Ananda
|
|
|
|
|
This is a non question. Did you just read the term 'API' on the toilet ? WPF has an API, ADO.NET has an API, GDI+ has an API. What the hell are you trying to ask ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
no actual i want create an API for chart. but I don't know to do so I want API. Already one chart control in vb.net but it is not suitable for my application and i tried some 3rd party chart tool but i can't get suitable control i want to know abt API control. and some of other customize control also need so i need some article or note etc... plzzz send the link..
|
|
|
|
|
non-bugging Errors wrote: i want create an API for chart
Wow - one has wonder how you think your question to do this would be helped by answers to the question you asked.
non-bugging Errors wrote: i want to know abt API control. and some of other customize control also need so i need some article or note etc... plzzz send the link..
I'll be honest. None of this makes any sort of sense. Certainly your first question was useless. There's tons of charting controls out there, there's nothing built in, although I think MS are giving away a charting library nowadays, you'll need to search to find out if this is so.
I recommend you read one of the many articles on how to ask reasonable questions because I guarentee you, no-one stood any chance of knowing what you wanted from your first question.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: Wow - one has wonder how you think your question to do this would be helped by answers to the question you asked.
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
I'm saying that he asked his first question, and his first question didn't contain ANY info that related to what he actually wanted to do, as shown in his response. So, if people had just answered his OP, no way he'd have got any help, b/c he didn't actually ask about what he wanted to know.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Don't know why you got voted down. Your response was reasonable considering the vagueness of the OP's request.
|
|
|
|
|
I guess because I didn't provide code to copy and paste ? :P
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi,
this link[^] explains API and provides some examples.
|
|
|
|
|
Hello,
I am struggling with API calls from VB.net. Basically, it is fine but a problem occurs when I try to call API which needs arrays to be passed.
API specification:
Public Declare Function spssGetVarNValueLabels Lib "spssio32.dll" Alias "spssGetVarNValueLabels@20" (ByVal handle As Integer, ByVal varName As String, ByRef values() As Double, ByVal labels() As String, ByRef numofLabels As Integer) As Integer
VB.NET call:
Dim handle As Integer = 0
Dim varname As String = "subject"
Dim numvallabs As Integer
Dim values(10) As Double
Dim labels(10) As String
erro = spssGetVarNValueLabels(handle, varname, values, labels, numvallabs)
No problems: handle, varname, numvallabs. In addition, I get correct value via "numvallabs".
But routine should return two arrays via values (double) and labels (string) and this is the problem. I have tried other similar API calls (integers or strings only) and everything was fine. But arrays are pain.
Since I read some topics how bridge the differences between C and VB, I have also tried to replace string variable for byte() or pass only the first element of array - but nothing helped. Current version return first element of doubled-array and nothing for string-array.
Full working code is enclosed: http://dev.zizkovi.name/anxiety.zip
Many thanks for any help in advance.
Petr
P.S. Background info: sav file is binary file used by SPSS Application. This DLL library is designated to read those files, etc.
Here is the sample code of mentioned call in C++ - published by vendor of used API:
#include <stdio.h>
#include "spssdio.h"
void func()
{
int fH;
int error;
int numL;
double *nValuesL;
char **labelsL;
...
error = spssOpenRead("bank.sav", &fH);
...
error = spssGetVarNValueLabels(fH, "SEX",
&nValuesL, &labelsL, &numL);
if (error == SPSS_OK)
{
int i;
printf("Value labels for SEX\n");
for (i = 0; i < numL; ++i)
{
printf("Value: %g, Label: %s\n", valuesL[i], labelsL[i]);
}
spssFreeVarNValueLabels(nValuesL, labelsL, numL);
}
}</stdio.h>
|
|
|
|
|
This sounds like a problem with how .NET is marshalling the arrays between the Managed and Unmanaged code. You'll need to research .NET Marshalling (Interop). There are generally some attributes that you can apply to the parameters that will instruct the Marshaller how to work with them correctly.
Keep It Simple Stupid! (KISS)
|
|
|
|
|
One thing that I have noticed with any API call that I use in my applications: Integer does not work properly with WinAPI; use Int32 as the default data type for integer objects.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Hi I need to convert HTML into RTF.
becourse I did not find a nice solution I let word do it
Sub HTML2RTF(ByVal oWord As Microsoft.Office.Interop.Word.Application, ByVal sHTMLFileName As String)
Const wdStory = 6
Const wdLine = 5
Const wdExtend = 1
Const wdCharacter = 1
Const wdFormatRTF = 6
With oWord
.Documents.Open(FileName:=sHTMLFileName)
.Selection.EndKey(Unit:=wdStory)
.Selection.MoveUp(Unit:=wdLine, Count:=2, Extend:=wdExtend)
.Selection.EndKey(Unit:=wdLine, Extend:=wdExtend)
.Selection.Delete(Unit:=wdCharacter, Count:=1)
Dim fi As New IO.FileInfo(sHTMLFileName)
Dim sRTFFileName As String = fi.FullName.Substring(0, fi.FullName.Length - fi.Extension.Length) & ".rtf"
.ActiveDocument.SaveAs(FileName:=sRTFFileName, FileFormat:=wdFormatRTF)
.ActiveWindow.Close()
End With
End Sub
However this in not the way to do it! Has someone a good idee
|
|
|
|
|
Word seems like a good way to me. There's nothing build in anywhere, your other option is to write your own conversion code.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks
Again MS failed to do something usefull
Jan
|
|
|
|
|
jan212r wrote: Again MS failed to do something usefull
Really?? Useful to how many people?? That number determines if it's going to be worth the effort or not. When dealing with RTF and HTML, it usually gets converted from RTF to HTML, not the other way around.
|
|
|
|
|
Hi, thanks for looking
Im having a little problem here
I have a website, in this website i have a webservice with a few webmethods, i dont want anyone calling these methods unless the have permisions (In fact, im calling them from a win app)
In my site im using forms authentication
So, before calling any webmethod i call the SignIn Method
I am currently using the first method because the second one doesnt work when called from win app
I dont know why, i saw examples that stated that it works as well
Method that works either when called from win app or with my browser
<WebMethod()> _
Public Function SignIn(ByVal Nick As String, ByVal Password As String) As Boolean
If Not Membership.ValidateUser(Nick, Password) Then Return False
Dim ticket As New FormsAuthenticationTicket(1, Nick, Now, Now.AddYears(1), True, "")
Dim strEncryptedTicket As String = FormsAuthentication.Encrypt(ticket)
Dim cookie As New HttpCookie(FormsAuthentication.FormsCookieName, strEncryptedTicket)
Context.Response.Cookies.Add(cookie)
Return True
End Function
Method that only works when i use it with my browser
<WebMethod()> _
Public Function SignIn(ByVal Nick As String, ByVal Password As String) As Boolean
If Not Membership.ValidateUser(Nick, Password) Then Return False
FormsAuthentication.SetAuthCookie(Nick, True)
Return True
End Function
Example of method that i can call only after ive called the SignIn method (with true as result)
<WebMethod()> _
Public Function HelloWorld() As String
If Not User.Identity.IsAuthenticated Then Return ""
Return "Hello World"
End Function
In my win app i am using the cookiecontainer
As i told you, it works with the first singin method but not with the second
I used this page as a reference:
http://blog.webgear.co.nz/archive/2007/11/23/forms-authentication-in-web-services.aspx[^]
Im not quite sure, but i think that since i added this webservice, ive started to receive the following error (This error is causing all autenthicated users (Users of the web portal as well as users of the webservice) to be logout and have to log in again):
System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.
at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)
at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Boolean useValidationSymAlgo)
at System.Web.UI.Page.DecryptString(String s)
at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Thanks in advance for any feedback
Alexei Rodriguez
|
|
|
|
|
i am new to vb.net.
i would like to create a class for sending emial . i tried the script online but i failed to send.
So i got this code below from the hosting server.
May i know how do i simplify the below script to just receive
FromEmail, Subject, Message ?
why it needs the mailerpath?mailerport? and errText? isn't we can check those error in the form instead of class ?
Please kindly advice. thanks
<pre>
' **** MailerPath = Your SMTP path (for eg: mail.[domain].com) ***
function CDOSYS_Mailer(Message, FromEmail, ToEmail, FromName, ToName, Subject, MailerPath, MailerPort, errText, searchURL)
on error resume next
dim Mailer
set Mailer = server.createobject("CDO.Message")
if err.number <> 0 then
errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description)
CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0
exit function
end if
Mailer.From = FromName & " <" & FromEmail & ">"
Mailer.To = ToName & " <" & ToEmail & ">"
Mailer.TextBody = Message
Mailer.Subject = Subject
with Mailer.Configuration
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MailerPath
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = MailerPort
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")="test@yourdomain.com"
.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")="youremailpassword"
.Fields.Update
end with
Mailer.Send
if err.number <> 0 then
errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description)
CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0
exit function
end if
set Mailer = Nothing
CDOSYS_Mailer = true
end function</pre>
|
|
|
|
|