LB_GETTEXT Returns Garbage Data?
Mar 2, 2010I'm using following code to receive content of a ListBox
View 3 RepliesI'm using following code to receive content of a ListBox
View 3 RepliesI have been given the task of calling a web service which returns an xml data feed which I am doing like so:
For Each r As DataRow in SomeDataTable
Dim msFeed As String = string.format("[URL]?param={0}", r!SOME_VAL)
Dim x As XDocument = XDocument.Load(msFeed)
Next
This is all fine but as you can see x just gets overwritten with every iteration. What I need is create an xDocument and add each feed from my loop but I am unsure how to proceed.
Solution
Dim xAllFeeds As XElement = New XElement("Feeds")
For Each r As DataRow in SomeDataTable
Dim msFeed As String = string.format("[URL]?param={0}", r!SOME_VAL)
Dim x As XDocument = XDocument.Load(msFeed)
xAllFeeds.Add(x.Root)
Next
The new command text returns data with schema different from the schema of the main query. Check your query's command text if this is not desired. I am getting this warning, whenever I add a query in a Strongly Typed DataSet which returns a single column.
Ex
SELECT DISTINCT Building
FROM Room
ORDER BY Building
When I give this query it will show me a warning. Because warning leads to a constraint error when ever i call the same function in a windows form.
I have a postgresql database, one table. This table has a date column too.And I have this code:
[code]...
The problem is, that the pgreader returns no rows (the parameters are right and the database contains the data too).firstday and lastday are f.e. '2005.05. 01.', the ConvertDate function converts the date to '2005-05-01' (the dates are storen in this form in the database)And when the commandtext="select * from arfolyamok where datum between '2005-05-01' and '2005-05-31'", then it works, the pgreader has the rows.Why? What make I wrong?
I am working on a front-end application program and cannot figure out what is giving me this error. The program is accessing an Access Database and filling a text box on the form. The error i keep receiving is "Index out of range", "No row at position 0". I have information in the data table, and when I type the select statement into a query in Access, it returns the information in the data table.[code]...
View 8 RepliesImports
System.IO
Imports
System.Windows.Forms
Imports
[CODE]...
I don't understand why nothing is being returned from the SQL)
on the custom inherited control i created, i noticed that when i bind my custom property to a data column, if that data column returns a value other than Null it always return a datarowstate of modified even if there were no changes. don't make any changes to the current record before you go to the next record. you will see that the rowstate will still return Modified.
View 8 RepliesI've heard that the c# garbage collector can be 'more aggressive' than it's vb.net counterpart. Is this true? Are there any other differences in how garbage collection is run in vb.net vs. c#?
View 5 RepliesI'm trying to introduce delay to my code so that it would read in the noise or garbage data.
I'm receiving the data from RFID to pic thru RS232.Is there any simple delay that i can use? I seriously don't understand threading.
I thought that when a variable went out of scope (like a variable declared within a method - when you exit that method the variable is out of scope) then it was eligible for garbage collection and when it was garage collected the Dispose method is called on it. Now I know that it does not get disposed immediately but I assumed it would be basically as soon as the process starts to take up quite a bit of memory.However, I found that my app's memory usage seems to constantly increase when I dont manually Dispose of a specific method local variable. Of course its good practice to call Dispose and ordinarily I would but I just didn't realise that this particular class actually implemented IDisposable. The class in question was the System.DirectoryServices.SearchResultCollection class, and I was looping through the items in it like so:
[Code]...
I have a function like the following: Public Function testFunction(ByVal input_string As String) As String
[Code]...
or just let the garbage collector do the job for us? Both the above functions work, but I want only know the best practice for performance...
I'm creating a windows forms program and have recently noticed a large amount of memory slowly being eaten by the application. I went through my program and tried to tie up as many loose ends as I could in relation to object creation but noticed that the program would still keep memory for every form loaded until it eventually crashed.
I decided to make a simple test program which sole purpose is to pop-up a new form with a few controls, wait for 200 milliseconds, then close the form and repeat the process 30 times every time I hit a button. I found it caused the same behavior, even with the only new object creation being that of the form. So, I decided to manually invoke the garbage collector in a subroutine which handles the formclosed event. During tests I would get some memory back occasionally, but not enough to make a difference in the long run. So I start setting the form variable to nothing before I called GC.collect(). The program will initially eat a few 1000K of memory before leveling off and using only 20-40K for every 30 forms created.
Now what I'm wondering is, what is the point of an automated garbage collection system if it requires constant manual evocation and explicit dereferencing of all new objects to be effective? Have I completely lost grasp on the scope of VB.Net forms and it simply never marks forms as available memory to be cleared?I would have thought object memory references created within a form would be marked as usable when the form's close or dispose routine is called and no references to objects created within the form exist anywhere outside the closed form.
I am trying to create radiobuttons, and then create code for them after they are created. I have the code to create the radiobuttons. What I want to do is create a sub for the event of changing the check value for the radiobutton. Or to have the check value recognized by a button click. For example, you click the button and if the first radiobutton has the circle filled then a msgbox comes up and says hurray. My code so far is this:
View 6 RepliesI am using a function from a dll in unmanaged code that requires a callback to my managed code in Visual Basic 2010. The callback is asynchronous and is called continuously over the life of the application. What's the best way to protect the callback function from the garbage collector? Right now it is being collected after several dozen calls from the dll.
View 11 RepliesI've been doing some reading on garbage collection in .NET and I was hoping for some clarification. So, as I understand it if I declare a public shared class variable, the GC will never get rid of it. Is this correct?Also, what then of private variables? Take the following example:
public class myClass
private shared myString As String
public sub ChangeString(newString As String)
[code].....
I have a callback function in a C+ dll:
<UnmanagedFunctionPointer(CallingConvention.Cdecl)> _
Public Delegate Sub DeviceDetectionEvent(ByVal YasdiEvent As YASDIDetectionSub, ByVal DeviceHandle As UInteger, ByVal param1 As UInteger)
[code].....
Is the memory from primitive data types (int, char,etc) immediately released once they leave scope, or added to garbage collection for later release?
consider:
For x as integer=0 to 1000
dim y as integer
Next
If this doesn't add 1000 integers to the garbage collector for clean up later,how does it treat string objects? would this create 1000 strings to clean up later?
For x as integer=0 to 1000
dim y as string=""
Next
How about structures that contain only int,string,etc... data types?
I am using vb.net 3.5 and application is interacting with VC++ dll.
code is:
Public Delegate Sub delProcess() //Globaly declare
im del As New delProcess(AddressOf Process) //Process is function which not returning
[code].....
If I want to narrow scope of a variable in C#, I can introduce additional braces - i.e.:
class Program
{
static void Main(string[] args)[code].....
In the ide, I can no longer reference y outside of the scope introduced by the new braces. I would have thought that this would mean that the variable y would be available for garbage collection.(it is interesting to note that when viewing the compiled code using reflector it appears that there is no difference with or without the additional braces)Is there any way similar to this to narrow scope when using VB.net? Does this have any impact on when variables defined in the inner scope may be garbage collected?
with VB.NET + MySQL i am having a connection object which is public public MYcnn as MySql.Data.MySqlClient.MySqlConnection when my main form opens MYcnn will open & will be available for all the procedures & functions. i never close this connection until the last form of the application closes (yes of course i compromise of some security + performance issues)
my problems is(1)when & how the garbage collector works to collect my connection object if my connection object remains open for > then certain time(2) how to offer or fix the time of my connection object availableness to garbage collector (3) i would like to write an event for the connection object closed event(i am explicitly declaring the connection object)
I have an Excel file that downloads automatically, but for some reason the binary XLS file contains some garbage HTML text at the end of it.
When opening the file in the Excel application, it shows a warning but proceeding will automatically remove the garbage HTML text.
However, I need to open the file programmatically. When doing so via
Dim wb As Workbook = Excel.Workbooks.Open(ExcelFileName)
It throws:
Exception from HRESULT: 0x800A03EC
a) Get Excel to perform a similar action as if I manually opened it and remove the garbage HTML automatically. NOTE: Tried setting the XlCorruptLoad.xlRepairFile parameter and it didn't work.
OR
b) Remove the garbage text from the XLS binary file (FileStream?) and resave it before attempting to open the file with the code mentioned above.
The garbage html always comes at the very end of the file and starts with
Datatable object within class function + garbage collection?
View 3 RepliesHere's the scenario, winforms application, monitoring via Task Manager Processes Tab.On initial launch spins up to ~61,000K (initial data grid and data loads)If I minimize the application, not touching or doing anything the Mem usage drops to 1,380K.When I restore the application is spins back up to only 5.8K
So my question is, does the minimize send some internal message to clean up resources since the application in question is not in focus?The first app I noticed this in happens to be VB.NET, but I've observed the same behavior in my main C# winform applications.
If I use a single variable of type Excel.Worksheet to reference Worksheet1, and then change it to Worksheet2, Worksheet3 and so on, is it adequate to simply do "Marshal.FinalReleaseComObject(worksheetVariable)" once at the end? Or would I be left with some references still in memory? In other words, do I need to do a "Marshal.FinalReleaseComObject" before each re-assignment?
View 3 RepliesI have a theory that the CLR garbage collection mechanism means that I can get away with circular references in my object hierarchy without creating deadlocks for teardown and garbage collection. Is this a safe assumption to make? (Target language VB.NET)
View 2 RepliesI have a problem with an application, in this case I have a windows services. its function is generate reports depending of demand of our users.In some cases the memory usage of my windows services is to 2 gb of RAM. I disposed all objects that my application use . but the memory usage doesn't low.I tried to reduce the memory usage forcing to garbage collector to Collect with the method "GC.Collect"but it's not recommend because uses many time of CPU.Surfing on the internet I found a method named "SetProcessWorkingSetSize" that free memory usage correctly. http:[url]....but some cases my windows services named sapdkadm_procesoestandarejecucion.exe has some error message in event viewer is the next:
Faulting application sapdkadm_procesoestandarejecucion.exe, version 1.0.0.0, stamp 4f908fef, faulting module kernel32.dll, version 5.2.3790.4480, stamp 49c51cdd, debug? 0, fault address 0x0000000000027ded.
The real problem is that when this happens my windows services restart
I have prided myself in having a pretty clean code however in the game I am making I have a player view (showscreen) and a host view, which is a copy of the player view (on a smaller screen). This way the host can see what's going on.The problem is that the graphic doesn't dispose properly and Garbage Collector gets it, though I have noticed it will crash if GC doesn't get it in time. The larger the showscreen window the more junk gets put into memory, which sucks.I thought I had everything correctly disposed below but still doesn't get the job done.
[code]...
I'm trying to sort an array based on a structure but whenever I do this, it basically erases all the data in the entire array.I have verified that the array is populated correctly, it is when using array.sort that everything returns blank.
View 6 RepliesI am currently working on a custom data type, and wanted to implement a = operator.
I data type is a nullable date that returns a string value if date was supplied.
I want to allow the variable to be set like this
Dim nd as New NullableDate nd = Today Does anyone know how this can be done, or can anyone point me in the right direction?
I may be the only person still automating excel this way and I am looking at doing it in ways that better handle COM objects and such, but for now I just importMicrosoft.Office.Interop.Excel and go for it. Something that gave me a lot of grief at first was hanging excel.exe processes, but there are tons of resources online for fixing that. At this point I am pretty confident in my abilities to handle it.One thing I did notice and was wondering about is how does closing a windows forms application interact with excel.exe running in the background and likely more specifically the garbage collector. I have written quite a few excel automation projects and noticed that after I run my program .exe and it has completed there is an excel.exe process that hangs on until I close the pop up window from the windows forms application. Why is that happening?
View 1 Replies