|
because textboxes are not bound.
programmer
|
|
|
|
|
Hi there
I'm looking for a reasonable way to avoid the serialization of events/eventhandlers in VB.NET (2005).
Since the structure of the objects I wanna serialize is quiet comlex, removing before and re-adding all handlers after the serialization could generate new problems.
Is there any solution except moving to C# or implementing ISerializable?
Thanks!
|
|
|
|
|
have you tried <xmlignore>
ex
<serializable> _
class xxxxx
<xmlingore> public sName as string 'will not be serialized
public sAddress as string
end class
|
|
|
|
|
What you suggested is what I usually end up doing, including adding custom serializer code to add support for handling Color and Font objects. Talk about Tedious Infinitum.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
Well, you don't have much of a choice. See here[^] for a great summary of your options.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks guys for the replay!
Since I have some COM stuff included I'm afraid to be forced to use the binary formatter. So <xmlignore> will probably not work.
What I further need is an abstract soution since the project I'm working on is a kind of a framework. Using any 'object specific' implementation could end up in a mess.
I have had seen the link Dave mentioned before I posted this message and I was hoping that there might be an easier way.
It's really a shame.
Rudi
|
|
|
|
|
Hello,
I am trying to convert a string representation(2007-02-22) into a dateformat yyyyMMdd. it returns the right result as string but I want the returned type as date and in this format 2007-02-22 as XML API I am using requires a DATE not STRING representation like this.
Am I missing something very easy here (quite possible)?
Appreciate any replies.
|
|
|
|
|
Did I get it right that you have a string representation of a date and want to convert this into a DateTime instance.? If so, then take a look at the DateTime.TryParseExact or DateTime.ParseExact (framework < 2.0) methods. Both methods let you specify a custom format for the input string.
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thnks Stefan the issues has been resolved.
Cheers!
|
|
|
|
|
How do I check fields in a database table for specific characters (for example, checking to see if the first two characters in the field are "\\"), using an if statement in a stored procedure.
Thanks,
Rhonridge
|
|
|
|
|
|
Im unsure where I should place the code for closing, flushing, and disposing of the various readers and writers.
Currently I place the .Flush and .Close inside the try block right before the Catches and then I place the .Dispose calls inside the Finally .
Cleako
|
|
|
|
|
Normally, you'd place the .Flush/.Close and .Dispose in the Finally block. You'd first check to see that the stream is indeed open before you called Close on it, then Dispose it.
Why? Because your code could throw an exception before or during the file open, so it's possible that the file never gets opened. Also, it's possible that your code could throw an exception during the manipulation of the file, leaving the file hung open in the Catch/Finally handlers. Finally gets executed no matter what happens in the Try block, so checking and closing the file in the Finally block is the best place to do it.
Dim sw As StreamWriter
Try
sw = New StreamWriter(filePath)
For x As Integer = 1 to 100
sw.WriteLine(x)
Next
Catch ex As Exception
' used a 'catch all' Exception which is not really good practice!!
Finally
' You'll only get a StreamWriter object if the file was successfully opened!
If Not sw Is Nothing Then
sw.Close()
sw.Dispose()
End If
End Try
Now in place of that, with VB.NET 2005, you can instead use the Using keyword to do the same thing. When the code execution leaves the Using block for any reason the object created on the Using line is automatically closed Disposed.
Try
Using sw As StreamWriter = New StreamWriter(filePath)
For x As Integer = 1 to 100
sw.WriteLine(x)
Next
End Using
Catch ex As Exception
...
End Try
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Does that take care of the flush and everything? If I have multiple writers would it make a difference to have all of those nested?
Cleako
|
|
|
|
|
cleako wrote: Does that take care of the flush and everything?
Disposing a StreamWriter, or any file stream for that matter, automatically calls Flush and Close.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
If I have, say 5 writers, to write to 5 files depending on a condition, if I use the keyword Using and I create all 5 is there a way to avoid that indenting?
Cleako
|
|
|
|
|
If you're writing to all 5 files for each record you write, no there isn't unless you turn off the automatic formatting in Tools/Options. But do that also turns off the formatting for every file in every project you open from then on.
If your picking which file you are going to write to for each record, then create a StreamWriter when you need to write to that particulare file. Don't open the file(s) unless you need to write to it. But, there is a performance penality for doing this, so you might want to test it before you nail it down as production code. But, if you sacrifice performance just to make the code "look pretty", I'll frown up you if you ever end up on my team...
Basically, no there isn't. It's not so bad. I've seen C++ and C# code indented 20-30 levels deep because of nested IF's and loops. It happens...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You're saying there is a performance hit to open the file everytime you need to write to it or to open 5 and write if you need to when you need to until you are done and then closing them all?
Also, checking for nothing establishes if it is ok to Flush and Close?
One more, , are you saying I could simply call .Dispose and it would take care of the Flush/Close instead of me calling those 2 in addition to the .Dispose?
Cleako
|
|
|
|
|
cleako wrote: You're saying there is a performance hit to open the file everytime you need to write to it or to open 5 and write if you need to when you need to until you are done and then closing them all?
Yes, there is a performance penalty for opening and closing a file. Try it. Write a little app that opens a file, writes 10,000 lines of text to it, then closes it. Then rewrite that loop so it opens the file, writes a line to it, then closes it, 10,000 times. See which one runs faster.
cleako wrote: checking for nothing establishes if it is ok to Flush and Close?
You're checking to see if it is safe to call Flush and Close, and even Dispose, on that object. If that object is Nothing, then any call you make on it will result in a Null Reference Exception.
cleako wrote: are you saying I could simply call .Dispose and it would take care of the Flush/Close instead of me calling those 2 in addition to the .Dispose?
Yep.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dear All,
I have a file which is archived with RAR and Password protected now I simply can't get it way. Is there any way to get its data as it's really required.
Develop2Program & Program2Develop
|
|
|
|
|
What does this have to do with VB.NET???
You have to have the password to open the RAR since the data is encoded with it. You can probably try Googling for some cracking tools, but don't get your hopes up.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am running VB.NEt(2003). I have a solution with 2 projects - the True project and the Setup project. User documentation is in a Help directory which contains 29 htm, bmp, and ico files. A year ago, both projects were fine and Setup project successfully deployed to several computers. I've completed some maintenance to the True project, which compiles and tests OK in Debug mode.
When I change to Release mode, the Setup project will not compile. It seems to make no difference whether I click Build or Rebuild for either the Setup project or the Solution.
Sometimes I get this error message C:\Development\VBN\VAQSO\VAQSO_Setup\VAQSO_Setup.vdproj Could not find file 'C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\Deployment\.\MsiRedist\1033\MsiLoadr.Bin' 'Interface not registered' Note the \.\ in the middle. The file & path (without the period) exist.
Usually I get this error message C:\Development\VBN\VAQSO\VAQSO_Setup\VAQSO_Setup.vdproj Could not find file 'C:\Development\VBN\VAQSO\VAQSO\bin\Help\Clear.ico' 'Interface not registered' This file and path also exist. This file is in the Setup project in a directory under the Application Folder. I can make this error go away in three steps. 1-Delete the entry from the Setup project. 2-Rename the file on my hard drive. 3-Add the renamed file back into the Setup project. Usually this works on this file, but another file in the same folder will come up missing the next build.
I figure I've busted a setting someplace, but I have no idea which one. This is the only VB project I maintain so I'm on thin ice here. Any ideas why the compiler is behaving this way?
Thanks
--HamCoder
|
|
|
|
|
Hi,
Although not the exact same problem, I have experienced similar things. You could probably investigate and experiment until you're ready to chuck your PC out of the window , but I recommend trying any of the following slightly more radical solutions:
1. delete the installer project, and add a new one to the solution.
2. start a new empty solution, add the main project (add existing project), and create a new installer project
3. uninstall and reinstall .NET Studio, and then solution 2.
I have spend about a week trying to solve my own problem, before I solved it in 15 minutes with solution 2.
Good luck,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
A call to PInvoke function 'Project1!Project1.Module1::NGIMAPBR_AutoDetectAndDecode2DBarcode' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

|
|
|
|