|
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>
|
|
|
|
|
.NET has its own built in ways of sending mail.
You want to read MSDN and look up the System.Net.Mail namespace and specifically the SmtpClient[^] class.
|
|
|
|
|
Dim message As New MailMessage("sender@address", "from@address", "Subject", "Message Text")<br />
Dim emailClient As New SmtpClient("Email Server Name")<br />
emailClient.Send(message)
That will do the job.
However, this code is one of the snippets in Visual basic, so how you didnt find it I dont know . And its not that hard to search google for this, and for possibly more reliable results try MSDN.
Lloyd J. Atkinson
|
|
|
|
|
You won't learn VB.NET by trying to copy code snippets off the web that you don't understand. This is a TERRIBLE way to send mail, as others said, the mail classes are built in. I would recommend reading my article on how to use google, it actually uses sending an email as an example. I would also recommend buying a book and working through it, learning how to program VB.NET incrementally instead of trying to learn how to copy and paste other people's code that is above your head.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
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
' **** 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
|
|
|
|
|
your posts have an edit button and a delete button. Please, please, ask your questions once only. Edit them if you need to change them, don't repost.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hello;
This seems to rather be VBScript and not VB.Net - which do you require help with?
VB.Net:
Public Shared Sub SendMail(ByVal mailTo As MailAddressCollection, ByVal mailFrom As String, _
ByVal mailSubject As String, ByVal mailPriority As System.Net.Mail.MailPriority, _
ByVal isHtmlFormat As Boolean, ByVal mailBody As String, _
Optional ByVal mailCC As MailAddressCollection = Nothing, _
Optional ByVal mailBcc As MailAddressCollection = Nothing, _
Optional ByVal mailFromDisplayName As String = Nothing)
Dim msg As New System.Net.Mail.MailMessage
For Each m As MailAddress In mailTo
msg.To.Add(m)
Next
If mailFromDisplayName Is Nothing Then
msg.From = New MailAddress(mailFrom)
Else
msg.From = New MailAddress(mailFrom, mailFromDisplayName)
End If
msg.Subject = mailSubject
msg.Priority = mailPriority
msg.IsBodyHtml = isHtmlFormat
If Not mailCC Is Nothing Then
For Each m As MailAddress In mailCC
msg.CC.Add(m)
Next
End If
If Not mailBcc Is Nothing Then
For Each m As MailAddress In mailBcc
msg.Bcc.Add(m)
Next
End If
msg.Body = mailBody
Dim smtpServer As New System.Net.Mail.SmtpClient()
smtpServer.Port = 25
smtpServer.Host = Convert.ToString(ConfigurationManager.AppSettings("SiteSMTP"))
Try
smtpServer.Send(msg)
Catch ex As Exception
Throw New Exception(String.Format("An error occurred sending an e-mail. The error recorded was {0}", ex))
End Try
End Sub
|
|
|
|
|
Hello,
How can I enable and disable modem via code?
Thanks
|
|
|
|
|
|
I recommend you start by reading the guide on how to ask questions. How does 'help me' make sense as a subject ? Everyone here wants help.
What is a bamp project and what is a glb file ? In what capacity do you want to add them ? Even if I knew what they were, I'm not sure I could answer you, because you are not clear on what you want.
According to the urban dictionary, a bamp is a person of low intellect. I'm sure this is not what you mean, so please explain yourself.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi,
I don have a code to open an existing excel spreadsheet.The Excel is in C: Drive.AM using the language as VB. Can anyone help me out???.
Thanks in advance
With Regards,
Samson
|
|
|
|
|
You are a glutton for punishment aren't you. In the last 20 minutes you could have searched and copy/pasted this solution many times over.
Now you want to spam the site. God I hope I'm not feeding a troll!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Have you tried just launching the .XLS files using Process.Start ??
|
|
|
|
|
Or have you tried saving the excel file as a csv file, then parsing its contents into the DataGridView control? (Using the Split could be a start)
Lloyd J. Atkinson
|
|
|
|
|
Hi..
Entry Level Prog in .net...
Now im doing project in billing software..
i want to secure my project..
i got USB id and Cpu id from client machine..
when i insert my USB(Pen drive) in my client..
At the time CPU id ill be "insert into USB permanently"...
i need solution for how to insert some datas or cpu id in usb....
Once insert key doesnt change when insert another system.. so easily protect my project....
Thx in Advance
By
Kannan.c
|
|
|
|
|
All you can do is to create a file on the stick and read/write the file. Hardly secure. There are hardware solutions out there that will do this, and without a file, but they are rather expensive.
|
|
|
|
|
Hi,
seems like most if not all USB memory sticks contain a unique ID, which you can obtain using WMI and Win32_DiskDrive (even as a regular user on Vista, as opposed to a hard disk's serial number). So I see two possible schemes where your software only runs with the stick present:
1.
have the USB serial number hardcoded in your app; have it contain code to retrieve and compare the serial number, and exit when no match is found.
Pro: simple
Con: the exe needs personalization
2.
instead of hardcoding it, have it stored in an encrypted way in a license file somewhere (could even be on the USB stick, does not matter); now have your app retrieve the hardware's serial number, and retrieve and decrypt the file, and compare both.
Pro: all customers can use the same exe
Con: you somehow must create and deliver the license files to your customers
Remark: for .NET apps, you still need some obfuscation, otherwise it is rather easy to patch a new serial number in there, and/or reverse engineer the encryption/decryption stuff.
|
|
|
|
|