|
Hi there,
I use a Setup-Project to deploy my application. Now i made a new Version - and want to deploy it as update - so i changed the version number in the setup-project -> it changed the ProductCode (absolutely correct) and the upgradecode stays the same (absolutely correct).
Now if I install the new version it overwrites the old version (as it should do) but it creates a second software entry (in "control panel" -> "add remove programs")
does anybody know how to avoid this?
thanks!!
|
|
|
|
|
I just bought a brand new laptop and installed a fresh copy of XP. I have tried a few times now to install VB.net and this same error keeps coming up. What is causing this? These cd's work fine on my desktop but do not work on the laptop. Any help would be great! =Brandon
|
|
|
|
|
Never heard of the message. Could you post the EXACT wording of the message?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm trying to do what should be a simple thing: watch a directory, and when a file appears read what's in the file. I'm using a FileWatcher to watch the directory, and that's working fine. What's not working is the StreamReader (actually it works once then starts failing).
Here's a code snippet from the handler routine that is set to process file creation events (I'm typing it in, so typos are mine, not in the code):
<br />
Private Sub processNewFile(Byval source As Object, ByVal e As FileSystemEventArgs)<br />
Dim message As String<br />
Dim sr As StreamReader<br />
<br />
Try<br />
' Uncomment the following to make it work<br />
' MsgBox("Be patient")<br />
sr = New StreamReader(e.FullPath)<br />
message = sr.ReadToEnd()<br />
sr.Close()<br />
MsgBox("The message is: " & message)<br />
Catch ex As Exception<br />
MsgBox("Dang...got an exception")<br />
End Try<br />
End Sub<br />
I test this by plopping files into the watched directory. The symptoms are as follows:
1) The first time I create a file in the watched directory it works perfectly.
2) Any subsequent attempt to create a file will cause the "new" statement to fail. The actual exception claims that the file is in use.
3) If I uncomment the commented lines in the code above (which causes a useless message box to appear) or if I add sufficiently long delay at that same point, it works perfectly.
By the way, if I take the exact same code and do it somewhere else (i.e. not in a handler for the filewatcher, just fire it off with a button click) it works perfectly, so clearly there's something about the context that's causing this.
Any ideas why this shouldn't work?
|
|
|
|
|
Hello,
I have recently had a similar problem with a message box being required to give the process a bit of a "break".
You could use a thread to stop the process for a couple of seconds, such as:
Edit:
Dim thread As Threading.Thread = New Threading.Thread(AddressOf TestSub)
Private Sub processNewFile(Byval source As Object, ByVal e As FileSystemEventArgs)
Try
thread.Start()
Catch ex As Exception
MsgBox("Dang...got an exception")
End Try
End Sub
And then create a new sub such as:
Sub TestSub()
'Your code goes here
End Sub
To pause your thread, all that you need to do is: thread.Sleep(1000)
Programmer2k4
My sig:
"The so-called 'Bugs' do not exist, they are merely features hidden by developers with message boxes that say 'An unhandled exception has occurred'." - Programmer2k4
"And it is a professional faux pas to pay someone else to destroy your computer when you are perfectly capable of destroying it yourself." - Roger Wright
I now use my CodeProject Blog!
|
|
|
|
|
Programmer2k4 wrote:
I have recently had a similar problem with a message box being required to give the process a bit of a "break".
Yes, but such tricks are symptomatic of not understanding what's going on under the covers. Adding sleeps/waits is dangerous since you need to determine what is the maximum time that you need in order to ensure success. You can't do that without understanding what's going on...and if you understand what's going on you shouldn't need the sleep in the first place!
I actually re-wrote the code to just keep trying to do the "new" and to count how many times it takes before it's successful. I then fired off a process on a machine running a real O/S (not this windows piece of ...oh nevermind), to just keep creating the file. The result is that the "new" always succeeds on the first iteration when the program is initially fired up. After that it may take anywhere from 4 to 25 iterations before being successful (usually around 6 or 7).
Clearly there's some sort of asynchronous issue going on here, but I can't figure out what the heck it is!
|
|
|
|
|
Glen Baker wrote:
Adding sleeps/waits is dangerous since you need to determine what is the maximum time that you need in order to ensure success.
True, but you could put the thread.sleep(300) inside of the Catch exc as exception . That way, it checks every 300 milliseconds if it is ready, and if not, it sleeps for another 300 milliseconds, until it eventually works.
I don't think there is any way to read/write to the file if it is returning a "File is already in use" error in previous tries.
Programmer2k4
My sig:
"The so-called 'Bugs' do not exist, they are merely features hidden by developers with message boxes that say 'An unhandled exception has occurred'." - Programmer2k4
"And it is a professional faux pas to pay someone else to destroy your computer when you are perfectly capable of destroying it yourself." - Roger Wright
I now use my CodeProject Blog!
|
|
|
|
|
Programmer2k4 wrote:
I don't think there is any way to read/write to the file if it is returning a "File is already in use" error in previous tries.
This is the crux of the whole issue. The file should not be in use! The StreamReader.Close() method has been called, the method has been exited. There should be no resources associated with the file (at least not with any reasonable operating system!). However clearly the O/S is maintaining some sort of handle to the file and something has to be kicked repeatedly in the butt to get the resources freed.
Unfortunately I can't for the life of me figure out what is holding onto the file, how to free it up, and why it eventually fixes itself.
Very frustrating.
|
|
|
|
|
StreamReader? I must be missing something here. The file is being written to disk by another process, your code tries to read the file when the FileSystemWatcher event fires (which will happen when the file is CREATED, not when it's completely written!) Your code attempts to read a file that is still being written and hasn't been flushed to disk and closed, correct?
The StreamReader/StreamWriter classes hold onto underlying Win32 file handles. Even though you called close on the Reader/Writer object, it would appear that the underlying, unmanaged, file handle hasn't been closed and released. This won't happen until the the Reader/Writer object is collect, which will call .Dispose() on the object. You can try calling .Dispose() yourself to free the underlying resources that your application holds.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
StreamReader? I must be missing something here. The file is being written to disk by another process, your code tries to read the file when the FileSystemWatcher event fires (which will happen when the file is CREATED, not when it's completely written!) Your code attempts to read a file that is still being written and hasn't been flushed to disk and closed, correct?
Ah...this is a plausible explanation! The first time that the handler gets called I notice that the system appears to load a dll (microsoft.visualbasic.dll). Subsequent iterations of the handler do not result in this dll being loaded. It may well be that the process of loading the dll is sufficient to delay things enough for the file write to complete, and therefore cause the StreamReader constructor to work.
From then on the dll is not loaded (it's already there), so the StreamReader constructor is called sooner, and as Dave points out the file may not be completely written yet, therefore causing the symptoms that I'm seeing.
Interestingly, trying to use read only handle doesn't solve this problem.
Hmm...makes me wonder how to properly use the FileWatcher at all.
Anyway, thanks Dave for pointing out the obvious. I'll now scratch my growing stubble and see if I can figure out a way to make this sucker work!
|
|
|
|
|
skifanatic wrote:
Interestingly, trying to use read only handle doesn't solve this problem.
That's because the other process has opened the file for write acces with DenyShareAll attributes. No other process on earth can open that file until the write is completed and the file is flushed and closed.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
That's because the other process has opened the file for write acces with DenyShareAll attributes.
The other process is samba (I'm dropping the file onto the Windows machine from my Linux machine...yes, I'm one of those annoying Linux people
|
|
|
|
|
Perhaps explicitly opening the files as readonly will help.
<br />
Dim sr As New IO.StreamReader(IO.File.OpenRead(e.FullPath))<br />
message = sr.ReadToEnd()<br />
sr.Close()<br />
I colleague of mine was having problems with trying to read, then upload, image files to a database. In the end, both the uploaded files and even the source files were getting hammered somehow, even though the code looked good. Opening the source files as readonly fixed the issue.
-- Dallas
|
|
|
|
|
I am trying to find a way to extract and send the contents of TEXT FILE 1, via email, to a list of email addresses in TEXT FILE 2.
So just to clarify, I would like some code which will rip the contents of Text File 1 and send the contents to everyone in Text File 2.
Any help received will be greatly appreciated.
Thanks,
|
|
|
|
|
Hello,
To read text from a file, here's some sample code: (can also be found in the VB .Net Help, under "reading text from files")
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader("TestFile.txt")
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
Console.WriteLine(Line)
Loop Until line Is Nothing
sr.Close()
To change it to write to a TextBox/RichTextBox all that you need to do is:
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader("TestFile.txt")
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
Textbox1.text += line
Loop Until line Is Nothing
sr.Close()
For sending an email, look at: sending mail, examples [Visual Basic] under the index section of the help. The System.Web.Mail is most likely what you will be using
Programmer2k4
My sig:
"The so-called 'Bugs' do not exist, they are merely features hidden by developers with message boxes that say 'An unhandled exception has occurred'." - Programmer2k4
"And it is a professional faux pas to pay someone else to destroy your computer when you are perfectly capable of destroying it yourself." - Roger Wright
I now use my CodeProject Blog!
|
|
|
|
|
I have a table of questions and related to it are a set of choices. My online test that I am creating requires me to pick out the question from a question table and display it on the page.
I am trying to iterate through my DataTable I have created and print out the questions on screen but I get the following error:
System.NullReferenceException: Object reference not set to an instance of an object.
My Code is as follows:
Dim AnswerArray(100) As String
Dim TesterArray(100) As String
Dim WrongArray(100) As String
Dim CorrectArray(100) As Boolean
Dim NumberOfQuestions As Integer
Dim NumberCorrect As Integer
Dim NumberWrong As Integer
Sub Page_Load(sender As Object, e As EventArgs)
if not IsPostBack
GetQuestions()
end if
End Sub
Public Sub GetQuestions()
'Create the SQL Connection
Dim connectionstring As String = "server='(local)'; trusted_connection=true; database='ELearn'"
Dim Oconnection As New SqlConnection (connectionString)
'oConnection.Open()
'Get the questions for the user and fill it into a data adapter
Dim strSQL As String
strSQL = "SELECT * FROM dbo_Private_Questions"
'Dim oCommand As New SqlCommand(strSQL, Oconnection)
Dim ds As System.Data.DataSet = New System.Data.DataSet
Dim da As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter(strSQL, connectionString)
'da.SelectCommand = oCommand
da.Fill(ds)
'Get the choices for the answer of each question and fill it into a data adapter
Dim choices As String
choices = "SELECT * FROM dbo_Choices"
da.Fill(ds)
'Create data tables for questions and choices so they can be iterated
Dim QuestionsTable As DataTable
QuestionsTable = ds.Tables("dbo_Private_Questions")
Dim ChoicesTable As DataTable
QuestionsTable = ds.Tables("dbo_Choices")
'Create a link between choices and questions
'Firstly get the datacolumn objects from the two datatables, create the relation with these
'columns
Dim parentCol As DataColumn
Dim childCol As DataColumn
parentCol = ds.Tables("dbo_Private_Questions").Columns("QuestionID")
childCol = ds.Tables("dbo_Choices").Columns("QuestionID")
Dim questionRelation As DataRelation
questionRelation = New DataRelation("QuestionLink", parentCol, childCol)
QuestionsTable.ChildRelations.Add(questionRelation)
NumberOfQuestions = 0
Dim questionRow As DataRow
for each questionRow in QuestionsTable.Rows
Dim tr1 As new TableRow
Table1.Rows.Add(tr1)
Dim aCell1 As new TableCell
aCell1.Text = questionRow("Question Text").ToString()
tr1.Cells.Add(aCell1)
AnswerArray(NumberOfQuestions) = questionRow("Answer").ToString()
dim count as integer = 0
Dim choiceRow As DataRow
for each choiceRow in questionRow.GetChildRows(questionRelation)
Dim tr2 As new TableRow
Table1.Rows.Add(tr2)
Dim aCell2 As new TableCell
aCell2.HorizontalAlign = HorizontalAlign.Left
tr2.Cells.Add(aCell2)
Dim cb as new CheckBox
cb.Text = choiceRow("Choice Text").ToString()
cb.ID = "CheckBox" + NumberOfQuestions.ToString() + Convert.ToChar(count + 65)
cb.Visible = true
aCell2.Controls.Add(cb)
next
Next
End Sub
I get the error for the for loop i.e. for each questionRow in QuestionsTable.Rows and also when creating the relation:
parentCol = ds.Tables("dbo_Private_Questions").Columns("QuestionID")
Is there anyone out there who can help sort it.
Thanks
Kav
|
|
|
|
|
ug39kxt@cs.bham.ac.uk wrote:
I get the error for the for loop i.e. for each questionRow in QuestionsTable.Rows and also when creating the relation:
parentCol = ds.Tables("dbo_Private_Questions")Columns("QuestionID")
The code doesn't lend itself to easily finding out so. One of the following is returning null:
ds
ds.Tables("dbo_Private_Questions")
ds.Tables("dbo_Private_Questions")Columns("QuestionID")
So, put some watches in (or debugging statements if you prefer) to find out what part of your statement is returning null.
Cada uno es artifice de su ventura
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
I have the error always occurs when trying to access the DataTable object in a DataSet:
parentCol = ds.Tables("dbo_Private_Questions").Columns("QuestionID")
childCol = ds.Tables("dbo_Choices").Columns("QuestionID")
for each questionRow in QuestionsTable.Rows
....
for each choiceRow in questionRow.GetChildRows(questionRelation)
...
The error occurs on these 4 lines. Creating the data table doesn't bring an error.
|
|
|
|
|
NB. I am using web matrix - free tool by microsoft - if that is any help
|
|
|
|
|
It's entirely possible that Tables("dbo_Private_Questions") doesn't return a DataTable object. This would mean that there is no table in the DataSet called "dbo_Private_Questions". The same could be true for the Columns collection of that table. Meaning there is no column called "QuestionID" in the Table object. The same could also be true for the DataSet not having a table in it called "dbo_Choices"...
Get the picture yet? Your code is assuming that these table and columns exist in the dataset. You need to write some code in there to check if they actually do exist before you use them.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a complete ASP web application. Now I want it to convert to VB.NET application. And the apllication can install in each computer. Is there any fast way to do it without hand by hand coding? PLEASE GIVE ME A HIT OF IT! THANKS A LOT!!
Lisa
|
|
|
|
|
You want to convert and ASP web app to a Windows Forms app? Start coding by hand. AFAIK , there's no tool that will do this, mainly because the execution models are so radically different.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
Can someone help me out with this urgent problem I am facing.
I have an Windows service whose components are controlled by a snap-in.
Now I need to create multiple instances of this service and snap-in on the same machine.
I am not able to latch the snap-in the instance I want to though both the instance use different users. The snap-in latches itself to the classed in the service via DCOM.
Excepting a quick reply.
What you cannot visualize you cannot achieve.
|
|
|
|
|
Please tell me what are the difference between RecordSet and ResultSet
|
|
|
|
|
AFAIK the two terms are used interchangably
|
|
|
|