|
I have an issue with a .NET stored procedure hosted in SQL Server 2005. Let's say I have a simple UDF that takes a float and returns whatever.ToString("c") to get a value formatted as currency. If I change my Windows regional settings to French, for example, I would expect to see the value 12345.67 displayed as "EUR 12 345,67". In US English I would see "$12,345.67". However, it appears that the hosted instance of the .NET CLR doesn't use the Windows regional settings but rather the settings for SQL Server (understandably). What I can't figure out is how to control the language of the hosted .NET CLR. I've spent a lot of time making sure my application is compatible with any locale. However, I've been assuming that SQL was going to stay in US English (which none of our clients seem to have a problem with). Now we need to control some formatting before things leave the database, and have to take a look at controlling that within SQL. Any ideas?
|
# ? May 29, 2007 23:03 |
|
|
# ? Jun 2, 2024 11:27 |
|
Hooray I've got a small question. I'm watching a folder using the FileSystemWatcher class. I only need to watch for incoming .zip files. What is the easiest way to retreive the file name of a new .zip file? I tried setting the NotifyFilter to NotifyFilter.FileName, thinking that would do it, but I guess not . Thanks!
|
# ? May 29, 2007 23:35 |
|
SLOSifl posted:Any ideas? http://blogs.msdn.com/sqlclr/archive/2005/06/15/429407.aspx Basically, CurrentCulture is what you want to look into.
|
# ? May 29, 2007 23:52 |
|
I've been told that you can compile Perl as a .NET program. If so, how do you handle graphics?
|
# ? May 30, 2007 00:07 |
|
genki posted:I think this deals with it: quote:The content of Thread.CurrentCulture is set for you to the default value specified in the control panel each time your code is invoked. The value is stable for the duration of your routine. Modifications you make to that property, or to any other static object, are not durable and will need to be redone each time your code runs.
|
# ? May 30, 2007 00:28 |
|
pliable posted:Hooray I've got a small question. http://forums.somethingawful.com/showthread.php?action=showpost&postid=328456201
|
# ? May 30, 2007 01:32 |
|
Sizzlechest posted:I've been told that you can compile Perl as a .NET program. If so, how do you handle graphics? You can use any of the .NET libraries with any .NET language, so you should be able to reference and use the same libraries as you would with C# or VB.Net. But if I remember from my short and unhappy time with perl, it's got a pretty funky object model so I couldn't speculate on syntax
|
# ? May 30, 2007 02:01 |
|
theHydralysk posted:You can use any of the .NET libraries with any .NET language, so you should be able to reference and use the same libraries as you would with C# or VB.Net. But if I remember from my short and unhappy time with perl, it's got a pretty funky object model so I couldn't speculate on syntax PerlNET doesn't go both ways. You can reference perl from .NET because it has a custom interpreter, but the Perl code doesn't see the .NET libraries.
|
# ? May 30, 2007 02:07 |
|
Fiend posted:My apologies. In case anyone has similar problems, I ended up using COM objects to open the file in Word and save it as a postscript file and then call up ghostscript to turn it into a pdf.
|
# ? May 30, 2007 02:08 |
|
DLCinferno posted:Excellent Win32 code SLOSifl posted:You can call SHGetFileInfo like this instead: Quick question: Do any other file types besides .exe and .ico have unique icons associated with them? SHGetFileInfo, unlike ExtractImage(), doesn't get thumbnails for images and the like, so I don't have to worry about them, only file with natively embedded icons. I'm trying to write a cacheing hash, so that I can only have one, say, .txt icon stored, instead of one for each txt file in the list. Also, if I create an icon in a method call, as in code:
Edit: Also, SHGetFileInfo doesn't seem to be able to get a folder's icon. What's the best way to do that? Edit2: Nevermind, removing the SHGFI_USEFILEATTRIBUTES flag did it. I guess for "hypothetical" folder, I'll have to retrieve the folder icon of some presumed "normal" folder and use that as a generic folder icon. Magicmat fucked around with this message at 03:42 on May 30, 2007 |
# ? May 30, 2007 03:23 |
|
Magicmat posted:Edit2: Nevermind, removing the SHGFI_USEFILEATTRIBUTES flag did it. I guess for "hypothetical" folder, I'll have to retrieve the folder icon of some presumed "normal" folder and use that as a generic folder icon.
|
# ? May 30, 2007 04:04 |
|
DLCinferno posted:This crosspost might help you: Perfect. Thanks a ton!
|
# ? May 30, 2007 17:26 |
|
Hey guys, I've been a lurker thus far but I have a little question.. I'm trying to get a list of networked computer names. I've found about Netapi32.NetServerEnum -- It work fine for finding the computer's workgroup computers but it completely ignore other workgroups. Is there any way (managed or non) to get computers in other workgroups? I don't think I can use System.DirectoryServices -- It requires an active domain server I believe?
|
# ? Jun 1, 2007 14:24 |
|
I'm having troubles with a session variable: The user hits Default.aspx: code:
I thought adding "false" to the Redirect statement allowed it to set the session variables before moving on.
|
# ? Jun 1, 2007 20:17 |
|
Dromio posted:I'm having troubles with a session variable: You are doing "string CurrentSite = (string) Session["CurrentSite"];" before you try to write it out, right ?
|
# ? Jun 1, 2007 22:25 |
|
I'm having a little trouble figuring out the subtleties of .NET's garbage collection and manually disposing/finalizing an object and all that. I'm using the previously posted method to get a file icon using the Win32 function SHGetFileInfo(), which returns a handle to an icon. I then using System.Drawing.Icon.FromHandle() to create an icon object out of that. Now, the MSDN page for FromHandle() states that "[w]hen using this method you must dispose of the resulting icon using the DestroyIcon method in the Win32 API to ensure the resources are released." Additionally, the Win32 documentation for SHGetFileInfo() states "[i]f SHGetFileInfo returns an icon handle [ . . . ], you are responsible for freeing it with DestroyIcon when you no longer need it." However, my .NET icon extraction code is encapsulated in a method which returns the Icon object and has no knowledge of the icon's lifetime. I tried creating an Icon with FromHandle(), calling DestroyIcon() on the handle returned by SHGetFileInfo() and then returning the icon, but that just detroys the Icon's copy of the icon resource. So, do I have to import and then call DestroyIcon() whenever the calling code finishes with an icon created via FromHandle(), or will Icon's own destructor take care of it? Or do I have to explicitly call the Icon object's Dispose() method when my calling code is done with the Icon? And while we're here, do I ever need to manually call Dispose() on an object other than when I want to manually free the object's resources? That is, if I don't call Dispose() on some object, will the GC still clean it up, or will I get a leak? And what's the difference between Dispose() and Finalize()? Magicmat fucked around with this message at 13:52 on Jun 4, 2007 |
# ? Jun 4, 2007 13:48 |
|
I'm trying to output a DateTime object in a specific format in an Xml file. The format of th XML can't be changed (even though it is wrong). The format I am looking for is:code:
code:
code:
EDIT: Figured it out myself: code:
jarito fucked around with this message at 15:15 on Jun 4, 2007 |
# ? Jun 4, 2007 14:21 |
|
uXs posted:You are doing "string CurrentSite = (string) Session["CurrentSite"];" before you try to write it out, right ? Thank you!
|
# ? Jun 4, 2007 14:38 |
|
Magicmat posted:And while we're here, do I ever need to manually call Dispose() on an object other than when I want to manually free the object's resources? That is, if I don't call Dispose() on some object, will the GC still clean it up, or will I get a leak? And what's the difference between Dispose() and Finalize()? And just for a little additional clarity, there are a few specific times when you should not Dispose() an IDisposable. The only time I can specifically think of when you shouldn't is when you get a sharepoint SPSite object through the SPControl.GetContextSite() method. These times when you shouldn't dispose of your object are usually made fairly clear, so if you're not sure you should probably do it. Oh, and the difference between Dispose() and Finalize() is this: Dispose() is what you call when you're done with an object. Finalize() is what you never call ever because it's the garbage collector's job to call it. Finalize() will probably call Dispose(), so I guess it's not like the resources will be hanging around forever, but it's still bad practice to not Dispose() of your unmanaged resources, since you never know when the GC is going to get around to cleaning house. Jethro fucked around with this message at 15:06 on Jun 4, 2007 |
# ? Jun 4, 2007 14:47 |
|
I'm always a little foggy with Garbage collecting in .NET so take this with a grain of salt, but to add on to what Jethro was saying. You need to call Dispose manually because the object holds some kind of resource that other objects can't get until you give it up. If you depend on the garbage collector to dispose, you have no control over when that happens. Depending on the program, the GC might only get called a few times a day or less. And all that time, you're holding the resource. There's a memory usage concern here too. When the gargage collector tries to reclaim an object that didn't have Dispose called, it will call dispose and then not reclaim the object until the next time it runs, so the object lives an extra garbage collection.
|
# ? Jun 4, 2007 17:04 |
|
I figured this would be the best place to go for advice on this. Not really coding-related, but .NET-related. I've been a .NET developer for the last 2 years in a small division of a much larger Fortune 500 company. I have a degree, I'm good at my job, my boss loves me and gives me glowing reviews, but with more and more of our development work being outsourced to either corporate IT or India I feel it's time for me to hit the job market. I've had my resume out there for less than a week and I have two interviews on Wednesday for what sound like great opportunities. One problem - I've never ACTUALLY interviewed for a developer position before and am nervous as hell about it! I got my current job by being promoted from within because my (current) boss knew me and knew what I could do and knew he wanted me for the job, so he gave it to me. I feel as though I'm a very competent .NET developer and the descriptions of these positions definitely don't sound like anything that I haven't done before, but can anybody tell me first hand what to expect during the interview process? I feel like if I have at least some idea of what to expect going in it'll really help with the anxiety. I really don't want to screw this up. Any tips are greatly appreciated!
|
# ? Jun 4, 2007 17:37 |
|
How do I set an ASP.NET page to not spazz out about SQL Timeouts? This one particualr page is going to display a fuckton of information and it takes the SQL server more than 30 seconds to do these calculations. Other than setting the connection string to timeoout at a greater number, is there any way of just setting this one particular page to be more patient?
|
# ? Jun 4, 2007 18:14 |
|
I've got a really basic problem- I have an ASP.Net DropDownList that is supposed to call a function on change. I was handling this before with a button that called it and it was working fine, but I'd like to remove that step. I have: <script runat="Server"> 'Saves ResultsPerPage to Session Sub SaveResultsCount(sender As Object, e As System.EventArgs) ... End Sub </script> Followed by: <asp:DropDownList id="selectResultsPerPage" onChange="SaveResultsCount" runat="Server" AutoPostBack="True"> ... </asp:DropDownList> Unfortunately, when I change the value of the list, Firebug tells me that SaveResultsCount is not defined. The button, which works, also calls SaveResultsCount from its onServerClick method. Like I said, it's probably something simple but it's not coming to me.
|
# ? Jun 4, 2007 18:50 |
|
jarito posted:I'm trying to output a DateTime object in a specific format in an Xml file. The format of th XML can't be changed (even though it is wrong). The format I am looking for is: SLOSifl fucked around with this message at 19:27 on Jun 4, 2007 |
# ? Jun 4, 2007 19:24 |
|
KiwiDNA posted:I've got a really basic problem- I have an ASP.Net DropDownList that is supposed to call a function on change. I was handling this before with a button that called it and it was working fine, but I'd like to remove that step. I have: try using: <asp:DropDownList id="selectResultsPerPage" OnSelectedIndexChanged="SaveResultsCount" runat="Server" AutoPostBack="True"> instead, the reason is probably that onchange is doing a client side javascript function call, which won't work and should give you that firebug error, versus the 'OnSelectedIndexChanged' which indicates which server side event handler function to call on postback. Hope that helps/makes sense. oberonix fucked around with this message at 19:46 on Jun 4, 2007 |
# ? Jun 4, 2007 19:43 |
|
Shalinor recommended I ask you guys, so what book would you recommend for learning C# from scratch? I have the Microsoft Press step by step book but it seems a little basic, and I'd like to concentrate more on learning how to program and less on how to copy what's in the book.
|
# ? Jun 4, 2007 19:58 |
|
MC Fruit Stripe posted:Shalinor recommended I ask you guys, so what book would you recommend for learning C# from scratch? I have the Microsoft Press step by step book but it seems a little basic, and I'd like to concentrate more on learning how to program and less on how to copy what's in the book. I liked Jesse Liberty's Programming C#. It's geared more toward someone who already has a good base of programming knowledge and covers some more advanced topics than would be in a book aimed at complete beginners. His writing style is also not too dry and easy to keep up with.
|
# ? Jun 4, 2007 20:23 |
|
What's the best way to load text into a RichTextBox without having the application freeze? I've attempted various shenanigans involving background workers, threads, google, etc ad nausum (I'll spare you my actual code), and nothing I've tried avoids the 2-3 second lockup while loading large blocks. Help.
|
# ? Jun 4, 2007 20:32 |
|
oberonix posted:try using: That worked like a charm; thanks!
|
# ? Jun 4, 2007 21:18 |
|
Unfortunately, one problem just led to another. I've got my DropDownList with three results per page options: 25, 50, and 100. When the page loads, it retrieves the current value of the ResultsPerPage variable from session and paginates properly. The drop down list also displays the proper option: Select Case Session("ResultsPerPage").ToString() Case "25" selectResultsPerPage.SelectedIndex = 0 Case "50" selectResultsPerPage.SelectedIndex = 1 Case "100" selectResultsPerPage.SelectedIndex = 2 End Select </HEAD> I know I could have just set SelectedValue; I just wanted to see if this would work. The problem is that if the page loads initially with 50 or 100 results, it won't let me select 25. That is, I can select it and it appears to do the PostBack, but it does not fire the OnSelectedIndexChanged function and the List reverts back to 50 or 100. However, if I select 50 or 100 first, it works fine, and if I then select 25 after that, it will properly display 25 results. This is perplexing as it is acting like 25 is selected initially (thus the OnSelectedIndexChanged function doesn't run), but the list does not display the 25 option and normally if you try to select the option that is already selected it does not PostBack. This poo poo is driving me batty.
|
# ? Jun 5, 2007 01:47 |
|
Mr. Herlihy posted:I liked Jesse Liberty's Programming C#. It's geared more toward someone who already has a good base of programming knowledge and covers some more advanced topics than would be in a book aimed at complete beginners. His writing style is also not too dry and easy to keep up with.
|
# ? Jun 5, 2007 02:14 |
|
Magicmat posted:I'm using the previously posted method to get a file icon using the Win32 function SHGetFileInfo(), which returns a handle to an icon. I then using System.Drawing.Icon.FromHandle() to create an icon object out of that. Now, the MSDN page for FromHandle() states that "[w]hen using this method you must dispose of the resulting icon using the DestroyIcon method in the Win32 API to ensure the resources are released." Additionally, the Win32 documentation for SHGetFileInfo() states "if SHGetFileInfo returns an icon handle [ . . . ], you are responsible for freeing it with DestroyIcon when you no longer need it." However, my .NET icon extraction code is encapsulated in a method which returns the Icon object and has no knowledge of the icon's lifetime. I'm guessing here since I don't remember if this works the way I expect it to or not, but once you've created your Icon with FromHandle(), call Clone() on it to create another Icon object, Dispose of the first one, DestroyIcon your handle, and return the Icon created by the Clone. There's a (reasonable) possibility the icon handle is shared between clones though. If that's the case you're gonna have to do a bit more heavy lifting. Magicmat posted:And while we're here, do I ever need to manually call Dispose() on an object other than when I want to manually free the object's resources? That is, if I don't call Dispose() on some object, will the GC still clean it up, or will I get a leak? And what's the difference between Dispose() and Finalize()? You should strive to always, always call Dispose(). A couple reasons have already been mentioned in other responses (the most important being that you have direct control over when the unmanaged memory and things like network connections are actually closed), and a more important reason is that almost every object that implements IDisposable also includes a finalizer method that calls Dispose() when you forget to, and when a finalizer method exists, it has a substantial negative performance effect on the garbage collector (it makes your objects live a generation longer than necessary). Dispose() almost always calls GC.SupressFinalize(...), which unregisters the finalizer method from the object, and thereby avoids the inherent performance loss of a finalizer. And a quick glossary: Dispose() - You call this when you're done using an object. Comes from the IDisposable interface. There is absolutely nothing magic about this method (it doesn't do anything special that a normal method call doesn't do). Finalize() - The runtime calls this when the object still needs to be cleaned up before the object can be truly collected. This method is intrinsic to the runtime, it doesn't come from an interface. It has magic attached to it in that if it exists on an object (and hasn't been manually supressed), the runtime ensures it will be called before the object's final collection.
|
# ? Jun 5, 2007 02:16 |
|
biznatchio posted:I'm guessing here since I don't remember if this works the way I expect it to or not, but once you've created your Icon with FromHandle(), call Clone() on it to create another Icon object, Dispose of the first one, DestroyIcon your handle, and return the Icon created by the Clone. Followup question: Is it bad form to instantiate an object which implements IDisposable as a temporary variable, for example as a parameter in a call to a method? For example, here's my current code: code:
code:
Magicmat fucked around with this message at 03:04 on Jun 5, 2007 |
# ? Jun 5, 2007 02:54 |
|
Just have a quick question that I just noticed and is bugging me now. Whenever I am working in the designer for a typed Dataset, I noticed there is an int field and an integer field. I never noticed this because I would always tab over and just type 'int' and never look at the other options, but a coworker actually went to the drop down and selected 'integer'. What the hell is the difference? Edit: And we are almost at 20 pages, should I start version 3 of this thread now?
|
# ? Jun 5, 2007 13:23 |
|
What's up .NET gurus? I'm a .NET newbie and am having a little trouble with trying to automate some web navigation with the WebBrowser control. I'm basically creating a UI that will log the user into a website and perform some tasks on the website but Im doing it through my app so that they have access to some helper functions and logging tools that I've developed as well. My problem is that I'm having trouble with code executing before the webpage fully loads, thus screwing up the logic of my code. There is some code that checks the URL property of the WebBrowser control and performs tasks based on what that URL is. However the problem is that the URL is being checked before the webBrowser has a chance to fully load the page(and in turn have its URL property updated). code:
Should I somehow be using the navigated event? I'm stuck like a pig on a plate and could use some direction. Thanks in advance, Tim
|
# ? Jun 5, 2007 15:15 |
|
Factor Mystic posted:What's the best way to load text into a RichTextBox without having the application freeze? I've attempted various shenanigans involving background workers, threads, google, etc ad nausum (I'll spare you my actual code), and nothing I've tried avoids the 2-3 second lockup while loading large blocks. Help. Put everything that's going to go into that box in a queue and listen for the AppIdle event (top of my head; not cut-and-pastable): code:
|
# ? Jun 5, 2007 17:09 |
|
Fastbreak posted:Edit: And we are almost at 20 pages, should I start version 3 of this thread now? I think we can have long threads now. Programming Questions thread is in the 50's and SALR thread is in the 60's
|
# ? Jun 5, 2007 17:46 |
|
FormerFattycode:
Senior Labor Eliminator, First-Against-The-Wall Division, Raiser of the Cost of Living, Defender of the Faith Munkeymon fucked around with this message at 18:44 on Jun 5, 2007 |
# ? Jun 5, 2007 18:39 |
|
Munkeymon posted:
Thanks... that event will trigger everytime the webBrowser finishes loading a page correct? I suppose I'd have to setup a large if statement to determine which page has finished loading(assuming Im going to be navigating between more than 2 pages).
|
# ? Jun 5, 2007 18:48 |
|
|
# ? Jun 2, 2024 11:27 |
|
KiwiDNA posted:Unfortunately, one problem just led to another. I've got my DropDownList with three results per page options: 25, 50, and 100. When the page loads, it retrieves the current value of the ResultsPerPage variable from session and paginates properly. The drop down list also displays the proper option: I would probably not set the selected index each time unless it is the first loading of the page, which is when that is really needed. The viewstate/browser should be able to hold the selection on subsequent visits just fine, so what you might consider is using the Page.IsPostBack value to see if it is not a postback, and then load the index from the session, otherwise just store to the session after each postback and let the dropdown selection manage itself. I'm a little too confused with just what you've posted to say anything else meaningful, but if you want/need more help feel free to post some more code or pm me about it if you want.
|
# ? Jun 5, 2007 19:41 |