|
I've been working on a small function today that is confounding me to no end. I have a file that is one line, the file size is ~400k bytes, and is a list of items delineated by a '~'.
The funny thing is, I can see the data on the stream while viewing in the debugger, but the data doesn't get assigned to the variable, no matter what it is. (note: I've tried assigning to regular strings and to the stringbuilder class as well, without the Split() of course )
The errant piece of code looks like this:
<br />
Dim al as New ArrayList<br />
<br />
m_istream = New StreamReader(m_ipath)<br />
al = al.Adapter(m_istream.ReadToEnd().Split("~"c))<br />
I've tried this with much success on smaller strings(not streams), and I don't understand why this assignment isn't working. Could someone give me a hand please?
Thanks in advance.
Jason
P.S. I'm using VS 2003
-- modified at 13:40 Monday 6th August, 2007
"In the middle of difficulty lies opportunity." Albert Einstein
|
|
|
|
|
First, what's that "Adapter"??
Second, break the line up so you can see what's going on with the debugger, step-by-step:
m_istream = New StreamReader(m_ipath)
Dim data As String = m_istream.ReadToEnd()
Dim items As String() = data.Split("~"c)
' I have no idea what "al" is and what the "Adapter" method is.
al = al.Adapter(items)
|
|
|
|
|
Thanks for the help.
<br />
Dim data As String = m_istream.ReadToEnd()<br />
'data' is null after the the call to ReadToEnd(),even though I can see data returned from this function in the debugger. This is the problem that has been plaguing me. It seems that I can't assign anything off the stream to a variable. I'm at a loss as to why.
The 'al' is an ArrayList, a very useful enumerated array type, the Adapter() method takes an IList object(string array in this case.) and converts it to an ArrayList. Just FYI.
Jason
-- modified at 14:06 Monday 6th August, 2007
for clarity, here is the exact code block:
<br />
Try<br />
m_istream = New StreamReader(m_ipath)<br />
m_al = m_al.Adapter(m_istream.ReadToEnd().Split("~"c))<br />
Return True<br />
Catch ex As Exception<br />
Return False<br />
Throw New Exception("Error Reading File! See InnerExcpetion.", ex)<br />
Finally<br />
m_istream.Close()<br />
End Try<br />
"In the middle of difficulty lies opportunity." Albert Einstein
|
|
|
|
|
Payrok wrote: The 'al' is an ArrayList
It would help if you explained what types were involved in the code. From what you posted, there's no way to tell that al was an ArrayList .
Well, you can try it like this then:
Dim data As String() = File.ReadAllText(m_ipath)
For Each s As String In data
Dim items As String() = s.Split("~"c)
al = al.Adapter(items)
Next
|
|
|
|
|
Sorry about that. I thought that I had, but I get ahead of myself sometimes. I should have realized that you knew what an arraylist was, I wasn't trying to be condesending. I'll give the File.ReadAllText a whirl.
Thanks again.
Jason
"In the middle of difficulty lies opportunity." Albert Einstein
|
|
|
|
|
Is that method for 1.1 framework? I'm not seeing it.
"In the middle of difficulty lies opportunity." Albert Einstein
|
|
|
|
|
|
it turns out that the while I was trying to watch the data in the debugger, the data was consumed, never to ne seen again, thus preventing anything I was attempting. I feel like such a dope. Anyways, thank you for the help Dave, and I apologize again for the comment.
Jason
"In the middle of difficulty lies opportunity." Albert Einstein
|
|
|
|
|
No problem. Even the pro's lose their minds once in a while!
|
|
|
|
|
I have developed a small database software in .Net 2.0 which has backend as Sql Server Express2005.Both of the server and client are running Windows XP. My client successfully detects the server but when
connecting to the server, it displays the error message "Cannot generate SSPI context".
I have also searched the internet but couldnot find any good solutions.
Could you people have any solution for this terrible error?
Help appreciated in both VB.Net and C#.
X
|
|
|
|
|
We'll have to see the code that generated this error. It would also help if you showed the connection string you're using to connect to the database.
|
|
|
|
|
Here is the code:
Server computer name is stored in My.Settings.Server property.
Public Shared Function RetCn() As SqlConnection
Dim sqlCnB As New SqlConnectionStringBuilder
sqlCnB.DataSource = My.Settings.Server & "\SQLEXPRESS"
sqlCnB.InitialCatalog = "CompA"
sqlCnB.IntegratedSecurity = True
sqlCnB.UserInstance = False
Dim sqlCn As New SqlConnection(sqlCnB.ConnectionString)
Return sqlCn
End Function
X
|
|
|
|
|
OK, this is .NET 3.0 because of the ConnectionStringBuilder class....
You cannot use Integrated Security if the two machines are not in a domain environment. If both of your machines are in workgroup mode, you MUST turn off Integrated Security and supply a username and password to get into the database.
Integrated Security uses the current users security token to login to the other machine. Since in workgroup mode, each machine maintains its own user database, the security token generated on one machine is not valid on the other.
Also, SQL Server uses two authenitcation mechanisms. Turning on Intergrated Security, or Trusted Connection, tells the connection string that the SQL Server is using Windows Integrated Security, instead of SQL Server Authentication. Using Windows Security means that the SQL Server will trust and use the machines user accounts (the machine the SQL Server is running on) for security ID's.
|
|
|
|
|
Hi guys,
Is there a way/control for previewing any document supported by the a windows system from vb.net?:->
thanks:->
|
|
|
|
|
Hi,
the Process.Start() method lets you open a document, using the application that got
associated to the file's extension. It is equivalent to double-clicking a file in
Windows Explorer; so al of this happens outside your app.
the WebBrowser class lets you open a number of document types (mtml, doc, ppt, xls, ...)
inside your app.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi,
The WebBrowser control is actually doing what I want, thanks. For PDF, picture formats etc its working fine i.e. it opens the file and displays it within the browser control, but when it comes to office documents, I get a File Download dialog box which then goes on to start the office application and open the document there or downloads the file to disk. Is there a way around this so that even office type documents are loaded but their applications are embedded within the WebBrowser control?
Thanks,
|
|
|
|
|
Hi,
Seems like yours is a web app, not a Windows app; I dont know for these.
I have been using shdocvw.dll (the precursor of WebBorwser) since .NET 1.1 in Win app,
and it shows office documents without dialogs.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
If you're talking about how you see it in Explorer, where you single-click on a file, say a JPG, and you see a smalle preview in the Explorer window, then no there isn't.
You'd have to write a parser, and renderer, for every document type you want to support. That's just not feasible.
|
|
|
|
|
Hi Dave
Thanks for your response, however i think u should take a look at this link:
http://www.gamedev.net/community/forums/mod/journal/journal.asp?jn=266903&cmonth=11&cyear=2005
Its possible to have thumbnails, also using the WebControl allows u to open most documents effortlessly. Just:
WebControl1.Navigate("c:\book.pdf")
Thanks
|
|
|
|
|
Yeah, but for that to work, you have to have something installed that knows what a PDF is and how to render it, like Adobe Acrobat Reader. Without it, the web browser control doesn't know a damn thing about the PDF and can't render it. The same goes for Excel files, Word documents, AutoCad drawings, ...
|
|
|
|
|
Hi
I m using VS.NET 2003. I m workling on web application using VB.Net.
Problem is that, when i run the project it takes so much time as compare to other projects of web applications and if i place break point in my application then it does not move line by line after the break point,to continue i have to run it again.
my other web projects are working well but having problem in this mentioned application.
Can anyone know why it is happening?
|
|
|
|
|
You have compiled your project in Debug mode, not Release mode, yes?
-------------------------------------------
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Just bugger off and leave me alone!!
|
|
|
|
|
I complied my project in Debug mode.
|
|
|
|
|
Dear All,
I am using VB.Net 2003 and MS Access 2003. My project is running and time to time arise an error. Sometimes it appears as OutofMemory exception and other time as follows.
An unhandled exception of type 'System.StackOverflowException' occurred in system.windows.forms.dll
What can I do for this.
Dimuthu
|
|
|
|
|
It means a function is calling itself until the stack is full, generally this means a recursive function that does not unwind, or an event is being fired by code that handles that event, so it gets fired over and over
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|