|
As Dave said.
unless you didn't create, or cause the creation, of the object (as in Brushes.Black ).
|
|
|
|
|
There is a blog discussing Dispose on MSDN; when-to-call-dispose[^]
There is also a link within the blog on in depth guidelines on use and implementation of Dispose .
As you will see at the bottom of the Blog there is a summary guidance section details the MUST category and the Maybe's.......
|
|
|
|
|
I have a VB6 ActiveX EXE that I wrote some time ago and a VB6 application that references it. I am writing a C# version of that VB6 application.
In VB6 you can run the ActiveX EXE project in the IDE and set a reference to that ActiveX EXE VBP file in the other application's References. This lets you run both the application and the ActiveX EXE in their respective IDE's and step through the code in the application as well as the code in the ActiveX project.
I can find no way to set a reference to the VBP file in C#. I set the reference to the EXE file and my C# program works fine, but I miss being able to step through the ActiveX EXE code when debugging.
Is there some way to do this in C#?
I am using VS2005 for this project but I also have VS2010 installed.
Thanks in advance.
chiselca
|
|
|
|
|
You can't set a reference to a .VBP file, which would be the project file in VB6.
Debugging VB6 code is not supported in the .NET versions of Visual Studio.
[EDIT]
Let me rephrase that. You cannot modify VB6 code from VS2005 or 2010. You can step through it and still see it, so long as you're running the Debug version of your VB6 code and the source file can be found.
|
|
|
|
|
Dave,
I am not sure I understand what you mean. Are you suggesting that if I set a breakpoint in my C# project on a line of code that calls into my VB6 EXE, that I can step through the VB6 project's source code in the Visual Studio IDE if I compile with symbolic Debug info?
I have never done this so I am not sure how to set it up.
Any help would be appreciated.
chiselca
|
|
|
|
|
There's nothing to setup. You compile your VB6 .DLL as Debug instead of Release. Then, in your C# project, you add a reference to the Debug version of the resulting .DLL. Done.
When you set a breakpoint in your C# app, you can step right into the VB6 code like it was native.
|
|
|
|
|
Ok, maybe I am missing something here. I have been using VB6 since it was first released and I know of no way to choose a DEBUG build over a RELEASE build like you do with Visual Studio. You CAN compile to native code and select the option to "Create Symbolic DEBUG Info". Maybe that is what you mean.
In any case, I did that already and I set a breakpoint in my C# code, then clicked "step into" and got an error message like "There is no source code available...blah blah blah". So I just figured I did something wrong. Or maybe Visual Studio can't find the source code for my VB6 project? How do I fix that?
Incidentally, the VB6 component is an ActiveX EXE, not a DLL, so it runs in a separate process. Is this a problem?
Thanks,
chiselca
|
|
|
|
|
Hi All,
I am trying to get specific values from the xml below, however i cannot get the desired result.
the xml structure is as below..
<Orders>
<OrderHeader>
<CustomerPoNumber>TEST1</CustomerPoNumber>
<ErrorMessages>
<ErrorDescription>Invalid Po 'TEST1'</ErrorDescription>
</ErrorMessages>
</OrderHeader>
<OrderDetails>
<Line>0001</Line>
<ErrorMessages>
<ErrorDescription>'EAE' invalid</ErrorDescription>
</ErrorMessages>
<ErrorMessages>
<ErrorDescription>'EAS' invalid</ErrorDescription>
</ErrorMessages>
<Line>0002</Line>
<ErrorMessages>
<ErrorDescription>Price invalid</ErrorDescription>
</ErrorMessages>
</OrderDetails>
</Orders>
the result i am looking for is as below
in a datatable with column headings
PoNum|Header|Line|Error|
TEST1|Invalid Po 'TEST1'|0001|'EAE' invalid & 'EAS'invalid
TEST1|Invalid Po 'TEST1'|0002|Price invalid
thx for your time and help
Anoop
|
|
|
|
|
Hi!
Can you please provide few more sample(s) ? I have just created a method that do the job. I need to test it. It would be be great if it may have as many cases as you have.
|
|
|
|
|
Hi ,
thanks for your help...
there was a slight typo error in the xml structure... it should have reflected as below
<Orders>
<OrderHeader>
<CustomerPoNumber>TEST1</CustomerPoNumber>
<ErrorMessages>
<ErrorDescription>Invalid Po 'TEST1'</ErrorDescription>
</ErrorMessages>
</OrderHeader>
<OrderDetails>
<Stock>
<Line>0001</Line>
<ErrorMessages>
<ErrorDescription>'EAE' invalid</ErrorDescription>
<ErrorDescription>'EAS' invalid</ErrorDescription>
</ErrorMessages>
</Stock>
<Stock>
<Line>0002</Line>
<ErrorMessages>
<ErrorDescription>Price invalid</ErrorDescription>
</ErrorMessages>
</Stock>
</OrderDetails>
</Orders>
i have managed to come up with a solution that works for now even though it's very messy...
have a look...
Private Function GetErrors(ByVal XML As String, ByVal Path As String) As DataTable
Try
Dim DOC As New Xml.XmlDocument
DOC.LoadXml(XML)
Dim ndParent As XmlNodeList
'Path = //Orders
ndParent = DOC.SelectNodes(Path)
Dim nd As XmlNode
Dim ndC1 As XmlNode
Dim ndC2 As XmlNodeList
Dim nd1 As XmlNode
Dim nd2 As XmlNode
Dim out As String = ""
Dim dt As New DataTable
dt.Columns.Add("PoNum")
dt.Columns.Add("So")
dt.Columns.Add("Line")
dt.Columns.Add("Error")
dt.Columns.Add("ErrHdr")
Dim row As DataRow
Dim PoNum As String = ""
Dim Line As Integer = 0
Dim errmsg As String = ""
Dim errhdr As String = ""
For Each nd In ndParent
'below reads the first level i.e. order header + order details
For Each ndC1 In nd.ChildNodes
Select Case ndC1.Name.Trim
Case "OrderHeader"
'get the childnodes of OrderHeader
'xml result should search for FieldName i.e. "CustomerPoNumber"
ndC2 = ndC1.ChildNodes
PoNum = XmlResult(ndC2, "CustomerPoNumber")
errhdr = XmlResult(ndC2, "ErrorMessages")
'out &= XmlResult(ndC2, "ErrorMessages")
Case "OrderDetails"
'ndC2 = ndC1.ChildNodes
For Each nd1 In ndC1
Line = Me.XmlResult(nd1.ChildNodes, "Line")
For Each nd2 In nd1.ChildNodes 'stockline
If nd2.Name = "ErrorMessages" Then
errmsg = Me.XmlResult(nd2.ChildNodes, "ErrorDescription") & " ; "
' out &= Me.XmlResult(nd2.ChildNodes, "ErrorDescription")
End If
Application.DoEvents()
Next
row = dt.NewRow
row("PoNum") = PoNum
row("Line") = Line
row("Error") = errmsg
row("ErrHdr") = errhdr
dt.Rows.Add(row)
Application.DoEvents()
Next
End Select
Next
Next
Return dt
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
Public Function XmlResult(ByVal node As XmlNodeList, ByVal Column As String) As String
Try
Dim nd As XmlNode
Dim nd2 As XmlNode
Dim strOut As String = ""
For Each nd In node
If nd.Name = Column Then
For Each nd2 In nd.ChildNodes
strOut = strOut & nd2.InnerText & vbCrLf
Application.DoEvents()
Next
End If
Next
nd = Nothing
Return strOut
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Function
thanks once again for your help....
appreciate it!
|
|
|
|
|
I have optimized the code a bit more, kindly check it out:
Public Function XmlToDataTable(ByVal path As String) As DataTable
Dim dt As New DataTable
Dim doc As New XmlDocument()
Dim PoNum As String = String.Empty
Dim Header As String = String.Empty
doc.Load(path)
dt.Columns.Add("PoNum")
dt.Columns.Add("Header")
dt.Columns.Add("Line")
dt.Columns.Add("Error")
Dim cnt As Integer = doc.SelectNodes("Orders/OrderHeader").Count
For k As Integer = 0 To cnt - 1
Dim node As XmlNode = doc.SelectNodes("Orders/OrderHeader").Item(k)
PoNum = node.Item("CustomerPoNumber").InnerText
Header = node.Item("ErrorMessages").InnerText
Dim n As Integer = doc.SelectNodes("Orders/OrderDetails").Count
For m As Integer = 0 To n - 1
Dim element As XmlNode = doc.SelectNodes("Orders/OrderDetails").Item(m)
Dim obj(3) As Object
obj(0) = PoNum : obj(1) = Header
For Each stocks As XmlNode In element.ChildNodes
Dim line As String = stocks.Item("Line").InnerText
Dim description As String = stocks.Item("ErrorMessages").InnerXml.Replace("</ErrorDescription><ErrorDescription>", " & ").Replace("<ErrorDescription>", "").Replace("</ErrorDescription>", "")
obj(2) = line : obj(3) = description
dt.Rows.Add(obj)
Next
Next
Next
Return dt
End Function
|
|
|
|
|
Hi
thanks, will try this out nd get back to you.
thanks for your help...
|
|
|
|
|
If you are reading the XML from file have a look at Dataset.ReadXML(filename)[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
I have written a code to change the back color of a label twice during execution to give it an animation effect. The idea says that :
when the button is pressed change the color from black to red.
Then a null loop is placed to create some delay and then the color changes back to black.
<pre lang="vb">Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
box.BackColor = Color.Red
For delay As Double = 0 To 900000000 Step 1
Next
box.BackColor = Color.Black
End Sub</pre>
But its not performing as desired. The label doesnt become red and i doubt the program is executing the delay first. Any idea whats the issue?
|
|
|
|
|
|
You're getting downvoted because you cannot touch a UI control from any other thread other than the thread that created it (the startup thread.)
|
|
|
|
|
Thanks, very elementary mistake. Note to self, think before posting. I have corrected the answer below(first one was removed).
Live for today. Plan for tomorrow. Party tonight!
|
|
|
|
|
Your code is running on the startup thread, also called UI thread. If the thread is blocked there is no way it can process the Windows PAINT messages that tell the controls to repaint themselves. This is why your label doesn't change color until your button Click method is done executing.
You have to move your work to a background thread. The problem is you cannot make changes to a control, such as changing the background color, from anything other that the UI thread. Once your background thead "work" is done the background thread can notify the foreground thread to change the label color as appropriate.
Read this article[^] for a discussion and alternate methods of modifying controls from background threads.
|
|
|
|
|
|
You will need to change the colour back using a separate thread. Something like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim newThread As New Threading.Thread(New Threading.ThreadStart(AddressOf ChangeBGColour))
newThread.Start()
Label1.BackColor = Color.Red
End Sub
Delegate Sub changeLabelColour()
Private Sub ChangeBGColour()
Threading.Thread.Sleep(3000)
If Me.Label1.InvokeRequired Then
Dim c As New changeLabelColour(AddressOf ChangeBGColour)
Me.Invoke(c)
Else
Label1.BackColor = Color.Yellow
End If
End Sub
I added proper UI thread access . My apologies for the basic thread error.
Hope this helps
Live for today. Plan for tomorrow. Party tonight!
|
|
|
|
|
That's an excellent answer.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Cheers.
Live for today. Plan for tomorrow. Party tonight!
|
|
|
|
|
Today I wrote a file compressor in Visual Basic, which stores its data in PNG images. It's called Squash.
Squash works by throttling the bytes of a file into a PNG image, storing 3 bytes per pixel in the Red, Green & Blue components. It works in a similar way to a ZIP file, but there is no extraction and apart from the extension (e.g. Document.docx.squash), the format is data/file type agnostic. Files with consistent byte patterns or 'blank' regions compress very well with Squash because these form solid or consistent areas in the graphic.
Here are the results - Results Graphic[^]
Squish is a free, single-executable file compressor. Just drag files on to Squash and find a .squash file in the same folder.
Squash is great for instant messaging, and can greatly improve transfer times. If your contacts have Squash too, they can just open the received file and it gets decompressed on the fly.
Just drop the EXE anywhere on your computer and start saving space - and time.
Project Page on my Site[^]
Download (EXE, 330k)
Source (ZIP, 150k)
If you go to the 'Project page on my Site' link, you can find the source and big explanation of how it works. The explanation is targeted towards beginners.
|
|
|
|
|
Hi all...
I am going to make a multi-user database application in VB.NET (VS 2008).
I have made several db program using different databases and made some client-server based chat programs. But I never worked on multi-user db program.
I wanna know that which database should I use as back-end. Application will be accessible by 3-5 users.
I also wanna know that from where to start to build multi-user program.
Suggest me.
Thanks.
Gagan
|
|
|
|
|
Assuming you're not storing ridiculously massive amounts of data, SQL Server Express would be a reasonable choice. Actually, pretty much anything but Access would be reasonable - there are way too many WTF's created by trying to make a multi-user Access system!
|
|
|
|