qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
92,258
<p>With my multiproject pom I get an error while running release:prepare. There is nothing fancy about the project setup and every release-step before runs fine. The error I get is:</p> <pre> [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Unable to tag SCM Provider message: The svn tag command failed. Command output: svn: Commit failed (details follow): svn: File '/repos/june/tags/foo-1.0.2/foo.bar.org/pom.xml' already exists </pre> <p>Any idea where it comes from and how to get around it?</p> <p>(sorry for duplicate post - first was closed because I didn't formulate it as a question that can be answered. I hope it's ok now.)</p> <p><b>EDIT</b><br> The maven release plugin takes care of the version handling itself. So when I check the path in the subversion repository the path does not yet exist.</p> <p><b>EDIT 2</b><br> @Ben: I don't know the server version, however the client is 1.5.2, too.</p>
[ { "answer_id": 92330, "author": "Roland Schneider", "author_id": 16515, "author_profile": "https://Stackoverflow.com/users/16515", "pm_score": 0, "selected": false, "text": "<p>As far as I know it is a bug in Subversion 1.5 and not directly related with maven. However a workaround the fi...
2008/09/18
[ "https://Stackoverflow.com/questions/92258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16515/" ]
With my multiproject pom I get an error while running release:prepare. There is nothing fancy about the project setup and every release-step before runs fine. The error I get is: ``` [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Unable to tag SCM Provider message: The svn tag command failed. Command output: svn: Commit failed (details follow): svn: File '/repos/june/tags/foo-1.0.2/foo.bar.org/pom.xml' already exists ``` Any idea where it comes from and how to get around it? (sorry for duplicate post - first was closed because I didn't formulate it as a question that can be answered. I hope it's ok now.) **EDIT** The maven release plugin takes care of the version handling itself. So when I check the path in the subversion repository the path does not yet exist. **EDIT 2** @Ben: I don't know the server version, however the client is 1.5.2, too.
This issue is addressed in the latest version of the [maven-release-plugin](http://maven.apache.org/plugins/maven-release-plugin/). Add this to your POM to pull it in. ``` <build> <pluginManagement> <plugins> <plugin> <artifactId>maven-release-plugin</artifactId> <version>2.0-beta-9</version> </plugin> </plugins> </pluginManagement> </build> ``` The issue that was fixed is [MRELEASE-375](http://jira.codehaus.org/browse/MRELEASE-375).
92,287
<p>I am trying to write a C# client to a server that is written in Java. The server expects a 4 byte (DataInputStread readInt() in Java) message header followed by the actual message.</p> <p>I am absolutely new to C#, how can I send this message header over to the Java Server? I tried it several ways (mostly trial and error without getting too deep into the C# language), and nothing worked. The Java side ended up with the incorrect (very large) message length.</p>
[ { "answer_id": 92309, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": 2, "selected": false, "text": "<p>It's simple, but have you checked endianness? It could easily be a mismatch between the endianness you have sent the da...
2008/09/18
[ "https://Stackoverflow.com/questions/92287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to write a C# client to a server that is written in Java. The server expects a 4 byte (DataInputStread readInt() in Java) message header followed by the actual message. I am absolutely new to C#, how can I send this message header over to the Java Server? I tried it several ways (mostly trial and error without getting too deep into the C# language), and nothing worked. The Java side ended up with the incorrect (very large) message length.
It is, as other posters have pointed out, down to endianness. The Java [DataInputStream](http://java.sun.com/j2se/1.4.2/docs/api/java/io/DataInputStream.html) expects the data to be [big-endian](http://en.wikipedia.org/wiki/Endianness) (network byte order). Judging from the Mono documentation (for equivalents like [BinaryWriter](http://www.go-mono.com/docs/monodoc.ashx?link=T%3aSystem.IO.BinaryWriter)), C# tends toward being little-endian (the default for Win32/x86). So, when you use the standard class library to change the 32bit int '1' to bytes, they produce different results: ``` //byte hex values Java: 00 00 00 01 C#: 01 00 00 00 ``` You can alter the way you write ints in C#: ``` private static void WriteInt(Stream stream, int n) { for(int i=3; i>=0; i--) { int shift = i * 8; //bits to shift byte b = (byte) (n >> shift); stream.WriteByte(b); } } ``` EDIT: A safer way of doing this would be: ``` private static void WriteToNetwork(System.IO.BinaryWriter stream, int n) { n = System.Net.IPAddress.HostToNetworkOrder(n); stream.Write(n); } ```
92,328
<p>Within an event, I'd like to put the focus on a specific TextBox within the ListViewItem's template. The XAML looks like this:</p> <pre><code>&lt;ListView x:Name="myList" ItemsSource="{Binding SomeList}"&gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn&gt; &lt;GridViewColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;!-- Focus this! --&gt; &lt;TextBox x:Name="myBox"/&gt; </code></pre> <p>I've tried the following in the code behind:</p> <pre><code>(myList.FindName("myBox") as TextBox).Focus(); </code></pre> <p>but I seem to have misunderstood the <code>FindName()</code> docs, because it returns <code>null</code>.</p> <p>Also the <code>ListView.Items</code> doesn't help, because that (of course) contains my bound business objects and no ListViewItems.</p> <p>Neither does <code>myList.ItemContainerGenerator.ContainerFromItem(item)</code>, which also returns null.</p>
[ { "answer_id": 92765, "author": "Abe Heidebrecht", "author_id": 9268, "author_profile": "https://Stackoverflow.com/users/9268", "pm_score": 4, "selected": false, "text": "<p>As others have noted, The myBox TextBox can not be found by calling FindName on the ListView. However, you can ge...
2008/09/18
[ "https://Stackoverflow.com/questions/92328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4918/" ]
Within an event, I'd like to put the focus on a specific TextBox within the ListViewItem's template. The XAML looks like this: ``` <ListView x:Name="myList" ItemsSource="{Binding SomeList}"> <ListView.View> <GridView> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <!-- Focus this! --> <TextBox x:Name="myBox"/> ``` I've tried the following in the code behind: ``` (myList.FindName("myBox") as TextBox).Focus(); ``` but I seem to have misunderstood the `FindName()` docs, because it returns `null`. Also the `ListView.Items` doesn't help, because that (of course) contains my bound business objects and no ListViewItems. Neither does `myList.ItemContainerGenerator.ContainerFromItem(item)`, which also returns null.
To understand why `ContainerFromItem` didn't work for me, here some background. The event handler where I needed this functionality looks like this: ``` var item = new SomeListItem(); SomeList.Add(item); ListViewItem = SomeList.ItemContainerGenerator.ContainerFromItem(item); // returns null ``` After the `Add()` the `ItemContainerGenerator` doesn't immediately create the container, because the `CollectionChanged` event could be handled on a non-UI-thread. Instead it starts an asynchronous call and waits for the UI thread to callback and execute the actual ListViewItem control generation. To be notified when this happens, the `ItemContainerGenerator` exposes a `StatusChanged` event which is fired after all Containers are generated. Now I have to listen to this event and decide whether the control currently want's to set focus or not.
92,362
<p><strong>Has anyone found a way to run Selenium RC / Selenium Grid tests, written in C# in parallel?</strong></p> <p>I've currently got a sizable test suite written using Selenium RC's C# driver. Running the entire test suite takes a little over an hour to complete. I normally don't have to run the entire suite so it hasn't been a concern up to now, but it's something that I'd like to be able to do more regularly (ie, as part of an automated build)</p> <p>I've been spending some time recently poking around with the Selenium Grid project whose purpose essentially is to allow those tests to run in parallel. Unfortunately, it seems that the TestDriven.net plugin that I'm using runs the tests serially (ie, one after another). I'm assuming that NUnit would execute the tests in a similar fashion, although I haven't actually tested this out. </p> <p>I've noticed that the NUnit 2.5 betas are starting to talk about running tests in parallel with pNUnit, but I haven't really familiarized myself enough with the project to know for sure whether this would work. </p> <p>Another option I'm considering is separating my test suite into different libraries which would let me run a test from each library concurrently, but I'd like to avoid that if possible since I'm not convinced this is a valid reason for splitting up the test suite.</p>
[ { "answer_id": 96318, "author": "Jeff Martin", "author_id": 13100, "author_profile": "https://Stackoverflow.com/users/13100", "pm_score": 0, "selected": false, "text": "<p>I don't know if no answer counts as an answer but I'd say you have researched everything and you really came up with...
2008/09/18
[ "https://Stackoverflow.com/questions/92362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6112/" ]
**Has anyone found a way to run Selenium RC / Selenium Grid tests, written in C# in parallel?** I've currently got a sizable test suite written using Selenium RC's C# driver. Running the entire test suite takes a little over an hour to complete. I normally don't have to run the entire suite so it hasn't been a concern up to now, but it's something that I'd like to be able to do more regularly (ie, as part of an automated build) I've been spending some time recently poking around with the Selenium Grid project whose purpose essentially is to allow those tests to run in parallel. Unfortunately, it seems that the TestDriven.net plugin that I'm using runs the tests serially (ie, one after another). I'm assuming that NUnit would execute the tests in a similar fashion, although I haven't actually tested this out. I've noticed that the NUnit 2.5 betas are starting to talk about running tests in parallel with pNUnit, but I haven't really familiarized myself enough with the project to know for sure whether this would work. Another option I'm considering is separating my test suite into different libraries which would let me run a test from each library concurrently, but I'd like to avoid that if possible since I'm not convinced this is a valid reason for splitting up the test suite.
I am working on this very thing and have found [Gallio](http://www.gallio.org/) latest can drive mbUnit tests in parallel. You can drive them against a single [Selenium Grid](http://selenium-grid.seleniumhq.org/) hub, which can have several remote control servers listening. I'm using the [latest nightly from Gallio](http://ccnet.gallio.org/Distributables/) to get the [ParallelizableAttribute](http://www.gallio.org/api/html/T_MbUnit_Framework_ParallelizableAttribute.html) and [DegreeOfParallelismAttribute](http://www.gallio.org/api/html/T_MbUnit_Framework_DegreeOfParallelismAttribute.html). Something things I've noticed is I cannot rely on `TestSet` and `TestTeardown` be isolated the parallel tests. You'll need the test to look something like this: ``` [Test] public void Foo(){ var s = new DefaultSelenium("http://grid", 4444, "*firefox", "http://server-under-test"); s.Start(); s.Open("mypage.aspx"); // Continue s.Stop(); } ``` Using the `[SetUp]` attribute to start the Selenium session was causing the tests to not get the remote session from `s.Start()`.
92,376
<p>Is there any way that I can programmatically create (and I guess access) hidden folders on a storage device from within c#?</p>
[ { "answer_id": 92397, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 8, "selected": true, "text": "<pre><code>using System.IO; \n\nstring path = @\"c:\\folders\\newfolder\"; // or whatever \nif (!Directory.Exists(path)) \n...
2008/09/18
[ "https://Stackoverflow.com/questions/92376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816/" ]
Is there any way that I can programmatically create (and I guess access) hidden folders on a storage device from within c#?
``` using System.IO; string path = @"c:\folders\newfolder"; // or whatever if (!Directory.Exists(path)) { DirectoryInfo di = Directory.CreateDirectory(path); di.Attributes = FileAttributes.Directory | FileAttributes.Hidden; } ```
92,396
<p>I've always wondered this - why can't you declare variables after a case label in a switch statement? In C++ you can declare variables pretty much anywhere (and declaring them close to first use is obviously a good thing) but the following still won't work:</p> <pre><code>switch (val) { case VAL: // This won't work int newVal = 42; break; case ANOTHER_VAL: ... break; } </code></pre> <p>The above gives me the following error (MSC):</p> <blockquote> <p>initialization of 'newVal' is skipped by 'case' label</p> </blockquote> <p>This seems to be a limitation in other languages too. Why is this such a problem?</p>
[ { "answer_id": 92408, "author": "Mark Ingram", "author_id": 986, "author_profile": "https://Stackoverflow.com/users/986", "pm_score": 5, "selected": false, "text": "<p>The whole switch statement is in the same scope. To get around it, do this:</p>\n\n<pre><code>switch (val)\n{\n case ...
2008/09/18
[ "https://Stackoverflow.com/questions/92396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
I've always wondered this - why can't you declare variables after a case label in a switch statement? In C++ you can declare variables pretty much anywhere (and declaring them close to first use is obviously a good thing) but the following still won't work: ``` switch (val) { case VAL: // This won't work int newVal = 42; break; case ANOTHER_VAL: ... break; } ``` The above gives me the following error (MSC): > > initialization of 'newVal' is skipped by 'case' label > > > This seems to be a limitation in other languages too. Why is this such a problem?
`Case` statements are only **labels**. This means the compiler will interpret this as a jump directly to the label. In C++, the problem here is one of scope. Your curly brackets define the scope as everything inside the `switch` statement. This means that you are left with a scope where a jump will be performed further into the code skipping the initialization. The correct way to handle this is to define a scope specific to that `case` statement and define your variable within it: ``` switch (val) { case VAL: { // This will work int newVal = 42; break; } case ANOTHER_VAL: ... break; } ```
92,413
<p>I have a SQL Server 2000, C# &amp; ASP.net web app. We want to control access to it by using Active Directory groups. I can get authentication to work if the group I put in is a 'Global' but not if the group is 'Universal'. </p> <p>How can I make this work with 'Universal' groups an well? Here's my authorization block:</p> <pre><code> &lt;authorization&gt; &lt;allow roles="domain\Group Name Here"/&gt; &lt;allow roles="domain\Group Name Here2"/&gt; &lt;allow roles="domain\Group Name Here3"/&gt; &lt;deny users="*"/&gt; &lt;/authorization&gt; </code></pre>
[ { "answer_id": 92919, "author": "jliszka", "author_id": 9767, "author_profile": "https://Stackoverflow.com/users/9767", "pm_score": 1, "selected": false, "text": "<p>Depending on your Active Directory topology, you might have to wait for the Universal Group membership to replicate around...
2008/09/18
[ "https://Stackoverflow.com/questions/92413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730/" ]
I have a SQL Server 2000, C# & ASP.net web app. We want to control access to it by using Active Directory groups. I can get authentication to work if the group I put in is a 'Global' but not if the group is 'Universal'. How can I make this work with 'Universal' groups an well? Here's my authorization block: ``` <authorization> <allow roles="domain\Group Name Here"/> <allow roles="domain\Group Name Here2"/> <allow roles="domain\Group Name Here3"/> <deny users="*"/> </authorization> ```
Turns out I needed to use the "Pre Win2000" id not the regular one.
92,427
<p>Based on a simple test I ran, I don't think it's possible to put an inline &lt;style&gt; tag into an ASP.NET server control. The style did not end up rendering to the output HTML. Even if it was possible, I'm sure it is bad practice to do this.</p> <p>Is it possible to do this? I can see it being useful for quick prototypes that just have 1 or 2 CSS classes to apply.</p>
[ { "answer_id": 92444, "author": "Vaibhav", "author_id": 380, "author_profile": "https://Stackoverflow.com/users/380", "pm_score": 1, "selected": false, "text": "<p>I think you will have to add it as an attribute to the server control... for it to render to HTML.</p>\n\n<p>So basically (i...
2008/09/18
[ "https://Stackoverflow.com/questions/92427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2470/" ]
Based on a simple test I ran, I don't think it's possible to put an inline <style> tag into an ASP.NET server control. The style did not end up rendering to the output HTML. Even if it was possible, I'm sure it is bad practice to do this. Is it possible to do this? I can see it being useful for quick prototypes that just have 1 or 2 CSS classes to apply.
According to [www.w3schools.com](http://www.w3schools.com/TAGS/tag_style.asp): > > The style element goes in the head section. If you want to include a style sheet in your page, you should define the style sheet externally, and link to it using `<link>`. > > > So it's not a good idea to include style elements (e.g. a `<style type="text\css"></style>` block) in a control. If you could, it'd probably have an effect in some browsers but it wouldn't validate and is bad practice. If you want to apply styles inline to an element then either of these would work: C# ``` myControl.Attributes["style"] = "color:red"; myControl.Attributes.Add("style", "color:red"); ``` VB.NET ``` myControl.Attributes("style") = "color:red"; myControl.Attributes.Add("style", "color:red"); ``` But bear in mind that *this will replace any existing styles that are set on the style attribute*. This may be a problem if you try setting styles in more than one place in the code so is something to watch out for. Using CSS classes would be preferable as you can group multiple style declarations and avoid redundancy and page bloat. All controls derived from [WebControl](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webcontrol.aspx) have a [CssClass](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webcontrol.cssclass.aspx) property which you can use, but again be careful not to overwrite existing classes that have been applied elsewhere.
92,438
<p>I use to run</p> <pre><code>$s =~ s/[^[:print:]]//g; </code></pre> <p>on Perl to get rid of non printable characters. </p> <p>In Python there's no POSIX regex classes, and I can't write [:print:] having it mean what I want. I know of no way in Python to detect if a character is printable or not. </p> <p>What would you do? </p> <p>EDIT: It has to support Unicode characters as well. The string.printable way will happily strip them out of the output. curses.ascii.isprint will return false for any unicode character.</p>
[ { "answer_id": 92441, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 2, "selected": false, "text": "<p>The best I've come up with now is (thanks to the python-izers above) </p>\n\n<pre><code>def filter_non_printable(s...
2008/09/18
[ "https://Stackoverflow.com/questions/92438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5190/" ]
I use to run ``` $s =~ s/[^[:print:]]//g; ``` on Perl to get rid of non printable characters. In Python there's no POSIX regex classes, and I can't write [:print:] having it mean what I want. I know of no way in Python to detect if a character is printable or not. What would you do? EDIT: It has to support Unicode characters as well. The string.printable way will happily strip them out of the output. curses.ascii.isprint will return false for any unicode character.
Iterating over strings is unfortunately rather slow in Python. Regular expressions are over an order of magnitude faster for this kind of thing. You just have to build the character class yourself. The *unicodedata* module is quite helpful for this, especially the *unicodedata.category()* function. See [Unicode Character Database](http://www.unicode.org/reports/tr44/#General_Category_Values) for descriptions of the categories. ``` import unicodedata, re, itertools, sys all_chars = (chr(i) for i in range(sys.maxunicode)) categories = {'Cc'} control_chars = ''.join(c for c in all_chars if unicodedata.category(c) in categories) # or equivalently and much more efficiently control_chars = ''.join(map(chr, itertools.chain(range(0x00,0x20), range(0x7f,0xa0)))) control_char_re = re.compile('[%s]' % re.escape(control_chars)) def remove_control_chars(s): return control_char_re.sub('', s) ``` For Python2 ``` import unicodedata, re, sys all_chars = (unichr(i) for i in xrange(sys.maxunicode)) categories = {'Cc'} control_chars = ''.join(c for c in all_chars if unicodedata.category(c) in categories) # or equivalently and much more efficiently control_chars = ''.join(map(unichr, range(0x00,0x20) + range(0x7f,0xa0))) control_char_re = re.compile('[%s]' % re.escape(control_chars)) def remove_control_chars(s): return control_char_re.sub('', s) ``` For some use-cases, additional categories (e.g. all from the *control* group might be preferable, although this might slow down the processing time and increase memory usage significantly. Number of characters per category: * `Cc` (control): 65 * `Cf` (format): 161 * `Cs` (surrogate): 2048 * `Co` (private-use): 137468 * `Cn` (unassigned): 836601 ***Edit** Adding suggestions from the comments.*
92,452
<p>I've been working on this for a few days now, and I've found several solutions but none of them incredibly simple or lightweight. The problem is basically this: We have a cluster of 10 machines, each of which is running the same software on a multithreaded ESB platform. I can deal with concurrency issues between threads on the same machine fairly easily, but what about concurrency on the same data on different machines? </p> <p>Essentially the software receives requests to feed a customer's data from one business to another via web services. However, the customer may or may not exist yet on the other system. If it does not, we create it via a web service method. So it requires a sort of test-and-set, but I need a semaphore of some sort to lock out the other machines from causing race conditions. I've had situations before where a remote customer was created twice for a single local customer, which isn't really desirable.</p> <p>Solutions I've toyed with conceptually are:</p> <ol> <li><p>Using our fault-tolerant shared file system to create "lock" files which will be checked for by each machine depending on the customer</p></li> <li><p>Using a special table in our database, and locking the whole table in order to do a "test-and-set" for a lock record.</p></li> <li><p>Using Terracotta, an open source server software which assists in scaling, but uses a hub-and-spoke model.</p></li> <li><p>Using EHCache for synchronous replication of my in-memory "locks."</p></li> </ol> <p>I can't imagine that I'm the only person who's ever had this kind of problem. How did you solve it? Did you cook something up in-house or do you have a favorite 3rd-party product?</p>
[ { "answer_id": 92521, "author": "Clinton Pierce", "author_id": 8173, "author_profile": "https://Stackoverflow.com/users/8173", "pm_score": -1, "selected": false, "text": "<p>Back in the day, we'd use a specific \"lock server\" on the network to handle this. Bleh.</p>\n\n<p>Your database...
2008/09/18
[ "https://Stackoverflow.com/questions/92452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7567/" ]
I've been working on this for a few days now, and I've found several solutions but none of them incredibly simple or lightweight. The problem is basically this: We have a cluster of 10 machines, each of which is running the same software on a multithreaded ESB platform. I can deal with concurrency issues between threads on the same machine fairly easily, but what about concurrency on the same data on different machines? Essentially the software receives requests to feed a customer's data from one business to another via web services. However, the customer may or may not exist yet on the other system. If it does not, we create it via a web service method. So it requires a sort of test-and-set, but I need a semaphore of some sort to lock out the other machines from causing race conditions. I've had situations before where a remote customer was created twice for a single local customer, which isn't really desirable. Solutions I've toyed with conceptually are: 1. Using our fault-tolerant shared file system to create "lock" files which will be checked for by each machine depending on the customer 2. Using a special table in our database, and locking the whole table in order to do a "test-and-set" for a lock record. 3. Using Terracotta, an open source server software which assists in scaling, but uses a hub-and-spoke model. 4. Using EHCache for synchronous replication of my in-memory "locks." I can't imagine that I'm the only person who's ever had this kind of problem. How did you solve it? Did you cook something up in-house or do you have a favorite 3rd-party product?
you might want to consider using [Hazelcast](http://www.hazelcast.com) distributed locks. Super lite and easy. ``` java.util.concurrent.locks.Lock lock = Hazelcast.getLock ("mymonitor"); lock.lock (); try { // do your stuff }finally { lock.unlock(); } ``` Hazelcast - Distributed Queue, Map, Set, List, Lock
92,456
<p>I have a legacy C++ module that offers encryption/decryption using the openssl library (DES encryption). I'm trying to translate that code into java, and I don't want to rely on a DLL, JNI, etc... C++ code looks like:</p> <pre><code>des_string_to_key(reinterpret_cast&lt;const char *&gt;(key1), &amp;initkey); des_string_to_key(reinterpret_cast&lt;const char *&gt;(key2), &amp;key); key_sched(&amp;key, ks); // ... des_ncbc_encrypt(reinterpret_cast&lt;const unsigned char *&gt;(tmp.c_str()), reinterpret_cast&lt; unsigned char *&gt;(encrypted_buffer), tmp.length(), ks, &amp;initkey, DES_ENCRYPT); return base64(reinterpret_cast&lt;const unsigned char *&gt;(encrypted_buffer), strlen(encrypted_buffer)); </code></pre> <p>Java code looks like:</p> <pre><code>Cipher ecipher; try { ecipher = Cipher.getInstance("DES"); SecretKeySpec keySpec = new SecretKeySpec(key, "DES"); ecipher.init(Cipher.ENCRYPT_MODE, keySpec); byte[] utf8 = password.getBytes("UTF8"); byte[] enc = ecipher.doFinal(utf8); return new sun.misc.BASE64Encoder().encode(enc); } catch { // ... } </code></pre> <p>So I can do DES encryption in Java pretty easily, but how can I get the same result as with the above code with methods that are completely different? What bothers me in particular is the fact that the C++ version uses 2 keys while the Java version uses only 1 key. The answer about DES in CBC mode is quite satisfying but I can't get it to work yet. Here are more details about the original code: unsigned char key1[10]= {0}; unsigned char key2[50]= {0};</p> <pre><code>int i; for (i=0;i&lt;8;i++) key1[i] = 31+int((i*sqrt((double)i*5)))%100; key1[9]=0; for (i=0;i&lt;48;i++) key2[i] = 31+int((i*i*sqrt((double)i*2)))%100; key2[49]=0; ... // Initialize encrypted buffer memset(encrypted_buffer, 0, sizeof(encrypted_buffer)); // Add begin Text and End Text to the encrypted message std::string input; const char beginText = 2; const char endText = 3; input.append(1,beginText); input.append(bufferToEncrypt); input.append(1,endText); // Add padding tmp.assign(desPad(input)); des_ncbc_encrypt(reinterpret_cast&lt;const unsigned char *&gt;(tmp.c_str()), reinterpret_cast&lt; unsigned char *&gt;(encrypted_buffer), tmp.length(), ks, &amp;initkey, DES_ENCRYPT); ... </code></pre> <p>From what I've read, the key should be 56 (or 64, it's not clear to me) bits long, but here it's 48 bytes long.</p>
[ { "answer_id": 92547, "author": "jodonnell", "author_id": 4223, "author_profile": "https://Stackoverflow.com/users/4223", "pm_score": 0, "selected": false, "text": "<p>The algorithms should match; if you're getting different results it may have to do with the way you're handling the keys...
2008/09/18
[ "https://Stackoverflow.com/questions/92456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17647/" ]
I have a legacy C++ module that offers encryption/decryption using the openssl library (DES encryption). I'm trying to translate that code into java, and I don't want to rely on a DLL, JNI, etc... C++ code looks like: ``` des_string_to_key(reinterpret_cast<const char *>(key1), &initkey); des_string_to_key(reinterpret_cast<const char *>(key2), &key); key_sched(&key, ks); // ... des_ncbc_encrypt(reinterpret_cast<const unsigned char *>(tmp.c_str()), reinterpret_cast< unsigned char *>(encrypted_buffer), tmp.length(), ks, &initkey, DES_ENCRYPT); return base64(reinterpret_cast<const unsigned char *>(encrypted_buffer), strlen(encrypted_buffer)); ``` Java code looks like: ``` Cipher ecipher; try { ecipher = Cipher.getInstance("DES"); SecretKeySpec keySpec = new SecretKeySpec(key, "DES"); ecipher.init(Cipher.ENCRYPT_MODE, keySpec); byte[] utf8 = password.getBytes("UTF8"); byte[] enc = ecipher.doFinal(utf8); return new sun.misc.BASE64Encoder().encode(enc); } catch { // ... } ``` So I can do DES encryption in Java pretty easily, but how can I get the same result as with the above code with methods that are completely different? What bothers me in particular is the fact that the C++ version uses 2 keys while the Java version uses only 1 key. The answer about DES in CBC mode is quite satisfying but I can't get it to work yet. Here are more details about the original code: unsigned char key1[10]= {0}; unsigned char key2[50]= {0}; ``` int i; for (i=0;i<8;i++) key1[i] = 31+int((i*sqrt((double)i*5)))%100; key1[9]=0; for (i=0;i<48;i++) key2[i] = 31+int((i*i*sqrt((double)i*2)))%100; key2[49]=0; ... // Initialize encrypted buffer memset(encrypted_buffer, 0, sizeof(encrypted_buffer)); // Add begin Text and End Text to the encrypted message std::string input; const char beginText = 2; const char endText = 3; input.append(1,beginText); input.append(bufferToEncrypt); input.append(1,endText); // Add padding tmp.assign(desPad(input)); des_ncbc_encrypt(reinterpret_cast<const unsigned char *>(tmp.c_str()), reinterpret_cast< unsigned char *>(encrypted_buffer), tmp.length(), ks, &initkey, DES_ENCRYPT); ... ``` From what I've read, the key should be 56 (or 64, it's not clear to me) bits long, but here it's 48 bytes long.
I'm not an OpenSSL expert, but I'd guess the C++ code is using DES in CBC mode thus needing an IV (that's what the initKey probably is, and that's why you think you need two keys). If I'm right, you need to change your Java code to use DES in CBC mode too, then the Java code too will require an encryption key and an IV.
92,504
<p>I'm trying to create a self signed certificate for use with Apache Tomcat 6. Every certificate I can make always results in the browser connecting with AES-128. The customer would like me to demonstrate that I can create a connection at AES-256.</p> <p>I've tried java's keytool and openssl. I've tried with a variety of parameters, but can't seem to specify anything about the keysize, just the signature size.</p> <p>How can I get the browser-tomcat connection to use AES-256 with a self signed certificate?</p>
[ { "answer_id": 93095, "author": "delfuego", "author_id": 16414, "author_profile": "https://Stackoverflow.com/users/16414", "pm_score": 1, "selected": false, "text": "<p>danivo, so long as the server's cert is capable of AES encryption, the level of encryption between the browser and the ...
2008/09/18
[ "https://Stackoverflow.com/questions/92504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17583/" ]
I'm trying to create a self signed certificate for use with Apache Tomcat 6. Every certificate I can make always results in the browser connecting with AES-128. The customer would like me to demonstrate that I can create a connection at AES-256. I've tried java's keytool and openssl. I've tried with a variety of parameters, but can't seem to specify anything about the keysize, just the signature size. How can I get the browser-tomcat connection to use AES-256 with a self signed certificate?
Okie doke, I think I just figured this out. As I said above, the key bit of knowledge is that the cert doesn't matter, so long as it's generated with an algorithm that supports AES 256-bit encryption (e.g., RSA). Just to make sure that we're on the same page, for my testing, I generated my self-signed cert using the following: ``` keytool -genkey -alias tomcat -keyalg RSA ``` Now, you have to make sure that your Java implementation on your server supports AES-256, and this is the tricky bit. I did my testing on an OS X (OS 10.5) box, and when I checked to see the list of ciphers that it supported by default, AES-256 was NOT on the list, which is why using that cert I generated above only was creating an AES-128 connection between my browser and Tomcat. (Well, technically, TLS\_RSA\_WITH\_AES\_256\_CBC\_SHA was not on the list -- that's the cipher that you want, according to [this JDK 5 list](http://java.sun.com/j2se/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#AppA).) For completeness, here's the short Java app I created to check my box's supported ciphers: ``` import java.util.Arrays; import javax.net.ssl.SSLSocketFactory; public class CipherSuites { public static void main(String[] args) { SSLSocketFactory sslsf = (SSLSocketFactory) SSLSocketFactory.getDefault(); String[] ciphers = sslsf.getDefaultCipherSuites(); Arrays.sort(ciphers); for (String cipher : ciphers) { System.out.println(cipher); } } } ``` It turns out that JDK 5, which is what this OS X box has installed by default, needs the "Unlimited Strength Jurisdiction Policy Files" installed in order to tell Java that it's OK to use the higher-bit encryption levels; you can [find those files here](http://java.sun.com/javase/downloads/index_jdk5.jsp) (scroll down and look at the top of the "Other Downloads" section). I'm not sure offhand if JDK 6 needs the same thing done, but the same policy files for JDK 6 [are available here](http://java.sun.com/javase/downloads/index.jsp), so I assume it does. Unzip that file, read the README to see how to install the files where they belong, and then check your supported ciphers again... I bet AES-256 is now on the list. If it is, you should be golden; just restart Tomcat, connect to your SSL instance, and I bet you'll now see an AES-256 connection.
92,514
<p>Is there any way to create a ODBC DSN with C#?</p> <p>Maybe a P/invoke?</p>
[ { "answer_id": 92538, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 1, "selected": false, "text": "<p>Following resources might be helpful:</p>\n\n<p>MSDN:</p>\n\n<p><a href=\"http://support.microsoft.com/kb/310988\" rel=\"nofol...
2008/09/18
[ "https://Stackoverflow.com/questions/92514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1098074/" ]
Is there any way to create a ODBC DSN with C#? Maybe a P/invoke?
You can use Registry classes to write the dsn info in the registry, under ``` HKLM\Software\ODBC\ODBC.INI\ODBC Data Sources ``` You'll need to check what values are needed for you ODBC driver.
92,522
<p>What is the best way to issue a http get in VB.net? I want to get the result of a request like <a href="http://api.hostip.info/?ip=68.180.206.184" rel="noreferrer">http://api.hostip.info/?ip=68.180.206.184</a> </p>
[ { "answer_id": 92529, "author": "Dario Solera", "author_id": 16026, "author_profile": "https://Stackoverflow.com/users/16026", "pm_score": 1, "selected": false, "text": "<p>You should try the <a href=\"http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx\" rel=\"nofollo...
2008/09/18
[ "https://Stackoverflow.com/questions/92522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4221/" ]
What is the best way to issue a http get in VB.net? I want to get the result of a request like <http://api.hostip.info/?ip=68.180.206.184>
In VB.NET: ``` Dim webClient As New System.Net.WebClient Dim result As String = webClient.DownloadString("http://api.hostip.info/?ip=68.180.206.184") ``` In C#: ``` System.Net.WebClient webClient = new System.Net.WebClient(); string result = webClient.DownloadString("http://api.hostip.info/?ip=68.180.206.184"); ```
92,533
<p>Based on <a href="https://stackoverflow.com/questions/6209/split-a-string-ignoring-quoted-sections#6243">"Split a string by spaces in Python"</a>, which uses <em>shlex.split</em> to split a string with quotes smartly, I would be interested in hearing about other common tasks solved by non-obvious standard library functions. </p> <p>If this turns into <a href="http://www.doughellmann.com/projects/PyMOTW/" rel="nofollow noreferrer">Module of The Week</a>, that's fine too. </p>
[ { "answer_id": 92548, "author": "William Keller", "author_id": 17095, "author_profile": "https://Stackoverflow.com/users/17095", "pm_score": 2, "selected": false, "text": "<p>I found struct.unpack to be a godsend for unpacking binary data formats after I learned of it!</p>\n" }, { ...
2008/09/18
[ "https://Stackoverflow.com/questions/92533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15842/" ]
Based on ["Split a string by spaces in Python"](https://stackoverflow.com/questions/6209/split-a-string-ignoring-quoted-sections#6243), which uses *shlex.split* to split a string with quotes smartly, I would be interested in hearing about other common tasks solved by non-obvious standard library functions. If this turns into [Module of The Week](http://www.doughellmann.com/projects/PyMOTW/), that's fine too.
I was quite surprised to learn that you could use the bisect module to do a very fast binary search in a sequence. It's documentation doesn't say anything about it: > > This module provides support for maintaining a list in sorted order without having to sort the list after each insertion. > > > The usage is very simple: ``` >>> import bisect >>> lst = [4, 7, 10, 23, 25, 100, 103, 201, 333] >>> bisect.bisect_left(lst, 23) 3 ``` You have to remember though, that it's quicker to linearly look for something in a list goes item by item, than sorting the list and then doing a binary search on it. The first option is O(n), the second is O(nlogn).
92,540
<p>In a WinForms 2.0 C# application, what is the typical method used for saving and restoring form position and size in an application?</p> <p>Related, is it possible to add new User scoped application settings AT RUNTIME? I totally see how to add settings at design time, that's not a problem. But what if I want to create one at runtime?</p> <p>More details:</p> <p>My application is a conversion of an existing Visual FoxPro application. I've been trying to read as much as I can about application settings, user settings, etc. and get myself clear on the .Net way of doing things, but there are still several things I am confused on.</p> <p>In the Fox app, saved settings are stored in the registry. My forms are subclassed, and I have base class code that automatically saves the form position and size in the registry keyed on the form name. Whenever I create a new form, I don't have to do anything special to get this behavior; it's built in to the base class. My .Net forms are also subclassed, that part is working well.</p> <p>In .Net, I get the impression I'm supposed to use User scoped settings for things like user preferences. Size and location of a form definitely seem like a user preference. But, I can't see any way to automatically add these settings to the project. In other words, every time I add a new form to my project (and their are 100's of forms), I have to remember to ADD a User scoped application setting and be sure to give it the same name as the form, i.e., &quot;FormMySpecialSizePosition&quot; to hold the size and position. I'd rather not have to remember to do that. Is this just tough luck? Or am I totally barking up the wrong tree by trying to use User scoped settings? Do I need to create my own XML file to hold settings, so that I can do whatever I want (i.e, add a new setting at runtime)? Or something else?</p> <p>Surely this is very common and somebody can tell the &quot;right&quot; way to do it.</p>
[ { "answer_id": 93211, "author": "Stormenet", "author_id": 2090, "author_profile": "https://Stackoverflow.com/users/2090", "pm_score": 0, "selected": false, "text": "<p>You could create a base form class with common functionality such as remembering the position and size and inherit from ...
2008/09/18
[ "https://Stackoverflow.com/questions/92540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In a WinForms 2.0 C# application, what is the typical method used for saving and restoring form position and size in an application? Related, is it possible to add new User scoped application settings AT RUNTIME? I totally see how to add settings at design time, that's not a problem. But what if I want to create one at runtime? More details: My application is a conversion of an existing Visual FoxPro application. I've been trying to read as much as I can about application settings, user settings, etc. and get myself clear on the .Net way of doing things, but there are still several things I am confused on. In the Fox app, saved settings are stored in the registry. My forms are subclassed, and I have base class code that automatically saves the form position and size in the registry keyed on the form name. Whenever I create a new form, I don't have to do anything special to get this behavior; it's built in to the base class. My .Net forms are also subclassed, that part is working well. In .Net, I get the impression I'm supposed to use User scoped settings for things like user preferences. Size and location of a form definitely seem like a user preference. But, I can't see any way to automatically add these settings to the project. In other words, every time I add a new form to my project (and their are 100's of forms), I have to remember to ADD a User scoped application setting and be sure to give it the same name as the form, i.e., "FormMySpecialSizePosition" to hold the size and position. I'd rather not have to remember to do that. Is this just tough luck? Or am I totally barking up the wrong tree by trying to use User scoped settings? Do I need to create my own XML file to hold settings, so that I can do whatever I want (i.e, add a new setting at runtime)? Or something else? Surely this is very common and somebody can tell the "right" way to do it.
``` private void Form1_Load( object sender, EventArgs e ) { // restore location and size of the form on the desktop this.DesktopBounds = new Rectangle(Properties.Settings.Default.Location, Properties.Settings.Default.Size); // restore form's window state this.WindowState = ( FormWindowState )Enum.Parse( typeof(FormWindowState), Properties.Settings.Default.WindowState); } private void Form1_FormClosing( object sender, FormClosingEventArgs e ) { System.Drawing.Rectangle bounds = this.WindowState != FormWindowState.Normal ? this.RestoreBounds : this.DesktopBounds; Properties.Settings.Default.Location = bounds.Location; Properties.Settings.Default.Size = bounds.Size; Properties.Settings.Default.WindowState = Enum.GetName(typeof(FormWindowState), this.WindowState); // persist location ,size and window state of the form on the desktop Properties.Settings.Default.Save(); } ```
92,546
<p>When refactoring away some <code>#defines</code> I came across declarations similar to the following in a C++ header file:</p> <pre><code>static const unsigned int VAL = 42; const unsigned int ANOTHER_VAL = 37; </code></pre> <p>The question is, what difference, if any, will the static make? Note that multiple inclusion of the headers isn't possible due to the classic <code>#ifndef HEADER</code> <code>#define HEADER</code> <code>#endif</code> trick (if that matters).</p> <p>Does the static mean only one copy of <code>VAL</code> is created, in case the header is included by more than one source file?</p>
[ { "answer_id": 92568, "author": "Jim Buck", "author_id": 2666, "author_profile": "https://Stackoverflow.com/users/2666", "pm_score": 0, "selected": false, "text": "<p>Static prevents another compilation unit from externing that variable so that the compiler can just \"inline\" the variab...
2008/09/18
[ "https://Stackoverflow.com/questions/92546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
When refactoring away some `#defines` I came across declarations similar to the following in a C++ header file: ``` static const unsigned int VAL = 42; const unsigned int ANOTHER_VAL = 37; ``` The question is, what difference, if any, will the static make? Note that multiple inclusion of the headers isn't possible due to the classic `#ifndef HEADER` `#define HEADER` `#endif` trick (if that matters). Does the static mean only one copy of `VAL` is created, in case the header is included by more than one source file?
The `static` means that there will be one copy of `VAL` created for each source file it is included in. But it also means that multiple inclusions will not result in multiple definitions of `VAL` that will collide at link time. In C, without the `static` you would need to ensure that only one source file defined `VAL` while the other source files declared it `extern`. Usually one would do this by defining it (possibly with an initializer) in a source file and put the `extern` declaration in a header file. `static` variables at global level are only visible in their own source file whether they got there via an include or were in the main file. --- *Editor's note:* In C++, `const` objects with neither the `static` nor `extern` keywords in their declaration are implicitly `static`.
92,613
<p>I have some code which is supposed to display a short message. Here's the pertinent code:</p> <pre><code>DATA SEGMENT 'DATA' MSG DB 0AH, 0DH, 'Hello, Adam', '$' CHAR DB 00H DATA ENDS CODE SEGMENT 'CODE' PRINT_MSG: MOV AH, 09H ;Command to print string of characters MOV DX, OFFSET MSG ;Mov address of message into DX INT 21H ;DOS Interrupt JMP WAITING ;Loop back to waiting state CODE ENDS </code></pre> <p>And the output is:</p> <pre><code>E:\ece323\software\lab2&gt;MAIN.EXE ?F ^?¶ ? N? ? -!- Hello, Adam- </code></pre> <p>What is going on here?</p>
[ { "answer_id": 92708, "author": "Nils Pipenbrinck", "author_id": 15955, "author_profile": "https://Stackoverflow.com/users/15955", "pm_score": 2, "selected": false, "text": "<p>My guess is that your DS does not point to your data-segment.</p>\n\n<p>Int21 Function 0x09 takes the string fr...
2008/09/18
[ "https://Stackoverflow.com/questions/92613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13790/" ]
I have some code which is supposed to display a short message. Here's the pertinent code: ``` DATA SEGMENT 'DATA' MSG DB 0AH, 0DH, 'Hello, Adam', '$' CHAR DB 00H DATA ENDS CODE SEGMENT 'CODE' PRINT_MSG: MOV AH, 09H ;Command to print string of characters MOV DX, OFFSET MSG ;Mov address of message into DX INT 21H ;DOS Interrupt JMP WAITING ;Loop back to waiting state CODE ENDS ``` And the output is: ``` E:\ece323\software\lab2>MAIN.EXE ?F ^?¶ ? N? ? -!- Hello, Adam- ``` What is going on here?
My guess is that your DS does not point to your data-segment. Int21 Function 0x09 takes the string from DS:DX. Remember that DX is only a 16 bit register. To access data outside the 16 bit range you have to use segment registers. These are called DS and ES for data, CS for code and SS for the stack (there are FS and GS on i386 as well). The exact address you load from is given by 16 \* segment\_register + offset\_register. Int21 cannot guess where your DS is, so you have to load it prior to call the interrupt. I guess you have never initialized your DS register, so it most likely points to the code, not the data-segment. Try to replace your ``` MOV DX, offset MSG ``` by: ``` LDS DX, MSG ; Check that, it's been ages since I've written 16 bit code. ``` Unfortunatley it's been years since I've last played with 16 bit assembler, so I can't check it, but LDS should do the trick. You may also load DS indirectly at your program startup by something like this: ``` MOV AX, SEG DATA ; check that - can be SEGMENT or so as well. MOV DS, AX ```
92,620
<p>I came back today to an old script I had for logging into Gmail via SSL. The script worked fine last time I ran it (several months ago) but now it dies immediately with:</p> <pre><code>&lt;urlopen error The read operation timed out&gt; </code></pre> <p>If I set the timeout (no matter how long), it dies even more immediately with:</p> <pre><code>&lt;urlopen error The connect operation timed out&gt; </code></pre> <p>The latter is reproducible with:</p> <pre><code>import socket socket.setdefaulttimeout(30000) sock = socket.socket() sock.connect(('www.google.com', 443)) ssl = socket.ssl(sock) </code></pre> <p>returning:</p> <pre><code>socket.sslerror: The connect operation timed out </code></pre> <p>but I can't seem to reproduce the former and, after much stepping thru the code, I have no clue what's causing any of this.</p>
[ { "answer_id": 93401, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>www.google.com is not accessible by HTTPS. It redirects to insecure HTTP. To get to mail, you should be going go <a href=\...
2008/09/18
[ "https://Stackoverflow.com/questions/92620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4300/" ]
I came back today to an old script I had for logging into Gmail via SSL. The script worked fine last time I ran it (several months ago) but now it dies immediately with: ``` <urlopen error The read operation timed out> ``` If I set the timeout (no matter how long), it dies even more immediately with: ``` <urlopen error The connect operation timed out> ``` The latter is reproducible with: ``` import socket socket.setdefaulttimeout(30000) sock = socket.socket() sock.connect(('www.google.com', 443)) ssl = socket.ssl(sock) ``` returning: ``` socket.sslerror: The connect operation timed out ``` but I can't seem to reproduce the former and, after much stepping thru the code, I have no clue what's causing any of this.
``` import socket socket.setdefaulttimeout(30000) sock = socket.socket() sock.connect(('www.google.com', 443)) ssl = socket.ssl(sock) ssl.server() --> '/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com' ``` It works just fine. I can't reproduce your error.
92,689
<p>I am writing a Composite control, which contains a listview to display a table of items. Normally when using a ListView in Asp.NET I would define the templates in the code-forward.</p> <pre><code>&lt;asp:ListView runat="server" ID="ArticleList"&gt; &lt;LayoutTemplate&gt; &lt;div class="ContentContainer"&gt; &lt;div runat="server" id="itemPlaceholder" /&gt; &lt;/div&gt; &lt;/LayoutTemplate&gt; &lt;ItemTemplate&gt; &lt;div&gt; &lt;div&gt;&lt;%# Eval("Content") %&gt;&lt;/div&gt; &lt;/div&gt; &lt;/ItemTemplate&gt; &lt;/asp:ListView&gt; </code></pre> <p>I assume it's something like:</p> <pre><code>ListView view = new ListView(); view.LayoutTemplate = ..... view.ItemTemplate = ..... // when do I call these? view.DataSource = myDataSource; view.DataBind(); </code></pre> <p><strong>Update:</strong> I created 2 templates by implementing the ITemplate interface:</p> <pre><code>private class LayoutTemplate : ITemplate { public void InstantiateIn(Control container) { var outer = new HtmlGenericControl("div"); var inner = new HtmlGenericControl("div") { ID = "itemPlaceholder" }; table.Rows.Add(row); container.Controls.Add(table); } } private class ItemTemplate : ITemplate { public void InstantiateIn(Control container) { var inner = new HtmlGenericControl("div"); container.Controls.Add(inner); } } </code></pre> <p>and I can add them using:</p> <pre><code>dataList.LayoutTemplate = new LayoutTemplate(); dataList.ItemTemplate = new ItemTemplate(); </code></pre> <p>But then I get stuck, since container.DataItem is null.</p>
[ { "answer_id": 93348, "author": "paudirac", "author_id": 15554, "author_profile": "https://Stackoverflow.com/users/15554", "pm_score": 2, "selected": false, "text": "<p>Could this link be of some help? <a href=\"http://web.archive.org/web/20120414044008/http://iridescence.no/post/Using-T...
2008/09/18
[ "https://Stackoverflow.com/questions/92689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1837197/" ]
I am writing a Composite control, which contains a listview to display a table of items. Normally when using a ListView in Asp.NET I would define the templates in the code-forward. ``` <asp:ListView runat="server" ID="ArticleList"> <LayoutTemplate> <div class="ContentContainer"> <div runat="server" id="itemPlaceholder" /> </div> </LayoutTemplate> <ItemTemplate> <div> <div><%# Eval("Content") %></div> </div> </ItemTemplate> </asp:ListView> ``` I assume it's something like: ``` ListView view = new ListView(); view.LayoutTemplate = ..... view.ItemTemplate = ..... // when do I call these? view.DataSource = myDataSource; view.DataBind(); ``` **Update:** I created 2 templates by implementing the ITemplate interface: ``` private class LayoutTemplate : ITemplate { public void InstantiateIn(Control container) { var outer = new HtmlGenericControl("div"); var inner = new HtmlGenericControl("div") { ID = "itemPlaceholder" }; table.Rows.Add(row); container.Controls.Add(table); } } private class ItemTemplate : ITemplate { public void InstantiateIn(Control container) { var inner = new HtmlGenericControl("div"); container.Controls.Add(inner); } } ``` and I can add them using: ``` dataList.LayoutTemplate = new LayoutTemplate(); dataList.ItemTemplate = new ItemTemplate(); ``` But then I get stuck, since container.DataItem is null.
The trick is to subscribe to the databinding event of the itemplaceholder in the ItemTemplate. The complete solution: ``` public class FibonacciControl : CompositeControl { public FibonacciControl() { // .... } protected override void CreateChildControls() { base.CreateChildControls(); ListView view = new ListView(); view.LayoutTemplate = new LayoutTemplate(); view.ItemTemplate = new ItemTemplate(); view.DataSource = FibonacciSequence(); view.DataBind(); this.Controls.Add(view); } private IEnumerable<int> FibonacciSequence() { int i1 = 0; int i2 = 1; for (int i = 0; i < Iterations; i++) { yield return i1 + i2; int temp = i1 + i2; i1 = i2; i2 = temp; } yield break; } public int Iterations { get; set; } private class LayoutTemplate : ITemplate { public void InstantiateIn(Control container) { var ol = new HtmlGenericControl("ol"); var li = new HtmlGenericControl("li") { ID = "itemPlaceholder" }; ol.Controls.Add(li); container.Controls.Add(ol); } } private class ItemTemplate : ITemplate { public void InstantiateIn(Control container) { var li = new HtmlGenericControl("li"); li.DataBinding += DataBinding; container.Controls.Add(li); } public void DataBinding(object sender, EventArgs e) { var container = (HtmlGenericControl)sender; var dataItem = ((ListViewDataItem)container.NamingContainer).DataItem; container.Controls.Add( new Literal(){Text = dataItem.ToString() }); } } } ```
92,696
<p>I have a couple databases on a shared SQL Server 2005 cluster instance, that I would like performance metrics on. I have some processes that run for a very long time and suspect that code inefficiencies, rather than insufficient hardware are to blame.</p> <p>I would like some way to get these performance metrics so that I can rule out the database hardware as the culprit.</p>
[ { "answer_id": 93348, "author": "paudirac", "author_id": 15554, "author_profile": "https://Stackoverflow.com/users/15554", "pm_score": 2, "selected": false, "text": "<p>Could this link be of some help? <a href=\"http://web.archive.org/web/20120414044008/http://iridescence.no/post/Using-T...
2008/09/18
[ "https://Stackoverflow.com/questions/92696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5885/" ]
I have a couple databases on a shared SQL Server 2005 cluster instance, that I would like performance metrics on. I have some processes that run for a very long time and suspect that code inefficiencies, rather than insufficient hardware are to blame. I would like some way to get these performance metrics so that I can rule out the database hardware as the culprit.
The trick is to subscribe to the databinding event of the itemplaceholder in the ItemTemplate. The complete solution: ``` public class FibonacciControl : CompositeControl { public FibonacciControl() { // .... } protected override void CreateChildControls() { base.CreateChildControls(); ListView view = new ListView(); view.LayoutTemplate = new LayoutTemplate(); view.ItemTemplate = new ItemTemplate(); view.DataSource = FibonacciSequence(); view.DataBind(); this.Controls.Add(view); } private IEnumerable<int> FibonacciSequence() { int i1 = 0; int i2 = 1; for (int i = 0; i < Iterations; i++) { yield return i1 + i2; int temp = i1 + i2; i1 = i2; i2 = temp; } yield break; } public int Iterations { get; set; } private class LayoutTemplate : ITemplate { public void InstantiateIn(Control container) { var ol = new HtmlGenericControl("ol"); var li = new HtmlGenericControl("li") { ID = "itemPlaceholder" }; ol.Controls.Add(li); container.Controls.Add(ol); } } private class ItemTemplate : ITemplate { public void InstantiateIn(Control container) { var li = new HtmlGenericControl("li"); li.DataBinding += DataBinding; container.Controls.Add(li); } public void DataBinding(object sender, EventArgs e) { var container = (HtmlGenericControl)sender; var dataItem = ((ListViewDataItem)container.NamingContainer).DataItem; container.Controls.Add( new Literal(){Text = dataItem.ToString() }); } } } ```
92,698
<p>I'm looking for an Access 2007 equivalent to SQL Server's COALESCE function.</p> <p>In SQL Server you could do something like:</p> <p><strong>Person</strong></p> <pre><code>John Steve Richard </code></pre> <p><strong>SQL</strong></p> <pre><code>DECLARE @PersonList nvarchar(1024) SELECT @PersonList = COALESCE(@PersonList + ',','') + Person FROM PersonTable PRINT @PersonList </code></pre> <p>Which produces: John, Steve, Richard</p> <p>I want to do the same but in Access 2007.</p> <p>Does anyone know how to combine rows like this in Access 2007?</p>
[ { "answer_id": 92878, "author": "Nick Craver", "author_id": 13249, "author_profile": "https://Stackoverflow.com/users/13249", "pm_score": 0, "selected": false, "text": "<p>I think Nz is what you're after, syntax is <code>Nz(variant, [if null value])</code>. Here's the documentation link:...
2008/09/18
[ "https://Stackoverflow.com/questions/92698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3742/" ]
I'm looking for an Access 2007 equivalent to SQL Server's COALESCE function. In SQL Server you could do something like: **Person** ``` John Steve Richard ``` **SQL** ``` DECLARE @PersonList nvarchar(1024) SELECT @PersonList = COALESCE(@PersonList + ',','') + Person FROM PersonTable PRINT @PersonList ``` Which produces: John, Steve, Richard I want to do the same but in Access 2007. Does anyone know how to combine rows like this in Access 2007?
Here is a sample User Defined Function (UDF) and possible usage. Function: ``` Function Coalsce(strSQL As String, strDelim, ParamArray NameList() As Variant) Dim db As Database Dim rs As DAO.Recordset Dim strList As String Set db = CurrentDb If strSQL <> "" Then Set rs = db.OpenRecordset(strSQL) Do While Not rs.EOF strList = strList & strDelim & rs.Fields(0) rs.MoveNext Loop strList = Mid(strList, Len(strDelim)) Else strList = Join(NameList, strDelim) End If Coalsce = strList End Function ``` Usage: ``` SELECT documents.MembersOnly, Coalsce("SELECT FName From Persons WHERE Member=True",":") AS Who, Coalsce("",":","Mary","Joe","Pat?") AS Others FROM documents; ``` An ADO version, inspired by a comment by onedaywhen ``` Function ConcatADO(strSQL As String, strColDelim, strRowDelim, ParamArray NameList() As Variant) Dim rs As New ADODB.Recordset Dim strList As String On Error GoTo Proc_Err If strSQL <> "" Then rs.Open strSQL, CurrentProject.Connection strList = rs.GetString(, , strColDelim, strRowDelim) strList = Mid(strList, 1, Len(strList) - Len(strRowDelim)) Else strList = Join(NameList, strColDelim) End If ConcatADO = strList Exit Function Proc_Err: ConcatADO = "***" & UCase(Err.Description) End Function ``` From: <http://wiki.lessthandot.com/index.php/Concatenate_a_List_into_a_Single_Field_%28Column%29>
92,699
<p>I have a table called OffDays, where weekends and holiday dates are kept. I have a table called LeadTime where amount of time (in days) for a product to be manufactured is stored. Finally I have a table called Order where a product and the order date is kept.</p> <p>Is it possible to query when a product will be finished manufacturing without using stored procedures or loops?</p> <p>For example:</p> <ul> <li>OffDays has 2008-01-10, 2008-01-11, 2008-01-14.</li> <li>LeadTime has 5 for product 9.</li> <li>Order has 2008-01-09 for product 9.</li> </ul> <p>The calculation I'm looking for is this:</p> <ul> <li>2008-01-09 1</li> <li>2008-01-10 x</li> <li>2008-01-11 x</li> <li>2008-01-12 2</li> <li>2008-01-13 3</li> <li>2008-01-14 x</li> <li>2008-01-15 4</li> <li>2008-01-16 5</li> </ul> <p>I'm wondering if it's possible to have a query return 2008-01-16 without having to use a stored procedure, or calculate it in my application code.</p> <p><strong>Edit (why no stored procs / loops):</strong> The reason I can't use stored procedures is that they are not supported by the database. I can only add extra tables / data. The application is a third party reporting tool where I can only control the SQL query.</p> <p><strong>Edit (how i'm doing it now):</strong> My current method is that I have an extra column in the order table to hold the calculated date, then a scheduled task / cron job runs the calculation on all the orders every hour. This is less than ideal for several reasons.</p>
[ { "answer_id": 92722, "author": "Joel Martinez", "author_id": 5416, "author_profile": "https://Stackoverflow.com/users/5416", "pm_score": 1, "selected": false, "text": "<p>Just calculate it in application code ... much easier and you won't have to write a really ugly query in your sql</p...
2008/09/18
[ "https://Stackoverflow.com/questions/92699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2581/" ]
I have a table called OffDays, where weekends and holiday dates are kept. I have a table called LeadTime where amount of time (in days) for a product to be manufactured is stored. Finally I have a table called Order where a product and the order date is kept. Is it possible to query when a product will be finished manufacturing without using stored procedures or loops? For example: * OffDays has 2008-01-10, 2008-01-11, 2008-01-14. * LeadTime has 5 for product 9. * Order has 2008-01-09 for product 9. The calculation I'm looking for is this: * 2008-01-09 1 * 2008-01-10 x * 2008-01-11 x * 2008-01-12 2 * 2008-01-13 3 * 2008-01-14 x * 2008-01-15 4 * 2008-01-16 5 I'm wondering if it's possible to have a query return 2008-01-16 without having to use a stored procedure, or calculate it in my application code. **Edit (why no stored procs / loops):** The reason I can't use stored procedures is that they are not supported by the database. I can only add extra tables / data. The application is a third party reporting tool where I can only control the SQL query. **Edit (how i'm doing it now):** My current method is that I have an extra column in the order table to hold the calculated date, then a scheduled task / cron job runs the calculation on all the orders every hour. This is less than ideal for several reasons.
You can generate a table of working days in advance. ``` WDId | WDDate -----+----------- 4200 | 2008-01-08 4201 | 2008-01-09 4202 | 2008-01-12 4203 | 2008-01-13 4204 | 2008-01-16 4205 | 2008-01-17 ``` Then do a query such as ``` SELECT DeliveryDay.WDDate FROM WorkingDay OrderDay, WorkingDay DeliveryDay, LeadTime, Order where DeliveryDay.WDId = OrderDay.WDId + LeadTime.LTDays AND OrderDay.WDDate = '' AND LeadTime.ProductId = Order.ProductId AND Order.OrderId = 1234 ``` You would need a stored procedure with a loop to generate the WorkingDays table, but not for regular queries. It's also fewer round trips to the server than if you use application code to count the days.
92,720
<p>I have a web page that includes a bunch of images. Sometimes the image isn't available, so a broken image is displayed in the client's browser.</p> <p>How do I use jQuery to get the set of images, filter it to broken images then replace the src?</p> <hr/> <p>--I thought it would be easier to do this with jQuery, but it turned out much easier to just use a pure JavaScript solution, that is, the one provided by Prestaul.</p>
[ { "answer_id": 92819, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 11, "selected": true, "text": "<p>Handle the <code>onError</code> event for the image to reassign its source using JavaScript:</p>\n\n<pre><code>function i...
2008/09/18
[ "https://Stackoverflow.com/questions/92720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17702/" ]
I have a web page that includes a bunch of images. Sometimes the image isn't available, so a broken image is displayed in the client's browser. How do I use jQuery to get the set of images, filter it to broken images then replace the src? --- --I thought it would be easier to do this with jQuery, but it turned out much easier to just use a pure JavaScript solution, that is, the one provided by Prestaul.
Handle the `onError` event for the image to reassign its source using JavaScript: ``` function imgError(image) { image.onerror = ""; image.src = "/images/noimage.gif"; return true; } ``` ``` <img src="image.png" onerror="imgError(this);"/> ``` Or without a JavaScript function: ``` <img src="image.png" onError="this.onerror=null;this.src='/images/noimage.gif';" /> ``` The following compatibility table lists the browsers that support the error facility: <http://www.quirksmode.org/dom/events/error.html>
92,781
<p>I'm looking to have text display vertically, first letter at the bottom, last letter at the top, within a JLabel. Is this possible?</p>
[ { "answer_id": 92805, "author": "jodonnell", "author_id": 4223, "author_profile": "https://Stackoverflow.com/users/4223", "pm_score": 3, "selected": false, "text": "<p>You can do it by messing with the paint command, sort of like this:</p>\n\n<pre><code>public class JVertLabel extends JC...
2008/09/18
[ "https://Stackoverflow.com/questions/92781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16538/" ]
I'm looking to have text display vertically, first letter at the bottom, last letter at the top, within a JLabel. Is this possible?
I found this page: <http://www.java2s.com/Tutorial/Java/0240__Swing/VerticalLabelUI.htm> when I needed to do that. I don't know if you want the letters 'standing' on each other or all rotated on their side. ``` /* * The contents of this file are subject to the Sapient Public License * Version 1.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * http://carbon.sf.net/License.html. * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License. * * The Original Code is The Carbon Component Framework. * * The Initial Developer of the Original Code is Sapient Corporation * * Copyright (C) 2003 Sapient Corporation. All Rights Reserved. */ import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; import java.awt.Rectangle; import java.awt.geom.AffineTransform; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.plaf.basic.BasicLabelUI; /** * This is the template for Classes. * * * @since carbon 1.0 * @author Greg Hinkle, January 2002 * @version $Revision: 1.4 $($Author: dvoet $ / $Date: 2003/05/05 21:21:27 $) * @copyright 2002 Sapient */ public class VerticalLabelUI extends BasicLabelUI { static { labelUI = new VerticalLabelUI(false); } protected boolean clockwise; public VerticalLabelUI(boolean clockwise) { super(); this.clockwise = clockwise; } public Dimension getPreferredSize(JComponent c) { Dimension dim = super.getPreferredSize(c); return new Dimension( dim.height, dim.width ); } private static Rectangle paintIconR = new Rectangle(); private static Rectangle paintTextR = new Rectangle(); private static Rectangle paintViewR = new Rectangle(); private static Insets paintViewInsets = new Insets(0, 0, 0, 0); public void paint(Graphics g, JComponent c) { JLabel label = (JLabel)c; String text = label.getText(); Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon(); if ((icon == null) && (text == null)) { return; } FontMetrics fm = g.getFontMetrics(); paintViewInsets = c.getInsets(paintViewInsets); paintViewR.x = paintViewInsets.left; paintViewR.y = paintViewInsets.top; // Use inverted height & width paintViewR.height = c.getWidth() - (paintViewInsets.left + paintViewInsets.right); paintViewR.width = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom); paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0; paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0; String clippedText = layoutCL(label, fm, text, icon, paintViewR, paintIconR, paintTextR); Graphics2D g2 = (Graphics2D) g; AffineTransform tr = g2.getTransform(); if (clockwise) { g2.rotate( Math.PI / 2 ); g2.translate( 0, - c.getWidth() ); } else { g2.rotate( - Math.PI / 2 ); g2.translate( - c.getHeight(), 0 ); } if (icon != null) { icon.paintIcon(c, g, paintIconR.x, paintIconR.y); } if (text != null) { int textX = paintTextR.x; int textY = paintTextR.y + fm.getAscent(); if (label.isEnabled()) { paintEnabledText(label, g, clippedText, textX, textY); } else { paintDisabledText(label, g, clippedText, textX, textY); } } g2.setTransform( tr ); } } ```
92,792
<p>I have a user control which is loaded in the page dynamically using the following code in Init of the Page.</p> <pre><code>Dim oCtl As Object oCtl = LoadControl("~/Controls/UserControl1.ascx") oCtl.Id = "UserControl11" PlaceHolder1.Controls.Clear() PlaceHolder1.Controls.Add(oCtl) </code></pre> <p>The user control also contains a button and I am unable to capture the button click within the user control. </p>
[ { "answer_id": 92810, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 1, "selected": false, "text": "<p>A few questions:</p>\n\n<ol>\n<li>At what point in the page lifecycle do you load the control?</li>\n<li>Where is th...
2008/09/18
[ "https://Stackoverflow.com/questions/92792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a user control which is loaded in the page dynamically using the following code in Init of the Page. ``` Dim oCtl As Object oCtl = LoadControl("~/Controls/UserControl1.ascx") oCtl.Id = "UserControl11" PlaceHolder1.Controls.Clear() PlaceHolder1.Controls.Add(oCtl) ``` The user control also contains a button and I am unable to capture the button click within the user control.
You have to ensure that the control exists on the page prior to .NET entering the "Postback event handling" step of the page lifecycle. Since the control is added dynamically you have to ensure that on every post back you recreate that control so that it can find the control to fire the event.
92,802
<p>I have a Bash shell script in which I would like to pause execution until the user presses a key. In DOS, this is easily accomplished with the <code>pause</code> command. Is there a Linux equivalent I can use in my script?</p>
[ { "answer_id": 92813, "author": "Jim", "author_id": 8427, "author_profile": "https://Stackoverflow.com/users/8427", "pm_score": 10, "selected": true, "text": "<p><code>read</code> does this:</p>\n\n<pre><code>user@host:~$ read -n1 -r -p \"Press any key to continue...\" key\n[...]\nuser@h...
2008/09/18
[ "https://Stackoverflow.com/questions/92802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4362/" ]
I have a Bash shell script in which I would like to pause execution until the user presses a key. In DOS, this is easily accomplished with the `pause` command. Is there a Linux equivalent I can use in my script?
`read` does this: ``` user@host:~$ read -n1 -r -p "Press any key to continue..." key [...] user@host:~$ ``` The `-n1` specifies that it only waits for a single character. The `-r` puts it into raw mode, which is necessary because otherwise, if you press something like backslash, it doesn't register until you hit the next key. The `-p` specifies the prompt, which must be quoted if it contains spaces. The `key` argument is only necessary if you want to know which key they pressed, in which case you can access it through `$key`. If you are using Bash, you can also specify a timeout with `-t`, which causes read to return a failure when a key isn't pressed. So for example: ``` read -t5 -n1 -r -p 'Press any key in the next five seconds...' key if [ "$?" -eq "0" ]; then echo 'A key was pressed.' else echo 'No key was pressed.' fi ```
92,820
<pre><code>class A : IFoo { } ... A[] arrayOfA = new A[10]; if(arrayOfA is IFoo[]) { // this is not called } </code></pre> <p>Q1: Why is <code>arrayOfA</code> not an array of <code>IFoos</code>?</p> <p>Q2: Why can't I cast <code>arrayOfA</code> to <code>IFoo[]</code>?</p>
[ { "answer_id": 92856, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": -1, "selected": false, "text": "<p>You could try</p>\n\n<pre><code>if (arrayofA[0] is IFoo) {.....}\n</code></pre>\n\n<p>which sort of answers your q...
2008/09/18
[ "https://Stackoverflow.com/questions/92820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7529/" ]
``` class A : IFoo { } ... A[] arrayOfA = new A[10]; if(arrayOfA is IFoo[]) { // this is not called } ``` Q1: Why is `arrayOfA` not an array of `IFoos`? Q2: Why can't I cast `arrayOfA` to `IFoo[]`?
`arrayOfA` **is** `IFoo[]`. There must be something else wrong with your program. You seem to have mocked up some code to show the problem, but in fact your code (see below) works as you expect. Try updating this question with the real code - or as close to real as you can - and we can take another look. ``` using System; public class oink { public static void Main() { A[] aOa = new A[10]; if (aOa is IFoo[]) { Console.WriteLine("aOa is IFoo[]"); } } public interface IFoo {} public class A : IFoo {} } PS D:\> csc test.cs Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.1 for Microsoft (R) .NET Framework version 3.5 Copyright (C) Microsoft Corporation. All rights reserved. PS D:\> D:\test.exe aOa is IFoo[] PS D:\> ```
92,841
<p>I am using CodeDom to generate dynamic code based on user values. One of those values controls what the name of the class I'm generating is. I know I could sterilize the name based on language rules about valid class names using regular expressions, but I'd like to know if there is a specific method built into the framework to validate and/or sterilize a class name.</p>
[ { "answer_id": 92958, "author": "Zach", "author_id": 8720, "author_profile": "https://Stackoverflow.com/users/8720", "pm_score": 2, "selected": false, "text": "<p>I found an answer to my question. I can call</p>\n\n<pre><code>CodeCompiler.ValidateIdentifiers(class1);\n</code></pre>\n\n<p...
2008/09/18
[ "https://Stackoverflow.com/questions/92841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8720/" ]
I am using CodeDom to generate dynamic code based on user values. One of those values controls what the name of the class I'm generating is. I know I could sterilize the name based on language rules about valid class names using regular expressions, but I'd like to know if there is a specific method built into the framework to validate and/or sterilize a class name.
An easy way to determine if a string is a valid identifier for a class or variable is to call the static method ``` System.CodeDom.Compiler.CodeGenerator.IsValidLanguageIndependentIdentifier(string value) ```
92,847
<p>How do I make an array shorter in Perl? I read some webpages indicating that I can assign:</p> <pre><code>$#ARRAY = 42; </code></pre> <p>I read that the use of $# is deprecated. I need a solution that will work for an array of arrays, too. This didn't work:</p> <pre><code>$#$ARRAY[$i] = 42; </code></pre>
[ { "answer_id": 92865, "author": "moonshadow", "author_id": 11834, "author_profile": "https://Stackoverflow.com/users/11834", "pm_score": 0, "selected": false, "text": "<p>$#{$ARRAY[$i]} = 42;</p>\n" }, { "answer_id": 92883, "author": "Leon Timmermans", "author_id": 4727, ...
2008/09/18
[ "https://Stackoverflow.com/questions/92847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4454/" ]
How do I make an array shorter in Perl? I read some webpages indicating that I can assign: ``` $#ARRAY = 42; ``` I read that the use of $# is deprecated. I need a solution that will work for an array of arrays, too. This didn't work: ``` $#$ARRAY[$i] = 42; ```
I'm not aware of assigning `$#ARRAY` being deprecated; `perldoc perldata` from 5.10.0 certainly says nothing about it. It is the fastest way to truncate an array. If you want something a little more readable, use `splice`: ``` splice @ARRAY, 43; ``` (Note `43` instead of `42` - `$#ARRAY` gets you the last index of the array, whereas `splice` taks the *length* of the array instead). As for working on arrays of arrays, I assume you mean being able to truncate a nested array via a reference? In that case, you want: ``` $#{$ARRAY->[7]} = 42; ``` or ``` splice @{$ARRAY->[7]}, 43; ```
92,860
<p>What is best practises for communicating events from a usercontrol to parent control/page i want to do something similar to this:</p> <pre><code>MyPage.aspx: &lt;asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceholder" runat="server"&gt; &lt;uc1:MyUserControl ID="MyUserControl1" runat="server" OnSomeEvent="MyUserControl_OnSomeEvent" /&gt; MyUserControl.ascx.cs: public partial class MyUserControl: UserControl { public event EventHandler SomeEvent; .... private void OnSomething() { if (SomeEvent!= null) SomeEvent(this, EventArgs.Empty); } </code></pre> <p>Question is what is best practise?</p>
[ { "answer_id": 92930, "author": "Matias Nino", "author_id": 17235, "author_profile": "https://Stackoverflow.com/users/17235", "pm_score": 2, "selected": false, "text": "<p>1) Declare a Public event in the user control</p>\n\n<p>2) Issue a RaiseEvent where appropriate inside the user cont...
2008/09/18
[ "https://Stackoverflow.com/questions/92860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15555/" ]
What is best practises for communicating events from a usercontrol to parent control/page i want to do something similar to this: ``` MyPage.aspx: <asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceholder" runat="server"> <uc1:MyUserControl ID="MyUserControl1" runat="server" OnSomeEvent="MyUserControl_OnSomeEvent" /> MyUserControl.ascx.cs: public partial class MyUserControl: UserControl { public event EventHandler SomeEvent; .... private void OnSomething() { if (SomeEvent!= null) SomeEvent(this, EventArgs.Empty); } ``` Question is what is best practise?
You would want to create an event on the control that is subscribed to in the parent. See [OdeToCode](http://www.odetocode.com/code/94.aspx) for an example. Here is the article for longevity sake: Some user controls are entirely self contained, for example, a user control displaying current stock quotes does not need to interact with any other content on the page. Other user controls will contain buttons to post back. Although it is possible to subscribe to the button click event from the containing page, doing so would break some of the object oriented rules of encapsulation. A better idea is to publish an event in the user control to allow any interested parties to handle the event. This technique is commonly referred to as “event bubbling” since the event can continue to pass through layers, starting at the bottom (the user control) and perhaps reaching the top level (the page) like a bubble moving up a champagne glass. For starters, let’s create a user control with a button attached. ``` <%@ Control Language="c#" AutoEventWireup="false" Codebehind="WebUserControl1.ascx.cs" Inherits="aspnet.eventbubble.WebUserControl1" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> <asp:Panel id="Panel1" runat="server" Width="128px" Height="96px"> WebUserControl1 <asp:Button id="Button1" Text="Button" runat="server"/> </asp:Panel> ``` The code behind for the user control looks like the following. ``` public class WebUserControl1 : System.Web.UI.UserControl { protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI.WebControls.Panel Panel1; private void Page_Load(object sender, System.EventArgs e) { Response.Write("WebUserControl1 :: Page_Load <BR>"); } private void Button1_Click(object sender, System.EventArgs e) { Response.Write("WebUserControl1 :: Begin Button1_Click <BR>"); OnBubbleClick(e); Response.Write("WebUserControl1 :: End Button1_Click <BR>"); } public event EventHandler BubbleClick; protected void OnBubbleClick(EventArgs e) { if(BubbleClick != null) { BubbleClick(this, e); } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); } private void InitializeComponent() { this.Button1.Click += new System.EventHandler(this.Button1_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion } ``` The user control specifies a public event (BubbleClick) which declares a delegate. Anyone interested in the BubbleClick event can add an EventHandler method to execute when the event fires – just like the user control adds an EventHandler for when the Button fires the Click event. In the OnBubbleClick event, we first check to see if anyone has attached to the event (BubbleClick != null), we can then invoke all the event handling methods by calling BubbleClick, passing through the EventArgs parameter and setting the user control (this) as the event sender. Notice we are also using Response.Write to follow the flow of execution. An ASPX page can now put the user control to work. ``` <%@ Register TagPrefix="ksa" TagName="BubbleControl" Src="WebUserControl1.ascx" %> <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="aspnet.eventbubble.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1</title> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <ksa:BubbleControl id="BubbleControl" runat="server" /> </form> </body> </HTML> ``` In the code behind for the page. ``` public class WebForm1 : System.Web.UI.Page { protected WebUserControl1 BubbleControl; private void Page_Load(object sender, System.EventArgs e) { Response.Write("WebForm1 :: Page_Load <BR>"); } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); } private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); BubbleControl.BubbleClick += new EventHandler(WebForm1_BubbleClick); } #endregion private void WebForm1_BubbleClick(object sender, EventArgs e) { Response.Write("WebForm1 :: WebForm1_BubbleClick from " + sender.GetType().ToString() + "<BR>"); } } ``` Notice the parent page simply needs to add an event handler during InitializeComponent method. When we receive the event we will again use Reponse.Write to follow the flow of execution. One word of warning: if at anytime events mysteriously stop work, check the InitializeComponent method to make sure the designer has not removed any of the code adding event handlers.
92,862
<p>In Ruby, like in many other OO programming languages, operators are overloadable. However, only certain character operators can be overloaded.</p> <p>This list may be incomplete but, here are some of the operators that cannot be overloaded: </p> <pre><code>!, not, &amp;&amp;, and, ||, or </code></pre>
[ { "answer_id": 92905, "author": "Farrel", "author_id": 7889, "author_profile": "https://Stackoverflow.com/users/7889", "pm_score": 5, "selected": true, "text": "<p>Methods are overloadable, those are part of the language syntax.</p>\n" }, { "answer_id": 92922, "author": "Joe ...
2008/09/18
[ "https://Stackoverflow.com/questions/92862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1167846/" ]
In Ruby, like in many other OO programming languages, operators are overloadable. However, only certain character operators can be overloaded. This list may be incomplete but, here are some of the operators that cannot be overloaded: ``` !, not, &&, and, ||, or ```
Methods are overloadable, those are part of the language syntax.
92,928
<p>In Python for *nix, does <code>time.sleep()</code> block the thread or the process?</p>
[ { "answer_id": 92953, "author": "finnw", "author_id": 12048, "author_profile": "https://Stackoverflow.com/users/12048", "pm_score": 5, "selected": false, "text": "<p>Just the thread.</p>\n" }, { "answer_id": 92986, "author": "Zach Burlingame", "author_id": 2233, "auth...
2008/09/18
[ "https://Stackoverflow.com/questions/92928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17732/" ]
In Python for \*nix, does `time.sleep()` block the thread or the process?
It blocks the thread. If you look in Modules/timemodule.c in the Python source, you'll see that in the call to `floatsleep()`, the substantive part of the sleep operation is wrapped in a Py\_BEGIN\_ALLOW\_THREADS and Py\_END\_ALLOW\_THREADS block, allowing other threads to continue to execute while the current one sleeps. You can also test this with a simple python program: ``` import time from threading import Thread class worker(Thread): def run(self): for x in xrange(0,11): print x time.sleep(1) class waiter(Thread): def run(self): for x in xrange(100,103): print x time.sleep(5) def run(): worker().start() waiter().start() ``` Which will print: ``` >>> thread_test.run() 0 100 >>> 1 2 3 4 5 101 6 7 8 9 10 102 ```
92,936
<p>I want to use small flex charts with just 3 labels, for example a chart over the past 2 hours , with 3 horizontal label, as shown below:</p> <pre><code> | | | 9:46 10:46 11:46 </code></pre> <p>(of course, there are more than 3 values to display!)</p> <p>I have been told this is not trivial, but how would you do it? </p> <p>Also, do you know of any books that present how to achieve sophisticated layouts in Flex? The books I have found are code-oriented and usually limit formatting to a minimum, and it's not always straightforward to connect the names of attributes to what you are trying to do.</p>
[ { "answer_id": 104491, "author": "defmeta", "author_id": 10875, "author_profile": "https://Stackoverflow.com/users/10875", "pm_score": 2, "selected": false, "text": "<p>Take a look in the online <a href=\"http://livedocs.adobe.com/flex/3/langref/index.html\" rel=\"nofollow noreferrer\">F...
2008/09/18
[ "https://Stackoverflow.com/questions/92936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to use small flex charts with just 3 labels, for example a chart over the past 2 hours , with 3 horizontal label, as shown below: ``` | | | 9:46 10:46 11:46 ``` (of course, there are more than 3 values to display!) I have been told this is not trivial, but how would you do it? Also, do you know of any books that present how to achieve sophisticated layouts in Flex? The books I have found are code-oriented and usually limit formatting to a minimum, and it's not always straightforward to connect the names of attributes to what you are trying to do.
Take a look in the online [Flex Language Guide](http://livedocs.adobe.com/flex/3/langref/index.html) at the [AxisRenderer](http://livedocs.adobe.com/flex/3/langref/mx/charts/AxisRenderer.html) class. It also has some helpful sample code and output.
92,971
<p>I'm trying to detect the size of the screen I'm starting emacs on, and adjust the size and position the window it is starting in (I guess that's the frame in emacs-speak) accordingly. I'm trying to set up my .emacs so that I always get a "reasonably-big" window with it's top-left corner near the top-left of my screen.</p> <p>I guess this is a <em>big</em> ask for the general case, so to narrow things down a bit I'm most interested in GNU Emacs 22 on Windows and (Debian) Linux.</p>
[ { "answer_id": 93005, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<pre><code>(setq initial-frame-alist\n (append '((width . 263) (height . 112) (top . -5) (left . 5) (font . \"4.System V...
2008/09/18
[ "https://Stackoverflow.com/questions/92971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6402/" ]
I'm trying to detect the size of the screen I'm starting emacs on, and adjust the size and position the window it is starting in (I guess that's the frame in emacs-speak) accordingly. I'm trying to set up my .emacs so that I always get a "reasonably-big" window with it's top-left corner near the top-left of my screen. I guess this is a *big* ask for the general case, so to narrow things down a bit I'm most interested in GNU Emacs 22 on Windows and (Debian) Linux.
If you want to change the size according to resolution you can do something like this (adjusting the preferred width and resolutions according to your specific needs): ``` (defun set-frame-size-according-to-resolution () (interactive) (if window-system (progn ;; use 120 char wide window for largeish displays ;; and smaller 80 column windows for smaller displays ;; pick whatever numbers make sense for you (if (> (x-display-pixel-width) 1280) (add-to-list 'default-frame-alist (cons 'width 120)) (add-to-list 'default-frame-alist (cons 'width 80))) ;; for the height, subtract a couple hundred pixels ;; from the screen height (for panels, menubars and ;; whatnot), then divide by the height of a char to ;; get the height we want (add-to-list 'default-frame-alist (cons 'height (/ (- (x-display-pixel-height) 200) (frame-char-height))))))) (set-frame-size-according-to-resolution) ``` Note that window-system is deprecated in newer versions of emacs. A suitable replacement is `(display-graphic-p)`. See [this answer](https://stackoverflow.com/a/5795518/7432) to the question [How to detect that emacs is in terminal-mode?](https://stackoverflow.com/questions/5795451/how-to-detect-that-emacs-is-in-terminal-mode) for a little more background.
92,984
<p>A friend of mine and I were having a discussion regarding currying and partial function application in Javascript, and we came to very different conclusions as to whether either were achievable. I came up with this implementation of <code>Function.prototype.curry</code>, which was the basis of our discussion:</p> <pre><code>Function.prototype.curry = function() { if (!arguments.length) return this; var args = Array.prototype.slice.apply(arguments); var mmm_curry = this, args; return function() { var inner_args = Array.prototype.slice.apply(arguments); return mmm_curry.apply(this, args.concat(inner_args)); } } </code></pre> <p>Which is used as follows:</p> <pre><code>var vindaloo = function(a, b) { return (a + b); } var karahi = vindaloo.curry(1); var masala = karahi(2); var gulai = karahi(3); print(masala); print(other); </code></pre> <p>The output of which is as follows in Spidermonkey:</p> <pre><code>$ js curry.js 3 4 </code></pre> <p>His opinion was that since the Javascript <code>function</code> primitive does not natively support "partial function application", it's completely wrong to refer to the function bound to the variable <code>karahi</code> as partially applied. His argument was that when the <code>vindaloo</code> function is curried, the function itself is completely applied and a closure is returned, not a "partially applied function".</p> <p>Now, my opinion is that while Javascript itself does not provide support for partial application in its' <code>function</code> primitives (unlike say, ML or Haskell), that doesn't mean you can't create a higher order function of the language which is capable of encapsulating concept of a partially applied function. Also, despite being "applied", the scope of the function is still bound to the closure returned by it causing it to remain "partially applied".</p> <p>Which is correct?</p>
[ { "answer_id": 93191, "author": "Zach", "author_id": 9128, "author_profile": "https://Stackoverflow.com/users/9128", "pm_score": 0, "selected": false, "text": "<p>You should check out <a href=\"http://www.svendtofte.com/code/curried_javascript/\" rel=\"nofollow noreferrer\">Curried JavaS...
2008/09/18
[ "https://Stackoverflow.com/questions/92984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11109/" ]
A friend of mine and I were having a discussion regarding currying and partial function application in Javascript, and we came to very different conclusions as to whether either were achievable. I came up with this implementation of `Function.prototype.curry`, which was the basis of our discussion: ``` Function.prototype.curry = function() { if (!arguments.length) return this; var args = Array.prototype.slice.apply(arguments); var mmm_curry = this, args; return function() { var inner_args = Array.prototype.slice.apply(arguments); return mmm_curry.apply(this, args.concat(inner_args)); } } ``` Which is used as follows: ``` var vindaloo = function(a, b) { return (a + b); } var karahi = vindaloo.curry(1); var masala = karahi(2); var gulai = karahi(3); print(masala); print(other); ``` The output of which is as follows in Spidermonkey: ``` $ js curry.js 3 4 ``` His opinion was that since the Javascript `function` primitive does not natively support "partial function application", it's completely wrong to refer to the function bound to the variable `karahi` as partially applied. His argument was that when the `vindaloo` function is curried, the function itself is completely applied and a closure is returned, not a "partially applied function". Now, my opinion is that while Javascript itself does not provide support for partial application in its' `function` primitives (unlike say, ML or Haskell), that doesn't mean you can't create a higher order function of the language which is capable of encapsulating concept of a partially applied function. Also, despite being "applied", the scope of the function is still bound to the closure returned by it causing it to remain "partially applied". Which is correct?
Technically you're creating a brand new function that calls the original function. So if my understanding of partially applied functions is correct, this is not a partially applied function. A partially applied function would be closer to this (note that this isn't a general solution): ``` vindaloo.curry = function(a) { return function(b) { return a + b; }; }; ``` IIUC, this still wouldn't be a partially applied function. But it's closer. A true partially applied function would actually look like this if you can examine the code: ``` function karahi(b) { return 1 + b; }; ``` So, technically, your original method *is* just returning a function bound within a closure. The only way I can think of to truly partially apply a function in JavaScript would be to parse the function, apply the changes, and then run it through an eval(). However, your solution is a good practical application of the concept to JavaScript, so practically speaking accomplishes the goal, even if it is not technically exact.
93,039
<p>In what segment (.BSS, .DATA, other) of an executable file are static variables stored so that they don't have name collision? For example:</p> <pre><code> foo.c: bar.c: static int foo = 1; static int foo = 10; void fooTest() { void barTest() { static int bar = 2; static int bar = 20; foo++; foo++; bar++; bar++; printf("%d,%d", foo, bar); printf("%d, %d", foo, bar); } } </code></pre> <p>If I compile both files and link it to a main that calls fooTest() and barTest repeatedly, the printf statements increment independently. Makes sense since the foo and bar variables are local to the translation unit.</p> <p>But where is the storage allocated?</p> <p>To be clear, the assumption is that you have a toolchain that would output a file in ELF format. Thus, I <em>believe</em> that there <strong>has</strong> to be some space reserved in the executable file for those static variables.<br> For discussion purposes, lets assume we use the GCC toolchain.</p>
[ { "answer_id": 93079, "author": "Seb Rose", "author_id": 12405, "author_profile": "https://Stackoverflow.com/users/12405", "pm_score": 5, "selected": false, "text": "<p>The storage location of the data will be implementation dependent.</p>\n\n<p>However, the meaning of <strong>static</st...
2008/09/18
[ "https://Stackoverflow.com/questions/93039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
In what segment (.BSS, .DATA, other) of an executable file are static variables stored so that they don't have name collision? For example: ``` foo.c: bar.c: static int foo = 1; static int foo = 10; void fooTest() { void barTest() { static int bar = 2; static int bar = 20; foo++; foo++; bar++; bar++; printf("%d,%d", foo, bar); printf("%d, %d", foo, bar); } } ``` If I compile both files and link it to a main that calls fooTest() and barTest repeatedly, the printf statements increment independently. Makes sense since the foo and bar variables are local to the translation unit. But where is the storage allocated? To be clear, the assumption is that you have a toolchain that would output a file in ELF format. Thus, I *believe* that there **has** to be some space reserved in the executable file for those static variables. For discussion purposes, lets assume we use the GCC toolchain.
Where your statics go depends on whether they are *zero-initialized*. *zero-initialized* static data goes in [.BSS (Block Started by Symbol)](http://en.wikipedia.org/wiki/.bss), *non-zero-initialized* data goes in [.DATA](http://en.wikipedia.org/wiki/Data_segment)
93,056
<p>this should be simple...could someone provide me a simple code sample that has an aspx page hosting both a silverlight app (consisting of, say a button) and an iframe (pointing to, say stackoverflow.com). The silverlight app and iframe could be in separate div's, the same div, whatever. </p> <p>Everything I've tried so far leaves me with a page that has no silverlight control rendered on it.</p> <p>EDIT: At the request for what my xaml looks like (Plus I should point out that my controls render just fine if I comment out the iframe.)</p> <pre><code>&lt;UserControl x:Class="SilverlightApplication1.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;Grid x:Name="LayoutRoot" Background="Pink"&gt; &lt;Button Content="Click Me!"/&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre> <p>Thats it. Just for good measure here is my aspx page...</p> <pre><code>&lt;form id="form1" runat="server"&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server"/&gt; &lt;div style="height:100%;"&gt; &lt;asp:Silverlight ID="Silverlight1" runat="server" Source="~/ClientBin/SilverlightApplication1.xap" MinimumVersion="2.0.30523" Width="400" Height="400" /&gt; &lt;/div&gt; &lt;iframe src ="http://www.google.com" width="400"/&gt; &lt;/form&gt; </code></pre>
[ { "answer_id": 93637, "author": "Ola Karlsson", "author_id": 10696, "author_profile": "https://Stackoverflow.com/users/10696", "pm_score": 2, "selected": false, "text": "<p>Hmm, sound a bit odd, a quick google gave me <a href=\"http://silverlight.net/forums/p/21584/75457.aspx\" rel=\"nof...
2008/09/18
[ "https://Stackoverflow.com/questions/93056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6419/" ]
this should be simple...could someone provide me a simple code sample that has an aspx page hosting both a silverlight app (consisting of, say a button) and an iframe (pointing to, say stackoverflow.com). The silverlight app and iframe could be in separate div's, the same div, whatever. Everything I've tried so far leaves me with a page that has no silverlight control rendered on it. EDIT: At the request for what my xaml looks like (Plus I should point out that my controls render just fine if I comment out the iframe.) ``` <UserControl x:Class="SilverlightApplication1.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Grid x:Name="LayoutRoot" Background="Pink"> <Button Content="Click Me!"/> </Grid> </UserControl> ``` Thats it. Just for good measure here is my aspx page... ``` <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"/> <div style="height:100%;"> <asp:Silverlight ID="Silverlight1" runat="server" Source="~/ClientBin/SilverlightApplication1.xap" MinimumVersion="2.0.30523" Width="400" Height="400" /> </div> <iframe src ="http://www.google.com" width="400"/> </form> ```
Hmm, sound a bit odd, a quick google gave me [this top result](http://silverlight.net/forums/p/21584/75457.aspx) which talks about using an Iframe and Silverlight on the same page, without problems. Also a quick test with the following code: ``` <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="asp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;"> <head runat="server"> <title>Test Page</title> </head> <body style="height:100%;margin:0;"> <form id="form1" runat="server" style="height:100%;"> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <div style="height:100%;"> <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/Test.xap" MinimumVersion="2.0.30523" Width="400" Height="400" /> </div> <iframe src ="http://www.google.com" width="400"></iframe> </form> </body> </html> ``` Renders out both Silverlight and the Iframe quite happily. What code were you using when trying and it didn't work?
93,100
<p>We all know that prepared statements are one of the best way of fending of SQL injection attacks. What is the best way of creating a prepared statement with an "IN" clause. Is there an easy way to do this with an unspecified number of values? Take the following query for example.</p> <pre><code>SELECT ID,Column1,Column2 FROM MyTable WHERE ID IN (1,2,3) </code></pre> <p>Currently I'm using a loop over my possible values to build up a string such as. </p> <pre><code>SELECT ID,Column1,Column2 FROM MyTable WHERE ID IN (@IDVAL_1,@IDVAL_2,@IDVAL_3) </code></pre> <p>Is it possible to use just pass an array as the value of the query paramter and use a query as follows?</p> <pre><code>SELECT ID,Column1,Column2 FROM MyTable WHERE ID IN (@IDArray) </code></pre> <p>In case it's important I'm working with SQL Server 2000, in VB.Net</p>
[ { "answer_id": 93184, "author": "DevelopingChris", "author_id": 1220, "author_profile": "https://Stackoverflow.com/users/1220", "pm_score": 1, "selected": false, "text": "<p>If you would like to pass an array, you will need a function in sql that can turn that array into a sub-select.</p...
2008/09/18
[ "https://Stackoverflow.com/questions/93100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1862/" ]
We all know that prepared statements are one of the best way of fending of SQL injection attacks. What is the best way of creating a prepared statement with an "IN" clause. Is there an easy way to do this with an unspecified number of values? Take the following query for example. ``` SELECT ID,Column1,Column2 FROM MyTable WHERE ID IN (1,2,3) ``` Currently I'm using a loop over my possible values to build up a string such as. ``` SELECT ID,Column1,Column2 FROM MyTable WHERE ID IN (@IDVAL_1,@IDVAL_2,@IDVAL_3) ``` Is it possible to use just pass an array as the value of the query paramter and use a query as follows? ``` SELECT ID,Column1,Column2 FROM MyTable WHERE ID IN (@IDArray) ``` In case it's important I'm working with SQL Server 2000, in VB.Net
Here you go - first create the following function... ``` Create Function [dbo].[SeparateValues] ( @data VARCHAR(MAX), @delimiter VARCHAR(10) ) RETURNS @tbldata TABLE(col VARCHAR(10)) As Begin DECLARE @pos INT DECLARE @prevpos INT SET @pos = 1 SET @prevpos = 0 WHILE @pos > 0 BEGIN SET @pos = CHARINDEX(@delimiter, @data, @prevpos+1) if @pos > 0 INSERT INTO @tbldata(col) VALUES(LTRIM(RTRIM(SUBSTRING(@data, @prevpos+1, @pos-@prevpos-1)))) else INSERT INTO @tbldata(col) VALUES(LTRIM(RTRIM(SUBSTRING(@data, @prevpos+1, len(@data)-@prevpos)))) SET @prevpos = @pos End RETURN END ``` then use the following... ``` Declare @CommaSeparated varchar(50) Set @CommaSeparated = '112,112,122' SELECT ID,Column1,Column2 FROM MyTable WHERE ID IN (select col FROM [SeparateValues](@CommaSeparated, ',')) ``` I think sql server 2008 will allow table functions. **UPDATE** You'll squeeze some extra performance using the following syntax... ``` SELECT ID,Column1,Column2 FROM MyTable Cross Apply [SeparateValues](@CommaSeparated, ',') s Where MyTable.id = s.col ``` Because the previous syntax causes SQL Server to run an extra "Sort" command using the "IN" clause. Plus - in my opinion it looks nicer :D!
93,105
<p>Need a function that takes a character as a parameter and returns true if it is a letter.</p>
[ { "answer_id": 93108, "author": "raven", "author_id": 4228, "author_profile": "https://Stackoverflow.com/users/4228", "pm_score": 3, "selected": false, "text": "<p>This was part of the code posted by <a href=\"https://stackoverflow.com/users/4007/rpetrich\">rpetrich</a> in response to a ...
2008/09/18
[ "https://Stackoverflow.com/questions/93105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228/" ]
Need a function that takes a character as a parameter and returns true if it is a letter.
Seanyboy's `IsCharAlphaA` [answer](https://stackoverflow.com/questions/93105/whats-the-best-way-to-determine-if-a-character-is-a-letter-in-vb6/93299#93299) is close. The best method is to use the W version like so: ``` Private Declare Function IsCharAlphaW Lib "user32" (ByVal cChar As Integer) As Long Public Property Get IsLetter(character As String) As Boolean IsLetter = IsCharAlphaW(AscW(character)) End Property ``` Of course, this all rarely matters as all of VB6's controls are ANSI only
93,128
<p>I'm importing a MySQL dump and getting the following error.</p> <pre><code>$ mysql foo &lt; foo.sql ERROR 1153 (08S01) at line 96: Got a packet bigger than 'max_allowed_packet' bytes </code></pre> <p>Apparently there are attachments in the database, which makes for very large inserts.</p> <hr> <p>This is on my local machine, a Mac with MySQL 5 installed from the MySQL package.</p> <p>Where do I change <code>max_allowed_packet</code> to be able to import the dump? </p> <p>Is there anything else I should set? </p> <p>Just running <code>mysql --max_allowed_packet=32M …</code> resulted in the same error.</p>
[ { "answer_id": 93165, "author": "GHad", "author_id": 11705, "author_profile": "https://Stackoverflow.com/users/11705", "pm_score": 6, "selected": false, "text": "<p>This can be changed in your <code>my.ini</code> file (on Windows, located in \\Program Files\\MySQL\\MySQL Server) under th...
2008/09/18
[ "https://Stackoverflow.com/questions/93128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13989/" ]
I'm importing a MySQL dump and getting the following error. ``` $ mysql foo < foo.sql ERROR 1153 (08S01) at line 96: Got a packet bigger than 'max_allowed_packet' bytes ``` Apparently there are attachments in the database, which makes for very large inserts. --- This is on my local machine, a Mac with MySQL 5 installed from the MySQL package. Where do I change `max_allowed_packet` to be able to import the dump? Is there anything else I should set? Just running `mysql --max_allowed_packet=32M …` resulted in the same error.
You probably have to change it for both the client (you are running to do the import) AND the daemon mysqld that is running and accepting the import. For the client, you can specify it on the command line: ``` mysql --max_allowed_packet=100M -u root -p database < dump.sql ``` Also, **change the my.cnf or my.ini file** (usually found in /etc/mysql/) under the mysqld section and set: ``` max_allowed_packet=100M ``` or you could run these **commands** in a MySQL console connected to that same server: ``` set global net_buffer_length=1000000; set global max_allowed_packet=1000000000; ``` (Use a very large value for the packet size.)
93,150
<p>The Query Optimizer is estimating that the results of a join will have only one row, when the actual number of rows is 2000. This is causing later joins on the dataset to have an estimated result of one row, when some of them go as high as 30,000.</p> <p>With a count of 1, the QO is choosing a loop join/index seek strategy for many of the joins which is much too slow. I worked around the issue by constraining the possible join strategies with a <code>WITH OPTION (HASH JOIN, MERGE JOIN)</code>, which improved overall execution time from 60+ minutes to 12 seconds. However, I think the QO is still generating a less than optimal plan because of the bad rowcounts. I don't want to specify the join order and details manually-- there are too many queries affected by this for it to be worthwhile.</p> <p>This is in Microsoft SQL Server 2000, a medium query with several table selects joined to the main select.</p> <p>I think the QO may be overestimating the cardinality of the many side on the join, expecting the joining columns between the tables to have less rows in common.</p> <p>The estimated row counts from scanning the indexes before the join are accurate, it's only the estimated row count after certain joins that's much too low.</p> <p>The statistics for all the tables in the DB are up to date and refreshed automatically.</p> <p>One of the early bad joins is between a generic 'Person' table for information common to all people and a specialized person table that about 5% of all those people belong to. The clustered PK in both tables (and the join column) is an INT. The database is highly normalized.</p> <p>I believe that the root problem is the bad row count estimate after certain joins, so my main questions are:</p> <ul> <li>How can I fix the QO's post join rowcount estimate?</li> <li>Is there a way that I can hint that a join will have a lot of rows without specifying the entire join order manually?</li> </ul>
[ { "answer_id": 93182, "author": "Danimal", "author_id": 2757, "author_profile": "https://Stackoverflow.com/users/2757", "pm_score": 0, "selected": false, "text": "<p>can't you prod the QO with a well-placed query hint?</p>\n" }, { "answer_id": 114811, "author": "Chris Smith",...
2008/09/18
[ "https://Stackoverflow.com/questions/93150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9073/" ]
The Query Optimizer is estimating that the results of a join will have only one row, when the actual number of rows is 2000. This is causing later joins on the dataset to have an estimated result of one row, when some of them go as high as 30,000. With a count of 1, the QO is choosing a loop join/index seek strategy for many of the joins which is much too slow. I worked around the issue by constraining the possible join strategies with a `WITH OPTION (HASH JOIN, MERGE JOIN)`, which improved overall execution time from 60+ minutes to 12 seconds. However, I think the QO is still generating a less than optimal plan because of the bad rowcounts. I don't want to specify the join order and details manually-- there are too many queries affected by this for it to be worthwhile. This is in Microsoft SQL Server 2000, a medium query with several table selects joined to the main select. I think the QO may be overestimating the cardinality of the many side on the join, expecting the joining columns between the tables to have less rows in common. The estimated row counts from scanning the indexes before the join are accurate, it's only the estimated row count after certain joins that's much too low. The statistics for all the tables in the DB are up to date and refreshed automatically. One of the early bad joins is between a generic 'Person' table for information common to all people and a specialized person table that about 5% of all those people belong to. The clustered PK in both tables (and the join column) is an INT. The database is highly normalized. I believe that the root problem is the bad row count estimate after certain joins, so my main questions are: * How can I fix the QO's post join rowcount estimate? * Is there a way that I can hint that a join will have a lot of rows without specifying the entire join order manually?
Although the statistics were up to date, the scan percentage wasn't high enough to provide accurate information. I ran this on each of the base tables that was having a problem to update all the statistics on a table by scanning all the rows, not just a default percentage. ``` UPDATE STATISTICS <table> WITH FULLSCAN, ALL ``` The query still has a lot of loop joins, but the join order is different and it runs in 2-3 seconds.
93,162
<p>Apparently you can easily obtain a client IP address in WCF 3.5 but not in WCF 3.0. Anyone know how?</p>
[ { "answer_id": 93437, "author": "Paul Mrozowski", "author_id": 3656, "author_profile": "https://Stackoverflow.com/users/3656", "pm_score": 7, "selected": false, "text": "<p>This doesn't help you in 3.0, but I can just see people finding this question and being frustrated because they are...
2008/09/18
[ "https://Stackoverflow.com/questions/93162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3856/" ]
Apparently you can easily obtain a client IP address in WCF 3.5 but not in WCF 3.0. Anyone know how?
It turns out you can, so long as (a) your service is being hosted in a Web Service (obviously) and (b) you enable AspNetCompatibility mode, as follows: ``` <system.serviceModel> <!-- this enables WCF services to access ASP.Net http context --> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> ... </system.serviceModel> ``` And then you can get the IP address by: ``` HttpContext.Current.Request.UserHostAddress ```
93,171
<p>I have a bowling web application that allows pretty detailed frame-by-frame information entry. One thing it allows is tracking which pins were knocked down on each ball. To display this information, I make it look like a rack of pins:</p> <pre>o o o o o o o o o o</pre> <p>Images are used to represent the pins. So, for the back row, I have four <em>img</em> tags, then a <em>br</em> tag. It works great... mostly. The problem is in small browsers, such as IEMobile. In this case, where there are may 10 or 11 columns in a table, and there may be a rack of pins in each column, Internet Explorer will try to shrink the column size to fit on the screen, and I end up with something like this:</p> <pre>o o o o o o o o o o</pre> <p>or</p> <pre>o o o o o o o o o o</pre> <p>The structure is:</p> <pre><code>&lt;tr&gt; &lt;td&gt; &lt;!-- some whitespace --&gt; &lt;div class=&quot;...&quot;&gt;&lt;img .../&gt;&lt;img .../&gt;&lt;img .../&gt;&lt;img .../&gt;&lt;br/&gt;...&lt;/div&gt; &lt;!-- some whitespace --&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>There is no whitespace inside the inner div. If you look at <a href="http://www.bowlsk.com/games/view-series.html?series=13717" rel="nofollow noreferrer">this page</a> in a regular browser, it should display fine. If you look at it in IEMobile, it does not.</p> <p>Any hints or suggestions? Maybe some sort of &amp;nbsp; that doesn't actually add a space?</p> <hr/> <h3>Follow-up/Summary</h3> <p>I have received and tried several good suggestions, including:</p> <ul> <li>Dynamically generate the whole image on the server. It is a good solution, but doesn't really fit my need (hosted on <a href="https://en.wikipedia.org/wiki/Google_App_Engine" rel="nofollow noreferrer">GAE</a>), and a bit more code than I'd like to write. These images could also be cached after the first generation.</li> <li>Use CSS white-space declaration. It is a good standards-based solution, but it fails miserably in the IEMobile view.</li> </ul> <h3>What I ended up doing</h3> <em>*hangs head and mumbles something*</em> <p>Yes, that's right, a transparent GIF at the top of the div, sized to the width I need. End code (simplified) looks like:</p> <pre><code>&lt;table class=&quot;game&quot;&gt; &lt;tr class=&quot;analysis leave&quot;&gt; &lt;!-- ... --&gt; &lt;td&gt; &lt;div class=&quot;smallpins&quot;&gt;&lt;img class=&quot;spacer&quot; src=&quot;http://seasrc.th.net/gif/cleardot.gif&quot; /&gt;&lt;br/&gt;&lt;img src=&quot;/img/pinsmall.gif&quot;/&gt;&lt;img src=&quot;/img/nopinsmall.gif&quot;/&gt;&lt;img src=&quot;/img/nopinsmall.gif&quot;/&gt;&lt;img src=&quot;/img/nopinsmall.gif&quot;/&gt;&lt;br/&gt;&lt;img src=&quot;/img/pinsmall.gif&quot;/&gt;&lt;img src=&quot;/img/pinsmall.gif&quot;/&gt;&lt;img src=&quot;/img/nopinsmall.gif&quot;/&gt;&lt;br/&gt;&lt;img src=&quot;/img/nopinsmall.gif&quot;/&gt;&lt;img src=&quot;/img/nopinsmall.gif&quot;/&gt;&lt;br/&gt;&lt;img src=&quot;/img/nopinsmall.gif&quot;/&gt;&lt;/div&gt; &lt;/td&gt; &lt;!-- ... --&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>And CSS:</p> <pre class="lang-css prettyprint-override"><code>div.smallpins { background: url(/img/lane.gif) repeat; text-align: center; padding: 0; white-space: nowrap; } div.smallpins img { width: 1em; height: 1em; } div.smallpins img.spacer { width: 4.5em; height: 0px; } table.game tr.leave td{ padding: 0; margin: 0; } table.game tr.leave .smallpins { min-width: 4em; white-space: nowrap; background: none; } </code></pre> <p>P.S.: No, I will not be hotlinking someone else's clear dot in my final solution :)</p>
[ { "answer_id": 93189, "author": "Paul Whelan", "author_id": 3050, "author_profile": "https://Stackoverflow.com/users/3050", "pm_score": 2, "selected": false, "text": "<p>Why not have an image for all possible outcomes for the pins? No Messing with layouts for browsers an image is an imag...
2008/09/18
[ "https://Stackoverflow.com/questions/93171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/96/" ]
I have a bowling web application that allows pretty detailed frame-by-frame information entry. One thing it allows is tracking which pins were knocked down on each ball. To display this information, I make it look like a rack of pins: ``` o o o o o o o o o o ``` Images are used to represent the pins. So, for the back row, I have four *img* tags, then a *br* tag. It works great... mostly. The problem is in small browsers, such as IEMobile. In this case, where there are may 10 or 11 columns in a table, and there may be a rack of pins in each column, Internet Explorer will try to shrink the column size to fit on the screen, and I end up with something like this: ``` o o o o o o o o o o ``` or ``` o o o o o o o o o o ``` The structure is: ``` <tr> <td> <!-- some whitespace --> <div class="..."><img .../><img .../><img .../><img .../><br/>...</div> <!-- some whitespace --> </td> </tr> ``` There is no whitespace inside the inner div. If you look at [this page](http://www.bowlsk.com/games/view-series.html?series=13717) in a regular browser, it should display fine. If you look at it in IEMobile, it does not. Any hints or suggestions? Maybe some sort of &nbsp; that doesn't actually add a space? --- ### Follow-up/Summary I have received and tried several good suggestions, including: * Dynamically generate the whole image on the server. It is a good solution, but doesn't really fit my need (hosted on [GAE](https://en.wikipedia.org/wiki/Google_App_Engine)), and a bit more code than I'd like to write. These images could also be cached after the first generation. * Use CSS white-space declaration. It is a good standards-based solution, but it fails miserably in the IEMobile view. ### What I ended up doing *\*hangs head and mumbles something\** Yes, that's right, a transparent GIF at the top of the div, sized to the width I need. End code (simplified) looks like: ``` <table class="game"> <tr class="analysis leave"> <!-- ... --> <td> <div class="smallpins"><img class="spacer" src="http://seasrc.th.net/gif/cleardot.gif" /><br/><img src="/img/pinsmall.gif"/><img src="/img/nopinsmall.gif"/><img src="/img/nopinsmall.gif"/><img src="/img/nopinsmall.gif"/><br/><img src="/img/pinsmall.gif"/><img src="/img/pinsmall.gif"/><img src="/img/nopinsmall.gif"/><br/><img src="/img/nopinsmall.gif"/><img src="/img/nopinsmall.gif"/><br/><img src="/img/nopinsmall.gif"/></div> </td> <!-- ... --> </tr> </table> ``` And CSS: ```css div.smallpins { background: url(/img/lane.gif) repeat; text-align: center; padding: 0; white-space: nowrap; } div.smallpins img { width: 1em; height: 1em; } div.smallpins img.spacer { width: 4.5em; height: 0px; } table.game tr.leave td{ padding: 0; margin: 0; } table.game tr.leave .smallpins { min-width: 4em; white-space: nowrap; background: none; } ``` P.S.: No, I will not be hotlinking someone else's clear dot in my final solution :)
You could try the css "nowrap" option in the containing div. ```css {white-space: nowrap;} ``` Not sure how widely that is supported.
93,208
<p>I'd like to automatically generate database scripts on a regular basis. Is this possible.</p>
[ { "answer_id": 93282, "author": "Orion Adrian", "author_id": 7756, "author_profile": "https://Stackoverflow.com/users/7756", "pm_score": 4, "selected": true, "text": "<p>To generate script for an object you have to pass up to six parameters:</p>\n\n<pre><code>exec proc_genscript \n @S...
2008/09/18
[ "https://Stackoverflow.com/questions/93208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'd like to automatically generate database scripts on a regular basis. Is this possible.
To generate script for an object you have to pass up to six parameters: ``` exec proc_genscript @ServerName = 'Server Name', @DBName = 'Database Name', @ObjectName = 'Object Name to generate script for', @ObjectType = 'Object Type', @TableName = 'Parent table name for index and trigger', @ScriptFile = 'File name to save the script' ``` <http://www.databasejournal.com/features/mssql/article.php/2205291>
93,214
<p>Given the code from the <a href="http://railscasts.com/episodes/75" rel="nofollow noreferrer">Complex Form part III</a> how would you go about testing the virtual attribute?</p> <pre><code> def new_task_attributes=(task_attributes) task_attributes.each do |attributes| tasks.build(attributes) end end </code></pre> <p>I am currently trying to test it like this:</p> <pre><code> def test_adding_task_to_project p = Project.new params = {&quot;new_tasks_attributes&quot; =&gt; [{ &quot;name&quot; =&gt; &quot;paint fence&quot;}]} p.new_tasks_attributes=(params) p.save assert p.tasks.length == 1 end </code></pre> <p>But I am getting the following error:</p> <blockquote> <p>NoMethodError: undefined method `stringify_keys!' for &quot;new_tasks_attributes&quot;:String</p> </blockquote> <p>Any suggestions on improving this test would be greatly appreciated.</p>
[ { "answer_id": 93393, "author": "Jason Wadsworth", "author_id": 11078, "author_profile": "https://Stackoverflow.com/users/11078", "pm_score": 3, "selected": true, "text": "<p>It looks as if new_task_attributes= is expecting an array of hashes, but you're passing it a hash. Try this:</p>\...
2008/09/18
[ "https://Stackoverflow.com/questions/93214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1681/" ]
Given the code from the [Complex Form part III](http://railscasts.com/episodes/75) how would you go about testing the virtual attribute? ``` def new_task_attributes=(task_attributes) task_attributes.each do |attributes| tasks.build(attributes) end end ``` I am currently trying to test it like this: ``` def test_adding_task_to_project p = Project.new params = {"new_tasks_attributes" => [{ "name" => "paint fence"}]} p.new_tasks_attributes=(params) p.save assert p.tasks.length == 1 end ``` But I am getting the following error: > > NoMethodError: undefined method `stringify\_keys!' for "new\_tasks\_attributes":String > > > Any suggestions on improving this test would be greatly appreciated.
It looks as if new\_task\_attributes= is expecting an array of hashes, but you're passing it a hash. Try this: ``` def test_adding_task_to_project p = Project.new new_tasks_attributes = [{ "name" => "paint fence"}] p.new_tasks_attributes = (new_tasks_attributes) p.save assert p.tasks.length == 1 end ```
93,222
<p>I recently received an email from my girlfriend that spamassassin marked as spam, mostly because spamassassin detected a tracker ID... except there wasn't one. I'd like to know what triggered it, so that I can report a sensible bug.</p>
[ { "answer_id": 93393, "author": "Jason Wadsworth", "author_id": 11078, "author_profile": "https://Stackoverflow.com/users/11078", "pm_score": 3, "selected": true, "text": "<p>It looks as if new_task_attributes= is expecting an array of hashes, but you're passing it a hash. Try this:</p>\...
2008/09/18
[ "https://Stackoverflow.com/questions/93222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
I recently received an email from my girlfriend that spamassassin marked as spam, mostly because spamassassin detected a tracker ID... except there wasn't one. I'd like to know what triggered it, so that I can report a sensible bug.
It looks as if new\_task\_attributes= is expecting an array of hashes, but you're passing it a hash. Try this: ``` def test_adding_task_to_project p = Project.new new_tasks_attributes = [{ "name" => "paint fence"}] p.new_tasks_attributes = (new_tasks_attributes) p.save assert p.tasks.length == 1 end ```
93,231
<p>I'm having a problem debugging an Eclipse Application from Eclipse. When I launch the Debug Configuration, the Eclipse Application starts up and then stops repeatedly. It shows the splash screen and then disappears. This is the farthest it gets before restarting:</p> <pre><code>MyDebugConfiguration [Eclipse Application] org.eclipse.equinox.launcher.Main at localhost:2599 Thread [main] (Running) Daemon Thread [Signal Dispatcher] (Running) Daemon Thread [State Data Manager] (Running) Daemon Thread [Framework Event Dispatcher] (Running) Thread [State Saver] (Running) Daemon Thread [Start Level Event Dispatcher] (Running) Thread [Refresh Packages] (Running) C:\MyApp\eclipse\jdk\jre\bin\javaw.exe (Sep 18, 2008 9:38:19 AM) </code></pre> <p>I am using Version 3.4.0 of the Eclipse SDK.</p> <p>What is causing this?</p>
[ { "answer_id": 93393, "author": "Jason Wadsworth", "author_id": 11078, "author_profile": "https://Stackoverflow.com/users/11078", "pm_score": 3, "selected": true, "text": "<p>It looks as if new_task_attributes= is expecting an array of hashes, but you're passing it a hash. Try this:</p>\...
2008/09/18
[ "https://Stackoverflow.com/questions/93231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7648/" ]
I'm having a problem debugging an Eclipse Application from Eclipse. When I launch the Debug Configuration, the Eclipse Application starts up and then stops repeatedly. It shows the splash screen and then disappears. This is the farthest it gets before restarting: ``` MyDebugConfiguration [Eclipse Application] org.eclipse.equinox.launcher.Main at localhost:2599 Thread [main] (Running) Daemon Thread [Signal Dispatcher] (Running) Daemon Thread [State Data Manager] (Running) Daemon Thread [Framework Event Dispatcher] (Running) Thread [State Saver] (Running) Daemon Thread [Start Level Event Dispatcher] (Running) Thread [Refresh Packages] (Running) C:\MyApp\eclipse\jdk\jre\bin\javaw.exe (Sep 18, 2008 9:38:19 AM) ``` I am using Version 3.4.0 of the Eclipse SDK. What is causing this?
It looks as if new\_task\_attributes= is expecting an array of hashes, but you're passing it a hash. Try this: ``` def test_adding_task_to_project p = Project.new new_tasks_attributes = [{ "name" => "paint fence"}] p.new_tasks_attributes = (new_tasks_attributes) p.save assert p.tasks.length == 1 end ```
93,264
<p>I have created a foreign key (in SQL Server) by:</p> <pre><code>alter table company add CountryID varchar(3); alter table company add constraint Company_CountryID_FK foreign key(CountryID) references Country; </code></pre> <p>I then run this query:</p> <pre><code>alter table company drop column CountryID; </code></pre> <p>and I get this error:</p> <blockquote> <p><em>Msg 5074, Level 16, State 4, Line 2<br> The object 'Company_CountryID_FK' is dependent on column 'CountryID'.<br> Msg 4922, Level 16, State 9, Line 2<br> ALTER TABLE DROP COLUMN CountryID failed because one or more objects access this column</em></p> </blockquote> <p>I have tried this, yet it does not seem to work:</p> <pre><code>alter table company drop foreign key Company_CountryID_FK; alter table company drop column CountryID; </code></pre> <p>What do I need to do to drop the <code>CountryID</code> column?</p> <p>Thanks.</p>
[ { "answer_id": 93292, "author": "Mike", "author_id": 1115144, "author_profile": "https://Stackoverflow.com/users/1115144", "pm_score": 9, "selected": true, "text": "<p>Try</p>\n\n<pre><code>alter table company drop constraint Company_CountryID_FK\n\n\nalter table company drop column Coun...
2008/09/18
[ "https://Stackoverflow.com/questions/93264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
I have created a foreign key (in SQL Server) by: ``` alter table company add CountryID varchar(3); alter table company add constraint Company_CountryID_FK foreign key(CountryID) references Country; ``` I then run this query: ``` alter table company drop column CountryID; ``` and I get this error: > > *Msg 5074, Level 16, State 4, Line 2 > > The object 'Company\_CountryID\_FK' is dependent on column 'CountryID'. > > Msg 4922, Level 16, State 9, Line 2 > > ALTER TABLE DROP COLUMN CountryID failed because one or more objects access this column* > > > I have tried this, yet it does not seem to work: ``` alter table company drop foreign key Company_CountryID_FK; alter table company drop column CountryID; ``` What do I need to do to drop the `CountryID` column? Thanks.
Try ``` alter table company drop constraint Company_CountryID_FK alter table company drop column CountryID ```
93,274
<p>What is the <em>definitive</em> way to mimic the CSS property min-width in Internet Explorer 6? Is it better not to try?</p>
[ { "answer_id": 93286, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 0, "selected": false, "text": "<p>do your css tag as _Width: 500px or whatever.</p>\n" }, { "answer_id": 93296, "author": "kch", "author_id"...
2008/09/18
[ "https://Stackoverflow.com/questions/93274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4241/" ]
What is the *definitive* way to mimic the CSS property min-width in Internet Explorer 6? Is it better not to try?
```css foo { min-width: 100px } // for everyone * html foo { width: 100px } // just for IE ``` (or serve a separate stylesheet to IE using [conditional comments](http://www.quirksmode.org/css/condcom.html))
93,277
<p>I have a rails form with a datetime_select field. When I try to submit the form, I get the following exception:</p> <pre><code>ActiveRecord::MultiparameterAssignmentErrors in WidgetsController#update 1 error(s) on assignment of multiparameter attributes </code></pre> <p>If it's a validation error, why don't I see an error on the page?</p> <p>This is in Rails 2.0.2</p>
[ { "answer_id": 93327, "author": "Jason Wadsworth", "author_id": 11078, "author_profile": "https://Stackoverflow.com/users/11078", "pm_score": 5, "selected": true, "text": "<p>It turns out that rails uses something called Multi-parameter assignment to transmit dates and times in small par...
2008/09/18
[ "https://Stackoverflow.com/questions/93277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11078/" ]
I have a rails form with a datetime\_select field. When I try to submit the form, I get the following exception: ``` ActiveRecord::MultiparameterAssignmentErrors in WidgetsController#update 1 error(s) on assignment of multiparameter attributes ``` If it's a validation error, why don't I see an error on the page? This is in Rails 2.0.2
It turns out that rails uses something called Multi-parameter assignment to transmit dates and times in small parts that are reassembled when you assign params to the model instance. My problem was that I was using a datetime\_select form field for a date model field. It apparently chokes when the multi-parameter magic tries to set the time on a Date object. The solution was to use a `date_select` form field rather than a `datetime_select`.
93,294
<p>So I have a nasty stack overflow I have been trying to track down / solve for the past 8 hours or so, and I'm at the point where i think i need advice. </p> <p>The details: Interestingly enough this code runs fine when called in the context of our regular winforms application -- but I am tasked with writing a web-based version of our software, and this same exact code causes the stack overflow when called out of an ASPX page running on IIS. The first thing I did was attach and attempt normal .NET debugging through visual studio. At the point of the exception the call stack seemed relatively shallow (about 11 frames deep, of our code), and I could find none of the usual suspects on a stack overflow (bad recursion, self-calling constructors, exception loops).</p> <p>So I resigned myself to breaking out windbg and S.O.S. -- which i know can be useful for this sort of thing, although I had limited experience with it myself. After hours of monkeying around I think I have some useful data, but I need some help analyzing it.</p> <p>First up is a !dumpstack I took while broken just before the stack overflow was about to come down.</p> <pre><code>0:015&gt; !dumpstack PDB symbol for mscorwks.dll not loaded OS Thread Id: 0x1110 (15) Current frame: ntdll!KiFastSystemCallRet ChildEBP RetAddr Caller,Callee 01d265a8 7c827d0b ntdll!NtWaitForSingleObject+0xc 01d265ac 77e61d1e kernel32!WaitForSingleObjectEx+0x88, calling ntdll!NtWaitForSingleObject 01d2661c 79e789c6 mscorwks!LogHelp_NoGuiOnAssert+0x58ca 01d26660 79e7898f mscorwks!LogHelp_NoGuiOnAssert+0x5893, calling mscorwks!LogHelp_NoGuiOnAssert+0x589b 01d26680 79e734c4 mscorwks!LogHelp_NoGuiOnAssert+0x3c8, calling mscorwks+0x17c0 01d26694 79fc1d6b mscorwks!CorExeMain+0x8724, calling kernel32!InterlockedDecrement 01d26698 79ef3892 mscorwks!GetCLRFunction+0x107de, calling mscorwks+0x17c0 01d266b0 79e78944 mscorwks!LogHelp_NoGuiOnAssert+0x5848, calling mscorwks!LogHelp_NoGuiOnAssert+0x584c 01d266c4 7a14de5d mscorwks!CorLaunchApplication+0x2f243, calling mscorwks!LogHelp_NoGuiOnAssert+0x5831 01d266ec 77e61d1e kernel32!WaitForSingleObjectEx+0x88, calling ntdll!NtWaitForSingleObject 01d266f8 77e61d43 kernel32!WaitForSingleObjectEx+0xad, calling kernel32!GetTickCount+0x73 01d26714 7c8279bb ntdll!NtSetEvent+0xc 01d26718 77e62321 kernel32!SetEvent+0x10, calling ntdll!NtSetEvent 01d26748 7a14df79 mscorwks!CorLaunchApplication+0x2f35f, calling mscorwks!CorLaunchApplication+0x2f17c 01d2675c 7a022dde mscorwks!NGenCreateNGenWorker+0x4516b, calling mscorwks!CorLaunchApplication+0x2f347 01d26770 79fbc685 mscorwks!CorExeMain+0x303e, calling mscorwks+0x1bbe 01d26788 79e734c4 mscorwks!LogHelp_NoGuiOnAssert+0x3c8, calling mscorwks+0x17c0 01d2678c 79e734f2 mscorwks!LogHelp_NoGuiOnAssert+0x3f6, calling mscorwks!LogHelp_NoGuiOnAssert+0x380 01d267a8 7a2d259e mscorwks!CreateHistoryReader+0xafd3 01d267b4 7a2e6292 mscorwks!CreateHistoryReader+0x1ecc7, calling mscorwks!CreateHistoryReader+0xaf9d 01d26814 7a064d52 mscorwks!NGenCreateNGenWorker+0x870df, calling mscorwks!CreateHistoryReader+0x1eb43 01d26854 79f91643 mscorwks!ClrCreateManagedInstance+0x46ff, calling mscorwks!ClrCreateManagedInstance+0x4720 01d2688c 79f915c4 mscorwks!ClrCreateManagedInstance+0x4680 01d268b4 79e734c4 mscorwks!LogHelp_NoGuiOnAssert+0x3c8, calling mscorwks+0x17c0 01d268cc 79f04e98 mscorwks!GetCLRFunction+0x21de4, calling mscorwks!GetCLRFunction+0x21e4b 01d26900 79f0815e mscorwks!GetCLRFunction+0x250aa, calling mscorwks!GetCLRFunction+0x21d35 01d2691c 7c858135 ntdll!RtlIpv4StringToAddressExW+0x167b7, calling ntdll!RtlReleaseResource 01d2692c 79f080a7 mscorwks!GetCLRFunction+0x24ff3, calling mscorwks!GetCLRFunction+0x25052 01d26950 7c828752 ntdll!RtlRaiseStatus+0xe0 01d26974 7c828723 ntdll!RtlRaiseStatus+0xb1, calling ntdll!RtlRaiseStatus+0xba 01d26998 7c8315c2 ntdll!RtlSubtreePredecessor+0x208, calling ntdll!RtlRaiseStatus+0x7e 01d26a1c 7c82855e ntdll!KiUserExceptionDispatcher+0xe, calling ntdll!RtlSubtreePredecessor+0x17c 01d26d20 13380333 (MethodDesc 0x10936710 +0x243 ASI.ParadigmPlus.LoadedWindows.WID904.QuestionChangeLogic(ASI.ParadigmPlus.Question, ASI.ParadigmPlus.Question)) ====&gt; Exception Code 0 cxr@1d26a54 exr@1d26000 01d26bd8 77e64590 kernel32!VirtualAllocEx+0x4b, calling kernel32!GetTickCount+0x73 01d26bec 7c829f59 ntdll!RtlFreeHeap+0x142, calling ntdll!CIpow+0x464 01d26bf0 79e78d11 mscorwks!LogHelp_NoGuiOnAssert+0x5c15, calling ntdll!RtlFreeHeap 01d3e86c 103b4064 (MethodDesc 0xf304c90 +0x174 ASI.ParadigmPlus.Window.TrackQuestionChange(ASI.ParadigmPlus.Question, ASI.ParadigmPlus.Answer)) 01d3e88c 103b4064 (MethodDesc 0xf304c90 +0x174 ASI.ParadigmPlus.Window.TrackQuestionChange(ASI.ParadigmPlus.Question, ASI.ParadigmPlus.Answer)) 01d3e8b0 103b3e6b (MethodDesc 0xebb4b38 +0x23 ASI.CommonLibrary.ASIArrayList3.get_Item(Int32)) 01d3e8d4 103b3d70 (MethodDesc 0xf304e98 +0x1b0 ASI.ParadigmPlus.Window.TrackQuestionChange()) 01d3e910 0f90febf (MethodDesc 0xf30d250 +0x190f ASI.ParadigmPlus.Data.RemoteDataAccess.GetWindow(Int32)) 01d3ec0c 10a2a572 (MethodDesc 0x10935aa0 +0x1f2 ASI.ParadigmPlus.LoadedWindowSets.WSID904.ApplyLayoutChanges()), calling 02259472 01d3ecec 0f90c880 (MethodDesc 0xebb91f8 +0xe8 ASI.ParadigmPlus.Windowset.ApplyLayoutChangesWrap()) 01d3ed0c 0f90c880 (MethodDesc 0xebb91f8 +0xe8 ASI.ParadigmPlus.Windowset.ApplyLayoutChangesWrap()) 01d3ed54 0f4d2388 (MethodDesc 0x22261a0 +0x5e8 WebConfigurator.NewDefault.ProductSelectedIndexChange(Int32, Int32)) 01d3f264 0f4d1d7f (MethodDesc 0x2226180 +0x47 WebConfigurator.NewDefault.btnGo_Click1(System.Object, System.EventArgs)), calling (MethodDesc 0x22261a0 +0 WebConfigurator.NewDefault.ProductSelectedIndexChange(Int32, Int32)) 01d3f284 0e810a05 (MethodDesc 0x22260f8 +0x145 WebConfigurator.NewDefault.Page_Load(System.Object, System.EventArgs)), calling (MethodDesc 0x2226180 +0 WebConfigurator.NewDefault.btnGo_Click1(System.Object, System.EventArgs)) 01d3f2a8 793ae896 (MethodDesc 0x79256848 +0x52 System.MulticastDelegate.RemoveImpl(System.Delegate)) 01d3f2ac 79e7bee8 mscorwks!LogHelp_TerminateOnAssert+0x2bd0, calling mscorwks!LogHelp_TerminateOnAssert+0x2b60 01d3f2c4 66f12980 (MethodDesc 0x66f1bcd0 +0x10 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr, System.Object, System.Object, System.EventArgs)) 01d3f2d0 6628efd2 (MethodDesc 0x66474328 +0x22 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(System.Object, System.EventArgs)), calling (MethodDesc 0x66f1bcd0 +0 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr, System.Object, System.Object, System.EventArgs)) 01d3f2e4 6613cb04 (MethodDesc 0x66468a58 +0x64 System.Web.UI.Control.OnLoad(System.EventArgs)) 01d3f2f8 6613cb50 (MethodDesc 0x66468a60 +0x30 System.Web.UI.Control.LoadRecursive()) 01d3f30c 6614e12d (MethodDesc 0x66467688 +0x59d System.Web.UI.Page.ProcessRequestMain(Boolean, Boolean)) 01d3f4e0 6614c717 (MethodDesc 0x66467430 +0x63 System.Web.UI.Page.AddWrappedFileDependencies(System.Object)), calling (MethodDesc 0x66478de8 +0 System.Web.ResponseDependencyList.AddDependencies(System.String[], System.String, Boolean, System.String)) 01d3f504 6614d8c3 (MethodDesc 0x66467650 +0x67 System.Web.UI.Page.ProcessRequest(Boolean, Boolean)), calling (MethodDesc 0x66467688 +0 System.Web.UI.Page.ProcessRequestMain(Boolean, Boolean)) 01d3f528 79371311 (MethodDesc 0x7925ac80 +0x25 System.Globalization.CultureInfo.get_UserDefaultUICulture()), calling (JitHelp: CORINFO_HELP_GETSHARED_GCSTATIC_BASE) 01d3f53c 6614d80f (MethodDesc 0x66467648 +0x57 System.Web.UI.Page.ProcessRequest()), calling (MethodDesc 0x66467650 +0 System.Web.UI.Page.ProcessRequest(Boolean, Boolean)) 01d3f560 6615055c (MethodDesc 0x664676f0 +0x184 System.Web.UI.Page.SetIntrinsics(System.Web.HttpContext, Boolean)), calling (MethodDesc 0x664726b0 +0 System.Web.UI.TemplateControl.HookUpAutomaticHandlers()) 01d3f578 6614d72f (MethodDesc 0x66467630 +0x13 System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext)), calling (MethodDesc 0x66467648 +0 System.Web.UI.Page.ProcessRequest()) 01d3f580 6614d6c2 (MethodDesc 0x66467620 +0x32 System.Web.UI.Page.ProcessRequest(System.Web.HttpContext)), calling (MethodDesc 0x66467630 +0 System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext)) 01d3f594 0e810206 (MethodDesc 0x22265a0 +0x1e ASP.newdefault_aspx.ProcessRequest(System.Web.HttpContext)), calling (MethodDesc 0x66467620 +0 System.Web.UI.Page.ProcessRequest(System.Web.HttpContext)) 01d3f5a0 65fe6bfb (MethodDesc 0x66470fc0 +0x167 System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()), calling 01dee5da 01d3f5d4 65fe3f51 (MethodDesc 0x6642f090 +0x41 System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)), calling 01de7d0a 01d3f610 65fe7733 (MethodDesc 0x66470cd0 +0x1b3 System.Web.HttpApplication+ApplicationStepManager.ResumeSteps(System.Exception)), calling (MethodDesc 0x6642f090 +0 System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)) 01d3f64c 7939eef2 (MethodDesc 0x7925eda8 +0x26 System.Runtime.InteropServices.GCHandle.Alloc(System.Object)), calling mscorwks!InstallCustomModule+0x1e8d 01d3f664 65fccbfe (MethodDesc 0x6642ebb0 +0x8e System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext, System.AsyncCallback, System.Object)) 01d3f678 65fd19c5 (MethodDesc 0x6642cde8 +0x1b5 System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest)), calling 01de7cba 01d3f69c 7938111c (MethodDesc 0x79262df0 +0xc System.DateTime.get_UtcNow()), calling mscorwks!GetCLRFunction+0x109f9 01d3f6a4 01c32cbc 01c32cbc, calling 01daa248 01d3f6b4 65fd16b2 (MethodDesc 0x664619e0 +0x62 System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest)), calling (MethodDesc 0x6642cde8 +0 System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest)) 01d3f6c0 65fcfa6d (MethodDesc 0x6642d4a0 +0xfd System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr, Int32)), calling (MethodDesc 0x664619e0 +0 System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest)) 01d3f6d8 65fcf9f4 (MethodDesc 0x6642d4a0 +0x84 System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr, Int32)), calling *** ERROR: Symbol file could not be found. Defaulted to export symbols for \\?\C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\webengine.dll - webengine!GetEcb 01d3f710 79f047fd mscorwks!GetCLRFunction+0x21749 01d3f720 01c32cbc 01c32cbc, calling 01daa248 01d3f730 79f047fd mscorwks!GetCLRFunction+0x21749 01d3f75c 79f01621 mscorwks!GetCLRFunction+0x1e56d, calling mscorwks+0x1b86 01d3f770 79ef98cf mscorwks!GetCLRFunction+0x1681b, calling mscorwks!GetCLRFunction+0x1682f 01d3f7d0 79e74f98 mscorwks!LogHelp_NoGuiOnAssert+0x1e9c, calling mscorwks!LogHelp_NoGuiOnAssert+0x1ec1 01d3f7e8 79f0462c mscorwks!GetCLRFunction+0x21578, calling mscorwks!GetCLRFunction+0x215b0 01d3f7f8 01c32cbc 01c32cbc, calling 01daa248 01d3f844 79f044fa mscorwks!GetCLRFunction+0x21446, calling mscorwks!GetCLRFunction+0x21541 01d3f854 01c32cbc 01c32cbc, calling 01daa248 01d3f898 660167e9 (MethodDesc 0x6646f6b0 +0x5 System.Web.RequestQueue.TimerCompletionCallback(System.Object)), calling (MethodDesc 0x6646f698 +0 System.Web.RequestQueue.ScheduleMoreWorkIfNeeded()) 01d3f89c 793af6c6 (MethodDesc 0x792672b0 +0x1a System.Threading._TimerCallback.TimerCallback_Context(System.Object)) 01d3f8b4 793af647 (MethodDesc 0x7914fc18 +0x5b System.Threading._TimerCallback.PerformTimerCallback(System.Object)), calling (MethodDesc 0x7914e0d8 +0 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)) 01d3f8b8 793af654 (MethodDesc 0x7914fc18 +0x68 System.Threading._TimerCallback.PerformTimerCallback(System.Object)), calling mscorwks!LogHelp_TerminateOnAssert 01d3f8f8 79e74466 mscorwks!LogHelp_NoGuiOnAssert+0x136a, calling mscorwks+0x1813 01d3f8fc 79e7c709 mscorwks!LogHelp_TerminateOnAssert+0x33f1, calling mscorwks!LogHelp_NoGuiOnAssert+0x1360 01d3f964 7c829f3d ntdll!RtlFreeHeap+0x126, calling ntdll!RtlGetNtGlobalFlags+0x12 01d3f96c 7c829f59 ntdll!RtlFreeHeap+0x142, calling ntdll!CIpow+0x464 01d3f9ac 6a2a9998 webengine!CSharelock::ChangeExclusiveLockToSharedLock+0x2d, calling kernel32!InterlockedCompareExchange 01d3f9b4 6a2ab03b webengine!EcbGetUnicodeServerVariables+0x3d5, calling kernel32!InterlockedIncrement 01d3f9f4 01c32cbc 01c32cbc, calling 01daa248 01d3fa28 01daa295 01daa295, calling mscorwks!GetCLRFunction+0x2119e 01d3fa50 6a2aa63f webengine!CookieAuthConstructTicket+0x232 01d3fa6c 01c32cbc 01c32cbc, calling 01daa248 01d3fa70 6a2aa63f webengine!CookieAuthConstructTicket+0x232 01d3fac8 79e734c4 mscorwks!LogHelp_NoGuiOnAssert+0x3c8, calling mscorwks+0x17c0 01d3facc 79e734f2 mscorwks!LogHelp_NoGuiOnAssert+0x3f6, calling mscorwks!LogHelp_NoGuiOnAssert+0x380 01d3fad8 79f00c03 mscorwks!GetCLRFunction+0x1db4f, calling mscorwks!LogHelp_NoGuiOnAssert+0xf0 01d3fadc 79e71b90 mscorwks+0x1b90, calling mscorwks+0x1813 01d3fae0 79f00c0b mscorwks!GetCLRFunction+0x1db57, calling mscorwks+0x1b86 01d3fb1c 79ef30c3 mscorwks!GetCLRFunction+0x1000f, calling mscorwks!GetCLRFunction+0x10040 01d3fb64 79f00c0b mscorwks!GetCLRFunction+0x1db57, calling mscorwks+0x1b86 01d3fb68 79f02a93 mscorwks!GetCLRFunction+0x1f9df, calling mscorwks!GetCLRFunction+0x1d8e5 01d3fb70 79e71b90 mscorwks+0x1b90, calling mscorwks+0x1813 01d3fb74 79f02aa7 mscorwks!GetCLRFunction+0x1f9f3, calling mscorwks+0x1b86 01d3fb88 79f00e8d mscorwks!GetCLRFunction+0x1ddd9, calling mscorwks+0x18bb 01d3fb8c 79f00f03 mscorwks!GetCLRFunction+0x1de4f, calling mscorwks!GetCLRFunction+0x1dd84 01d3fbc0 79f02978 mscorwks!GetCLRFunction+0x1f8c4, calling mscorwks!GetCLRFunction+0x1de1a 01d3fbfc 79e73220 mscorwks!LogHelp_NoGuiOnAssert+0x124, calling (JitHelp: CORINFO_HELP_GET_THREAD) 01d3fc08 79ef2884 mscorwks!GetCLRFunction+0xf7d0, calling mscorwks!LogHelp_NoGuiOnAssert+0x118 01d3fc0c 79ef28ab mscorwks!GetCLRFunction+0xf7f7, calling mscorwks+0x17c0 01d3fc24 79e7904f mscorwks!LogHelp_NoGuiOnAssert+0x5f53, calling mscorwks+0x1b95 01d3fc38 79ef31ca mscorwks!GetCLRFunction+0x10116, calling mscorwks!LogHelp_NoGuiOnAssert+0x5f3d 01d3fc3c 79e71b90 mscorwks+0x1b90, calling mscorwks+0x1813 01d3fc40 79ef31d9 mscorwks!GetCLRFunction+0x10125, calling mscorwks+0x1b86 01d3fc90 7c829fb5 ntdll!RtlGetNtGlobalFlags+0x38, calling ntdll!ExpInterlockedPopEntrySListEnd+0x11 01d3fc94 7c827d0b ntdll!NtWaitForSingleObject+0xc 01d3fc98 77e61d1e kernel32!WaitForSingleObjectEx+0x88, calling ntdll!NtWaitForSingleObject 01d3fca4 77e61d43 kernel32!WaitForSingleObjectEx+0xad, calling kernel32!GetTickCount+0x73 01d3fdb4 6a2aa748 webengine!CookieAuthConstructTicket+0x33b, calling webengine!CookieAuthConstructTicket+0x11d 01d3fdc4 6a2aa715 webengine!CookieAuthConstructTicket+0x308 01d3fddc 79f024cf mscorwks!GetCLRFunction+0x1f41b 01d3fdf4 79ef3a3f mscorwks!GetCLRFunction+0x1098b, calling mscorwks+0x17c0 01d3fe28 79f0202a mscorwks!GetCLRFunction+0x1ef76 01d3fe3c 79f021a0 mscorwks!GetCLRFunction+0x1f0ec, calling mscorwks!GetCLRFunction+0x1eef9 01d3fe94 79fc9840 mscorwks!CorExeMain+0x101f9 01d3ffa4 79fc982e mscorwks!CorExeMain+0x101e7, calling mscorwks!LogHelp_NoGuiOnAssert+0x61c0 01d3ffb8 77e64829 kernel32!GetModuleHandleA+0xdf </code></pre> <p>Lot of stuff there, but nothing that in my (admittedly limited) stack analyzing knowledge indicates looping. I think this next section might have some value however. This is a !dumpstackobjects I got at the same breakpoint:</p> <pre><code>0:000&gt; ~16e !dumpstackobjects OS Thread Id: 0x172c (16) ESP/REG Object Name 01d0ee30 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d0ef68 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d0ef6c 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d0ef74 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d0f280 0295f810 ASI.ParadigmPlus.Question 01d0f284 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d26cec 02fdb36c ASI.ParadigmPlus.GrilleApp.GA1000 01d26cf0 0295f674 ASI.ParadigmPlus.QuestionList 01d26cf4 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d26cf8 02fdb36c ASI.ParadigmPlus.GrilleApp.GA1000 01d26cfc 0295f810 ASI.ParadigmPlus.Question 01d26d00 0295f810 ASI.ParadigmPlus.Question 01d26d08 0295f810 ASI.ParadigmPlus.Question 01d26d30 06c3a958 System.String SP1:SP1 01d26d40 029c232c System.String TNE:TNE 01d26d50 06c3a958 System.String SP1:SP1 01d26d54 029c232c System.String TNE:TNE 01d26d60 029c232c System.String TNE:TNE 01d26d78 06c3a958 System.String SP1:SP1 01d26d7c 06c3a958 System.String SP1:SP1 01d26d84 06c3a958 System.String SP1:SP1 01d26da4 06c357a0 System.String SB1:SB1 01d26da8 06c357a0 System.String SB1:SB1 01d26db0 06c3a958 System.String SP1:SP1 01d26db4 06ba3d08 System.String WHT:WHT 01d26db8 06b987c8 System.String WHT:WHT 01d26dbc 06b8aa10 System.String WF:WF 01d26dc0 029fab00 System.String L:L 01d26dc4 06c3a958 System.String SP1:SP1 01d26dc8 06c4a518 System.String S000:S000 01d26dd4 06c4a518 System.String S000:S000 01d26dd8 0296b404 ASI.ParadigmPlus.Question 01d26ddc 0296a00c ASI.ParadigmPlus.Question 01d26de0 02968a90 ASI.ParadigmPlus.Question 01d26de4 02966af8 ASI.ParadigmPlus.Question 01d26de8 06be6e1c ASI.ParadigmPlus.Answer 01d26dec 06c357a0 System.String SB1:SB1 01d26df0 029fab00 System.String L:L 01d26df4 0295fa54 ASI.ParadigmPlus.QuestionGroup 01d26df8 02963f80 ASI.ParadigmPlus.QuestionGroup 01d26dfc 029662fc ASI.ParadigmPlus.QuestionGroup 01d26e00 02961cb4 ASI.ParadigmPlus.QuestionGroup 01d26e0c 0295f810 ASI.ParadigmPlus.Question 01d26e10 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d270d4 06c38ddc ASI.ParadigmPlus.Answer 01d270dc 06c4bc0c ASI.ParadigmPlus.Dimension 01d270e0 06c4b99c ASI.ParadigmPlus.DimensionList 01d27104 029607f8 ASI.ParadigmPlus.Question 01d27108 0295fa80 ASI.ParadigmPlus.QuestionList 01d27118 06c38e74 System.String 5:5 01d2711c 02960564 ASI.ParadigmPlus.Question 01d27120 0295fa80 ASI.ParadigmPlus.QuestionList 01d2781c 029fac84 ASI.ParadigmPlus.Answer 01d27820 02960464 ASI.ParadigmPlus.AnswerList 01d27824 029fcbd8 ASI.ParadigmPlus.Answer 01d27828 02960464 ASI.ParadigmPlus.AnswerList 01d2782c 029fca28 ASI.ParadigmPlus.Answer 01d27830 02960464 ASI.ParadigmPlus.AnswerList 01d27844 029faa84 ASI.ParadigmPlus.Answer 01d2784c 06c38e74 System.String 5:5 01d27850 02960564 ASI.ParadigmPlus.Question 01d27854 0295fa80 ASI.ParadigmPlus.QuestionList 01d27860 06c38e74 System.String 5:5 01d27864 02960564 ASI.ParadigmPlus.Question 01d27868 0295fa80 ASI.ParadigmPlus.QuestionList 01d27870 06c38e74 System.String 5:5 01d27874 02960564 ASI.ParadigmPlus.Question 01d27878 0295fa80 ASI.ParadigmPlus.QuestionList 01d2787c 029faa84 ASI.ParadigmPlus.Answer 01d27880 02960464 ASI.ParadigmPlus.AnswerList 01d27884 029fab84 ASI.ParadigmPlus.Answer 01d27888 02960464 ASI.ParadigmPlus.AnswerList 01d27974 02960e80 ASI.ParadigmPlus.Question 01d27978 0295fa80 ASI.ParadigmPlus.QuestionList 01d27bd0 06c3a8dc ASI.ParadigmPlus.Answer 01d27c08 06c3b924 ASI.ParadigmPlus.Answer 01d27c0c 02960f44 ASI.ParadigmPlus.AnswerList 01d27c10 06c3b860 ASI.ParadigmPlus.Answer 01d27c14 02960f44 ASI.ParadigmPlus.AnswerList 01d27c18 06c3ac90 ASI.ParadigmPlus.Answer 01d27c1c 02960f44 ASI.ParadigmPlus.AnswerList 01d27c20 06c3abcc ASI.ParadigmPlus.Answer 01d27c24 02960f44 ASI.ParadigmPlus.AnswerList 01d27c28 06c3ab08 ASI.ParadigmPlus.Answer 01d27c2c 02960f44 ASI.ParadigmPlus.AnswerList 01d27c30 06c3aa44 ASI.ParadigmPlus.Answer 01d27c34 02960f44 ASI.ParadigmPlus.AnswerList 01d27c38 06c3b4dc ASI.ParadigmPlus.Answer 01d27c3c 02960f44 ASI.ParadigmPlus.AnswerList 01d27c40 06c3a990 ASI.ParadigmPlus.Answer 01d27c44 02960f44 ASI.ParadigmPlus.AnswerList 01d27c48 06c3a8dc ASI.ParadigmPlus.Answer 01d27c4c 02960f44 ASI.ParadigmPlus.AnswerList 01d27c6c 02960e80 ASI.ParadigmPlus.Question 01d27c70 0295fa80 ASI.ParadigmPlus.QuestionList 01d27e04 029628d0 ASI.ParadigmPlus.Question 01d27e08 02961ce0 ASI.ParadigmPlus.QuestionList 01d27e28 029628d0 ASI.ParadigmPlus.Question 01d27e2c 02961ce0 ASI.ParadigmPlus.QuestionList 01d27f14 06b89804 ASI.ParadigmPlus.Answer 01d27f18 02962994 ASI.ParadigmPlus.AnswerList 01d27f1c 029628d0 ASI.ParadigmPlus.Question 01d27f20 02961ce0 ASI.ParadigmPlus.QuestionList 01d27f38 06c38e74 System.String 5:5 01d27f3c 02960564 ASI.ParadigmPlus.Question 01d27f40 0295fa80 ASI.ParadigmPlus.QuestionList 01d27f4c 06c38e74 System.String 5:5 01d27f50 02960564 ASI.ParadigmPlus.Question 01d27f54 0295fa80 ASI.ParadigmPlus.QuestionList 01d27f60 06c38e74 System.String 5:5 01d27f64 02960564 ASI.ParadigmPlus.Question 01d27f68 0295fa80 ASI.ParadigmPlus.QuestionList 01d27f88 06b89964 ASI.ParadigmPlus.Answer 01d27f8c 029628d0 ASI.ParadigmPlus.Question 01d27f90 02961ce0 ASI.ParadigmPlus.QuestionList 01d27fa8 06c4b34c System.String FDIA:FDIA 01d27fac 0295fd84 ASI.ParadigmPlus.Question 01d27fb0 0295fa80 ASI.ParadigmPlus.QuestionList 01d27fb4 06b896dc ASI.ParadigmPlus.Answer 01d27fb8 02962994 ASI.ParadigmPlus.AnswerList 01d27fbc 029628d0 ASI.ParadigmPlus.Question 01d27fc0 02961ce0 ASI.ParadigmPlus.QuestionList 01d27fc8 029fab00 System.String L:L 01d27fcc 029603a0 ASI.ParadigmPlus.Question 01d27fd0 0295fa80 ASI.ParadigmPlus.QuestionList 01d27fd4 06b89964 ASI.ParadigmPlus.Answer 01d27fd8 02962994 ASI.ParadigmPlus.AnswerList 01d27fdc 029628d0 ASI.ParadigmPlus.Question 01d27fe0 02961ce0 ASI.ParadigmPlus.QuestionList 01d27fe4 029628d0 ASI.ParadigmPlus.Question 01d27fe8 02961ce0 ASI.ParadigmPlus.QuestionList 01d28610 06b987c8 System.String WHT:WHT 01d28614 02961dd8 ASI.ParadigmPlus.Question 01d28618 02961ce0 ASI.ParadigmPlus.QuestionList 01d2872c 06ba3d08 System.String WHT:WHT 01d28730 029621f0 ASI.ParadigmPlus.Question 01d28734 02961ce0 ASI.ParadigmPlus.QuestionList 01d28778 029f1d94 ASI.ParadigmPlus.Answer 01d2877c 02963c14 ASI.ParadigmPlus.AnswerList 01d28780 06c37884 ASI.ParadigmPlus.Answer 01d28784 02963c14 ASI.ParadigmPlus.AnswerList 01d28788 06c379cc ASI.ParadigmPlus.Answer 01d2878c 02963c14 ASI.ParadigmPlus.AnswerList 01d28790 06c36798 ASI.ParadigmPlus.Answer 01d28794 02963c14 ASI.ParadigmPlus.AnswerList 01d28798 06c36510 ASI.ParadigmPlus.Answer 01d2879c 02963c14 ASI.ParadigmPlus.AnswerList 01d287a0 06c36648 ASI.ParadigmPlus.Answer 01d287a4 02963c14 ASI.ParadigmPlus.AnswerList 01d287ac 06c37a78 System.String Custom Paint 01d287b0 06c379cc ASI.ParadigmPlus.Answer 01d287b8 072eb468 System.Collections.ArrayList+ArrayListEnumeratorSimple 01d287bc 02963c14 ASI.ParadigmPlus.AnswerList 01d289dc 029640b8 ASI.ParadigmPlus.Question 01d289e0 02963fac ASI.ParadigmPlus.QuestionList 01d28a38 029f13f4 System.String Venting Sidelite Locking System 01d28a3c 029f1390 ASI.ParadigmPlus.Answer 01d28a44 072f0568 System.Collections.ArrayList+ArrayListEnumeratorSimple 01d28a48 0296417c ASI.ParadigmPlus.AnswerList 01d28a60 06c356f4 ASI.ParadigmPlus.Answer 01d28a68 06c4a518 System.String S000:S000 01d28a6c 0295ffec ASI.ParadigmPlus.Question 01d28a70 0295fa80 ASI.ParadigmPlus.QuestionList 01d28a7c 06c4a518 System.String S000:S000 01d28a80 0295ffec ASI.ParadigmPlus.Question 01d28a84 0295fa80 ASI.ParadigmPlus.QuestionList 01d28a90 0295f768 System.String CustItemNumber 01d28a98 06c4b34c System.String FDIA:FDIA 01d28a9c 0295fd84 ASI.ParadigmPlus.Question 01d28aa0 0295fa80 ASI.ParadigmPlus.QuestionList 01d28aa4 029ecd64 ASI.ParadigmPlus.Answer 01d28aa8 0296417c ASI.ParadigmPlus.AnswerList 01d28aac 029e95ac ASI.ParadigmPlus.Answer 01d28ab0 0296417c ASI.ParadigmPlus.AnswerList 01d28ab8 029f13f4 System.String Venting Sidelite Locking System 01d28abc 029f1390 ASI.ParadigmPlus.Answer 01d28ac4 072ef574 System.Collections.ArrayList+ArrayListEnumeratorSimple 01d28ac8 0296417c ASI.ParadigmPlus.AnswerList 01d28acc 029f1230 ASI.ParadigmPlus.Answer 01d28ad0 0296417c ASI.ParadigmPlus.AnswerList 01d28f4c 02961798 ASI.ParadigmPlus.Question 01d28f50 0295fa80 ASI.ParadigmPlus.QuestionList 01d2903c 0296466c ASI.ParadigmPlus.Question 01d29040 02963fac ASI.ParadigmPlus.QuestionList 01d290cc 06c07914 System.String C:C 01d290d0 02964268 ASI.ParadigmPlus.Question 01d290d4 02963fac ASI.ParadigmPlus.QuestionList 01d29144 06c30604 ASI.ParadigmPlus.Answer 01d29148 02964730 ASI.ParadigmPlus.AnswerList 01d2914c 0296466c ASI.ParadigmPlus.Question 01d29150 02963fac ASI.ParadigmPlus.QuestionList 01d29154 06c0f9d8 ASI.ParadigmPlus.Answer 01d29158 0296450c ASI.ParadigmPlus.AnswerList 01d2915c 02964448 ASI.ParadigmPlus.Question 01d29160 02963fac ASI.ParadigmPlus.QuestionList 01d29164 02964268 ASI.ParadigmPlus.Question 01d29168 02963fac ASI.ParadigmPlus.QuestionList 01d2991c 029d6c7c System.String 021022 01d29928 029d6c7c System.String 021022 01d29934 029d6c7c System.String 021022 01d29938 029d5700 ASI.ParadigmPlus.Answer 01d2993c 0296450c ASI.ParadigmPlus.AnswerList 01d29940 029d6bdc ASI.ParadigmPlus.Answer 01d29944 0296450c ASI.ParadigmPlus.AnswerList 01d29948 02964448 ASI.ParadigmPlus.Question 01d2994c 02963fac ASI.ParadigmPlus.QuestionList 01d2f908 06c4b34c System.String FDIA:FDIA 01d2f90c 0295fd84 ASI.ParadigmPlus.Question 01d2f910 0295fa80 ASI.ParadigmPlus.QuestionList 01d2ffd0 02964c28 ASI.ParadigmPlus.Question 01d2ffd4 02963fac ASI.ParadigmPlus.QuestionList 01d2ffe4 06c32030 System.String SB:SB 01d2ffe8 02964a54 ASI.ParadigmPlus.Question 01d2ffec 02963fac ASI.ParadigmPlus.QuestionList 01d2fffc 06c3368c ASI.ParadigmPlus.Answer 01d30000 02964b18 ASI.ParadigmPlus.AnswerList 01d30004 02964a54 ASI.ParadigmPlus.Question 01d30008 02963fac ASI.ParadigmPlus.QuestionList 01d3000c 02964a54 ASI.ParadigmPlus.Question 01d30010 02963fac ASI.ParadigmPlus.QuestionList 01d30144 06c32030 System.String SB:SB 01d30148 02964a54 ASI.ParadigmPlus.Question 01d3014c 02963fac ASI.ParadigmPlus.QuestionList 01d30154 06c31f90 ASI.ParadigmPlus.Answer 01d3015c 06c344d8 System.String (COM) Lifetime Brass 01d30160 06c34418 ASI.ParadigmPlus.Answer 01d30168 072f16a0 System.Collections.ArrayList+ArrayListEnumeratorSimple 01d3016c 02964b18 ASI.ParadigmPlus.AnswerList 01d30174 06c31f90 ASI.ParadigmPlus.Answer 01d30178 06c34294 ASI.ParadigmPlus.Answer 01d3017c 02964b18 ASI.ParadigmPlus.AnswerList 01d30180 06c33e48 ASI.ParadigmPlus.Answer 01d30184 02964b18 ASI.ParadigmPlus.AnswerList 01d30188 06c32e6c ASI.ParadigmPlus.Answer 01d3018c 02964b18 ASI.ParadigmPlus.AnswerList 01d30190 06c32b78 ASI.ParadigmPlus.Answer 01d30194 02964b18 ASI.ParadigmPlus.AnswerList </code></pre> <p>^^ I had to cut off some of the above to make this post fit, but imagine it keeps going like that ^^</p> <p>Please ignore the details of our custom code. All this seems excessive to me, but I am no expert at the stack. Most of those stack objects listed above (there are 1500+) are not function paramteters, so I would think they do not belong there. Here is an example of the kind of code that is generating all those items on the stack (tons of code like this is run):</p> <pre><code>gUnitType.Questions("French Door Style").CommonLogicValue = CommonLogicValues.AlwaysDisplay gUnitType.Questions("French Door Style").ShowAllAnswers() If Me.NumberOfUnits &gt; 1 Then Me.Dimensions("Call Size Height").Answers("6-8 Handicap sill").Visible = False Me.Dimensions("Call Size Height").Answers("6-10 Handicap Sill").Visible = False Me.Dimensions("Call Size Height").Answers("7-0 Handicap Sill").Visible = False Me.Dimensions("Call Size Height").Answers("8-0 Handicap Sill").Visible = False End If </code></pre> <p>I am also no expert on VB (this code is from a different part of our application I do not normally work with), but is it normal for code like this to be filling up the stack with stuff? If anyone has any insight, or could even just point me in the direction of some resources with info about this kind of stuff, it would be greatly appreciated. Thanks for looking!</p>
[ { "answer_id": 93367, "author": "Mike Dimmick", "author_id": 6970, "author_profile": "https://Stackoverflow.com/users/6970", "pm_score": 1, "selected": false, "text": "<p>You need some decent symbols for the CLR. Set <code>_NT_SYMBOL_PATH</code> (in WinDBG, use File/Symbol File Path) so ...
2008/09/18
[ "https://Stackoverflow.com/questions/93294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17784/" ]
So I have a nasty stack overflow I have been trying to track down / solve for the past 8 hours or so, and I'm at the point where i think i need advice. The details: Interestingly enough this code runs fine when called in the context of our regular winforms application -- but I am tasked with writing a web-based version of our software, and this same exact code causes the stack overflow when called out of an ASPX page running on IIS. The first thing I did was attach and attempt normal .NET debugging through visual studio. At the point of the exception the call stack seemed relatively shallow (about 11 frames deep, of our code), and I could find none of the usual suspects on a stack overflow (bad recursion, self-calling constructors, exception loops). So I resigned myself to breaking out windbg and S.O.S. -- which i know can be useful for this sort of thing, although I had limited experience with it myself. After hours of monkeying around I think I have some useful data, but I need some help analyzing it. First up is a !dumpstack I took while broken just before the stack overflow was about to come down. ``` 0:015> !dumpstack PDB symbol for mscorwks.dll not loaded OS Thread Id: 0x1110 (15) Current frame: ntdll!KiFastSystemCallRet ChildEBP RetAddr Caller,Callee 01d265a8 7c827d0b ntdll!NtWaitForSingleObject+0xc 01d265ac 77e61d1e kernel32!WaitForSingleObjectEx+0x88, calling ntdll!NtWaitForSingleObject 01d2661c 79e789c6 mscorwks!LogHelp_NoGuiOnAssert+0x58ca 01d26660 79e7898f mscorwks!LogHelp_NoGuiOnAssert+0x5893, calling mscorwks!LogHelp_NoGuiOnAssert+0x589b 01d26680 79e734c4 mscorwks!LogHelp_NoGuiOnAssert+0x3c8, calling mscorwks+0x17c0 01d26694 79fc1d6b mscorwks!CorExeMain+0x8724, calling kernel32!InterlockedDecrement 01d26698 79ef3892 mscorwks!GetCLRFunction+0x107de, calling mscorwks+0x17c0 01d266b0 79e78944 mscorwks!LogHelp_NoGuiOnAssert+0x5848, calling mscorwks!LogHelp_NoGuiOnAssert+0x584c 01d266c4 7a14de5d mscorwks!CorLaunchApplication+0x2f243, calling mscorwks!LogHelp_NoGuiOnAssert+0x5831 01d266ec 77e61d1e kernel32!WaitForSingleObjectEx+0x88, calling ntdll!NtWaitForSingleObject 01d266f8 77e61d43 kernel32!WaitForSingleObjectEx+0xad, calling kernel32!GetTickCount+0x73 01d26714 7c8279bb ntdll!NtSetEvent+0xc 01d26718 77e62321 kernel32!SetEvent+0x10, calling ntdll!NtSetEvent 01d26748 7a14df79 mscorwks!CorLaunchApplication+0x2f35f, calling mscorwks!CorLaunchApplication+0x2f17c 01d2675c 7a022dde mscorwks!NGenCreateNGenWorker+0x4516b, calling mscorwks!CorLaunchApplication+0x2f347 01d26770 79fbc685 mscorwks!CorExeMain+0x303e, calling mscorwks+0x1bbe 01d26788 79e734c4 mscorwks!LogHelp_NoGuiOnAssert+0x3c8, calling mscorwks+0x17c0 01d2678c 79e734f2 mscorwks!LogHelp_NoGuiOnAssert+0x3f6, calling mscorwks!LogHelp_NoGuiOnAssert+0x380 01d267a8 7a2d259e mscorwks!CreateHistoryReader+0xafd3 01d267b4 7a2e6292 mscorwks!CreateHistoryReader+0x1ecc7, calling mscorwks!CreateHistoryReader+0xaf9d 01d26814 7a064d52 mscorwks!NGenCreateNGenWorker+0x870df, calling mscorwks!CreateHistoryReader+0x1eb43 01d26854 79f91643 mscorwks!ClrCreateManagedInstance+0x46ff, calling mscorwks!ClrCreateManagedInstance+0x4720 01d2688c 79f915c4 mscorwks!ClrCreateManagedInstance+0x4680 01d268b4 79e734c4 mscorwks!LogHelp_NoGuiOnAssert+0x3c8, calling mscorwks+0x17c0 01d268cc 79f04e98 mscorwks!GetCLRFunction+0x21de4, calling mscorwks!GetCLRFunction+0x21e4b 01d26900 79f0815e mscorwks!GetCLRFunction+0x250aa, calling mscorwks!GetCLRFunction+0x21d35 01d2691c 7c858135 ntdll!RtlIpv4StringToAddressExW+0x167b7, calling ntdll!RtlReleaseResource 01d2692c 79f080a7 mscorwks!GetCLRFunction+0x24ff3, calling mscorwks!GetCLRFunction+0x25052 01d26950 7c828752 ntdll!RtlRaiseStatus+0xe0 01d26974 7c828723 ntdll!RtlRaiseStatus+0xb1, calling ntdll!RtlRaiseStatus+0xba 01d26998 7c8315c2 ntdll!RtlSubtreePredecessor+0x208, calling ntdll!RtlRaiseStatus+0x7e 01d26a1c 7c82855e ntdll!KiUserExceptionDispatcher+0xe, calling ntdll!RtlSubtreePredecessor+0x17c 01d26d20 13380333 (MethodDesc 0x10936710 +0x243 ASI.ParadigmPlus.LoadedWindows.WID904.QuestionChangeLogic(ASI.ParadigmPlus.Question, ASI.ParadigmPlus.Question)) ====> Exception Code 0 cxr@1d26a54 exr@1d26000 01d26bd8 77e64590 kernel32!VirtualAllocEx+0x4b, calling kernel32!GetTickCount+0x73 01d26bec 7c829f59 ntdll!RtlFreeHeap+0x142, calling ntdll!CIpow+0x464 01d26bf0 79e78d11 mscorwks!LogHelp_NoGuiOnAssert+0x5c15, calling ntdll!RtlFreeHeap 01d3e86c 103b4064 (MethodDesc 0xf304c90 +0x174 ASI.ParadigmPlus.Window.TrackQuestionChange(ASI.ParadigmPlus.Question, ASI.ParadigmPlus.Answer)) 01d3e88c 103b4064 (MethodDesc 0xf304c90 +0x174 ASI.ParadigmPlus.Window.TrackQuestionChange(ASI.ParadigmPlus.Question, ASI.ParadigmPlus.Answer)) 01d3e8b0 103b3e6b (MethodDesc 0xebb4b38 +0x23 ASI.CommonLibrary.ASIArrayList3.get_Item(Int32)) 01d3e8d4 103b3d70 (MethodDesc 0xf304e98 +0x1b0 ASI.ParadigmPlus.Window.TrackQuestionChange()) 01d3e910 0f90febf (MethodDesc 0xf30d250 +0x190f ASI.ParadigmPlus.Data.RemoteDataAccess.GetWindow(Int32)) 01d3ec0c 10a2a572 (MethodDesc 0x10935aa0 +0x1f2 ASI.ParadigmPlus.LoadedWindowSets.WSID904.ApplyLayoutChanges()), calling 02259472 01d3ecec 0f90c880 (MethodDesc 0xebb91f8 +0xe8 ASI.ParadigmPlus.Windowset.ApplyLayoutChangesWrap()) 01d3ed0c 0f90c880 (MethodDesc 0xebb91f8 +0xe8 ASI.ParadigmPlus.Windowset.ApplyLayoutChangesWrap()) 01d3ed54 0f4d2388 (MethodDesc 0x22261a0 +0x5e8 WebConfigurator.NewDefault.ProductSelectedIndexChange(Int32, Int32)) 01d3f264 0f4d1d7f (MethodDesc 0x2226180 +0x47 WebConfigurator.NewDefault.btnGo_Click1(System.Object, System.EventArgs)), calling (MethodDesc 0x22261a0 +0 WebConfigurator.NewDefault.ProductSelectedIndexChange(Int32, Int32)) 01d3f284 0e810a05 (MethodDesc 0x22260f8 +0x145 WebConfigurator.NewDefault.Page_Load(System.Object, System.EventArgs)), calling (MethodDesc 0x2226180 +0 WebConfigurator.NewDefault.btnGo_Click1(System.Object, System.EventArgs)) 01d3f2a8 793ae896 (MethodDesc 0x79256848 +0x52 System.MulticastDelegate.RemoveImpl(System.Delegate)) 01d3f2ac 79e7bee8 mscorwks!LogHelp_TerminateOnAssert+0x2bd0, calling mscorwks!LogHelp_TerminateOnAssert+0x2b60 01d3f2c4 66f12980 (MethodDesc 0x66f1bcd0 +0x10 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr, System.Object, System.Object, System.EventArgs)) 01d3f2d0 6628efd2 (MethodDesc 0x66474328 +0x22 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(System.Object, System.EventArgs)), calling (MethodDesc 0x66f1bcd0 +0 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr, System.Object, System.Object, System.EventArgs)) 01d3f2e4 6613cb04 (MethodDesc 0x66468a58 +0x64 System.Web.UI.Control.OnLoad(System.EventArgs)) 01d3f2f8 6613cb50 (MethodDesc 0x66468a60 +0x30 System.Web.UI.Control.LoadRecursive()) 01d3f30c 6614e12d (MethodDesc 0x66467688 +0x59d System.Web.UI.Page.ProcessRequestMain(Boolean, Boolean)) 01d3f4e0 6614c717 (MethodDesc 0x66467430 +0x63 System.Web.UI.Page.AddWrappedFileDependencies(System.Object)), calling (MethodDesc 0x66478de8 +0 System.Web.ResponseDependencyList.AddDependencies(System.String[], System.String, Boolean, System.String)) 01d3f504 6614d8c3 (MethodDesc 0x66467650 +0x67 System.Web.UI.Page.ProcessRequest(Boolean, Boolean)), calling (MethodDesc 0x66467688 +0 System.Web.UI.Page.ProcessRequestMain(Boolean, Boolean)) 01d3f528 79371311 (MethodDesc 0x7925ac80 +0x25 System.Globalization.CultureInfo.get_UserDefaultUICulture()), calling (JitHelp: CORINFO_HELP_GETSHARED_GCSTATIC_BASE) 01d3f53c 6614d80f (MethodDesc 0x66467648 +0x57 System.Web.UI.Page.ProcessRequest()), calling (MethodDesc 0x66467650 +0 System.Web.UI.Page.ProcessRequest(Boolean, Boolean)) 01d3f560 6615055c (MethodDesc 0x664676f0 +0x184 System.Web.UI.Page.SetIntrinsics(System.Web.HttpContext, Boolean)), calling (MethodDesc 0x664726b0 +0 System.Web.UI.TemplateControl.HookUpAutomaticHandlers()) 01d3f578 6614d72f (MethodDesc 0x66467630 +0x13 System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext)), calling (MethodDesc 0x66467648 +0 System.Web.UI.Page.ProcessRequest()) 01d3f580 6614d6c2 (MethodDesc 0x66467620 +0x32 System.Web.UI.Page.ProcessRequest(System.Web.HttpContext)), calling (MethodDesc 0x66467630 +0 System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext)) 01d3f594 0e810206 (MethodDesc 0x22265a0 +0x1e ASP.newdefault_aspx.ProcessRequest(System.Web.HttpContext)), calling (MethodDesc 0x66467620 +0 System.Web.UI.Page.ProcessRequest(System.Web.HttpContext)) 01d3f5a0 65fe6bfb (MethodDesc 0x66470fc0 +0x167 System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()), calling 01dee5da 01d3f5d4 65fe3f51 (MethodDesc 0x6642f090 +0x41 System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)), calling 01de7d0a 01d3f610 65fe7733 (MethodDesc 0x66470cd0 +0x1b3 System.Web.HttpApplication+ApplicationStepManager.ResumeSteps(System.Exception)), calling (MethodDesc 0x6642f090 +0 System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)) 01d3f64c 7939eef2 (MethodDesc 0x7925eda8 +0x26 System.Runtime.InteropServices.GCHandle.Alloc(System.Object)), calling mscorwks!InstallCustomModule+0x1e8d 01d3f664 65fccbfe (MethodDesc 0x6642ebb0 +0x8e System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext, System.AsyncCallback, System.Object)) 01d3f678 65fd19c5 (MethodDesc 0x6642cde8 +0x1b5 System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest)), calling 01de7cba 01d3f69c 7938111c (MethodDesc 0x79262df0 +0xc System.DateTime.get_UtcNow()), calling mscorwks!GetCLRFunction+0x109f9 01d3f6a4 01c32cbc 01c32cbc, calling 01daa248 01d3f6b4 65fd16b2 (MethodDesc 0x664619e0 +0x62 System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest)), calling (MethodDesc 0x6642cde8 +0 System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest)) 01d3f6c0 65fcfa6d (MethodDesc 0x6642d4a0 +0xfd System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr, Int32)), calling (MethodDesc 0x664619e0 +0 System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest)) 01d3f6d8 65fcf9f4 (MethodDesc 0x6642d4a0 +0x84 System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr, Int32)), calling *** ERROR: Symbol file could not be found. Defaulted to export symbols for \\?\C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\webengine.dll - webengine!GetEcb 01d3f710 79f047fd mscorwks!GetCLRFunction+0x21749 01d3f720 01c32cbc 01c32cbc, calling 01daa248 01d3f730 79f047fd mscorwks!GetCLRFunction+0x21749 01d3f75c 79f01621 mscorwks!GetCLRFunction+0x1e56d, calling mscorwks+0x1b86 01d3f770 79ef98cf mscorwks!GetCLRFunction+0x1681b, calling mscorwks!GetCLRFunction+0x1682f 01d3f7d0 79e74f98 mscorwks!LogHelp_NoGuiOnAssert+0x1e9c, calling mscorwks!LogHelp_NoGuiOnAssert+0x1ec1 01d3f7e8 79f0462c mscorwks!GetCLRFunction+0x21578, calling mscorwks!GetCLRFunction+0x215b0 01d3f7f8 01c32cbc 01c32cbc, calling 01daa248 01d3f844 79f044fa mscorwks!GetCLRFunction+0x21446, calling mscorwks!GetCLRFunction+0x21541 01d3f854 01c32cbc 01c32cbc, calling 01daa248 01d3f898 660167e9 (MethodDesc 0x6646f6b0 +0x5 System.Web.RequestQueue.TimerCompletionCallback(System.Object)), calling (MethodDesc 0x6646f698 +0 System.Web.RequestQueue.ScheduleMoreWorkIfNeeded()) 01d3f89c 793af6c6 (MethodDesc 0x792672b0 +0x1a System.Threading._TimerCallback.TimerCallback_Context(System.Object)) 01d3f8b4 793af647 (MethodDesc 0x7914fc18 +0x5b System.Threading._TimerCallback.PerformTimerCallback(System.Object)), calling (MethodDesc 0x7914e0d8 +0 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)) 01d3f8b8 793af654 (MethodDesc 0x7914fc18 +0x68 System.Threading._TimerCallback.PerformTimerCallback(System.Object)), calling mscorwks!LogHelp_TerminateOnAssert 01d3f8f8 79e74466 mscorwks!LogHelp_NoGuiOnAssert+0x136a, calling mscorwks+0x1813 01d3f8fc 79e7c709 mscorwks!LogHelp_TerminateOnAssert+0x33f1, calling mscorwks!LogHelp_NoGuiOnAssert+0x1360 01d3f964 7c829f3d ntdll!RtlFreeHeap+0x126, calling ntdll!RtlGetNtGlobalFlags+0x12 01d3f96c 7c829f59 ntdll!RtlFreeHeap+0x142, calling ntdll!CIpow+0x464 01d3f9ac 6a2a9998 webengine!CSharelock::ChangeExclusiveLockToSharedLock+0x2d, calling kernel32!InterlockedCompareExchange 01d3f9b4 6a2ab03b webengine!EcbGetUnicodeServerVariables+0x3d5, calling kernel32!InterlockedIncrement 01d3f9f4 01c32cbc 01c32cbc, calling 01daa248 01d3fa28 01daa295 01daa295, calling mscorwks!GetCLRFunction+0x2119e 01d3fa50 6a2aa63f webengine!CookieAuthConstructTicket+0x232 01d3fa6c 01c32cbc 01c32cbc, calling 01daa248 01d3fa70 6a2aa63f webengine!CookieAuthConstructTicket+0x232 01d3fac8 79e734c4 mscorwks!LogHelp_NoGuiOnAssert+0x3c8, calling mscorwks+0x17c0 01d3facc 79e734f2 mscorwks!LogHelp_NoGuiOnAssert+0x3f6, calling mscorwks!LogHelp_NoGuiOnAssert+0x380 01d3fad8 79f00c03 mscorwks!GetCLRFunction+0x1db4f, calling mscorwks!LogHelp_NoGuiOnAssert+0xf0 01d3fadc 79e71b90 mscorwks+0x1b90, calling mscorwks+0x1813 01d3fae0 79f00c0b mscorwks!GetCLRFunction+0x1db57, calling mscorwks+0x1b86 01d3fb1c 79ef30c3 mscorwks!GetCLRFunction+0x1000f, calling mscorwks!GetCLRFunction+0x10040 01d3fb64 79f00c0b mscorwks!GetCLRFunction+0x1db57, calling mscorwks+0x1b86 01d3fb68 79f02a93 mscorwks!GetCLRFunction+0x1f9df, calling mscorwks!GetCLRFunction+0x1d8e5 01d3fb70 79e71b90 mscorwks+0x1b90, calling mscorwks+0x1813 01d3fb74 79f02aa7 mscorwks!GetCLRFunction+0x1f9f3, calling mscorwks+0x1b86 01d3fb88 79f00e8d mscorwks!GetCLRFunction+0x1ddd9, calling mscorwks+0x18bb 01d3fb8c 79f00f03 mscorwks!GetCLRFunction+0x1de4f, calling mscorwks!GetCLRFunction+0x1dd84 01d3fbc0 79f02978 mscorwks!GetCLRFunction+0x1f8c4, calling mscorwks!GetCLRFunction+0x1de1a 01d3fbfc 79e73220 mscorwks!LogHelp_NoGuiOnAssert+0x124, calling (JitHelp: CORINFO_HELP_GET_THREAD) 01d3fc08 79ef2884 mscorwks!GetCLRFunction+0xf7d0, calling mscorwks!LogHelp_NoGuiOnAssert+0x118 01d3fc0c 79ef28ab mscorwks!GetCLRFunction+0xf7f7, calling mscorwks+0x17c0 01d3fc24 79e7904f mscorwks!LogHelp_NoGuiOnAssert+0x5f53, calling mscorwks+0x1b95 01d3fc38 79ef31ca mscorwks!GetCLRFunction+0x10116, calling mscorwks!LogHelp_NoGuiOnAssert+0x5f3d 01d3fc3c 79e71b90 mscorwks+0x1b90, calling mscorwks+0x1813 01d3fc40 79ef31d9 mscorwks!GetCLRFunction+0x10125, calling mscorwks+0x1b86 01d3fc90 7c829fb5 ntdll!RtlGetNtGlobalFlags+0x38, calling ntdll!ExpInterlockedPopEntrySListEnd+0x11 01d3fc94 7c827d0b ntdll!NtWaitForSingleObject+0xc 01d3fc98 77e61d1e kernel32!WaitForSingleObjectEx+0x88, calling ntdll!NtWaitForSingleObject 01d3fca4 77e61d43 kernel32!WaitForSingleObjectEx+0xad, calling kernel32!GetTickCount+0x73 01d3fdb4 6a2aa748 webengine!CookieAuthConstructTicket+0x33b, calling webengine!CookieAuthConstructTicket+0x11d 01d3fdc4 6a2aa715 webengine!CookieAuthConstructTicket+0x308 01d3fddc 79f024cf mscorwks!GetCLRFunction+0x1f41b 01d3fdf4 79ef3a3f mscorwks!GetCLRFunction+0x1098b, calling mscorwks+0x17c0 01d3fe28 79f0202a mscorwks!GetCLRFunction+0x1ef76 01d3fe3c 79f021a0 mscorwks!GetCLRFunction+0x1f0ec, calling mscorwks!GetCLRFunction+0x1eef9 01d3fe94 79fc9840 mscorwks!CorExeMain+0x101f9 01d3ffa4 79fc982e mscorwks!CorExeMain+0x101e7, calling mscorwks!LogHelp_NoGuiOnAssert+0x61c0 01d3ffb8 77e64829 kernel32!GetModuleHandleA+0xdf ``` Lot of stuff there, but nothing that in my (admittedly limited) stack analyzing knowledge indicates looping. I think this next section might have some value however. This is a !dumpstackobjects I got at the same breakpoint: ``` 0:000> ~16e !dumpstackobjects OS Thread Id: 0x172c (16) ESP/REG Object Name 01d0ee30 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d0ef68 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d0ef6c 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d0ef74 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d0f280 0295f810 ASI.ParadigmPlus.Question 01d0f284 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d26cec 02fdb36c ASI.ParadigmPlus.GrilleApp.GA1000 01d26cf0 0295f674 ASI.ParadigmPlus.QuestionList 01d26cf4 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d26cf8 02fdb36c ASI.ParadigmPlus.GrilleApp.GA1000 01d26cfc 0295f810 ASI.ParadigmPlus.Question 01d26d00 0295f810 ASI.ParadigmPlus.Question 01d26d08 0295f810 ASI.ParadigmPlus.Question 01d26d30 06c3a958 System.String SP1:SP1 01d26d40 029c232c System.String TNE:TNE 01d26d50 06c3a958 System.String SP1:SP1 01d26d54 029c232c System.String TNE:TNE 01d26d60 029c232c System.String TNE:TNE 01d26d78 06c3a958 System.String SP1:SP1 01d26d7c 06c3a958 System.String SP1:SP1 01d26d84 06c3a958 System.String SP1:SP1 01d26da4 06c357a0 System.String SB1:SB1 01d26da8 06c357a0 System.String SB1:SB1 01d26db0 06c3a958 System.String SP1:SP1 01d26db4 06ba3d08 System.String WHT:WHT 01d26db8 06b987c8 System.String WHT:WHT 01d26dbc 06b8aa10 System.String WF:WF 01d26dc0 029fab00 System.String L:L 01d26dc4 06c3a958 System.String SP1:SP1 01d26dc8 06c4a518 System.String S000:S000 01d26dd4 06c4a518 System.String S000:S000 01d26dd8 0296b404 ASI.ParadigmPlus.Question 01d26ddc 0296a00c ASI.ParadigmPlus.Question 01d26de0 02968a90 ASI.ParadigmPlus.Question 01d26de4 02966af8 ASI.ParadigmPlus.Question 01d26de8 06be6e1c ASI.ParadigmPlus.Answer 01d26dec 06c357a0 System.String SB1:SB1 01d26df0 029fab00 System.String L:L 01d26df4 0295fa54 ASI.ParadigmPlus.QuestionGroup 01d26df8 02963f80 ASI.ParadigmPlus.QuestionGroup 01d26dfc 029662fc ASI.ParadigmPlus.QuestionGroup 01d26e00 02961cb4 ASI.ParadigmPlus.QuestionGroup 01d26e0c 0295f810 ASI.ParadigmPlus.Question 01d26e10 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904 01d270d4 06c38ddc ASI.ParadigmPlus.Answer 01d270dc 06c4bc0c ASI.ParadigmPlus.Dimension 01d270e0 06c4b99c ASI.ParadigmPlus.DimensionList 01d27104 029607f8 ASI.ParadigmPlus.Question 01d27108 0295fa80 ASI.ParadigmPlus.QuestionList 01d27118 06c38e74 System.String 5:5 01d2711c 02960564 ASI.ParadigmPlus.Question 01d27120 0295fa80 ASI.ParadigmPlus.QuestionList 01d2781c 029fac84 ASI.ParadigmPlus.Answer 01d27820 02960464 ASI.ParadigmPlus.AnswerList 01d27824 029fcbd8 ASI.ParadigmPlus.Answer 01d27828 02960464 ASI.ParadigmPlus.AnswerList 01d2782c 029fca28 ASI.ParadigmPlus.Answer 01d27830 02960464 ASI.ParadigmPlus.AnswerList 01d27844 029faa84 ASI.ParadigmPlus.Answer 01d2784c 06c38e74 System.String 5:5 01d27850 02960564 ASI.ParadigmPlus.Question 01d27854 0295fa80 ASI.ParadigmPlus.QuestionList 01d27860 06c38e74 System.String 5:5 01d27864 02960564 ASI.ParadigmPlus.Question 01d27868 0295fa80 ASI.ParadigmPlus.QuestionList 01d27870 06c38e74 System.String 5:5 01d27874 02960564 ASI.ParadigmPlus.Question 01d27878 0295fa80 ASI.ParadigmPlus.QuestionList 01d2787c 029faa84 ASI.ParadigmPlus.Answer 01d27880 02960464 ASI.ParadigmPlus.AnswerList 01d27884 029fab84 ASI.ParadigmPlus.Answer 01d27888 02960464 ASI.ParadigmPlus.AnswerList 01d27974 02960e80 ASI.ParadigmPlus.Question 01d27978 0295fa80 ASI.ParadigmPlus.QuestionList 01d27bd0 06c3a8dc ASI.ParadigmPlus.Answer 01d27c08 06c3b924 ASI.ParadigmPlus.Answer 01d27c0c 02960f44 ASI.ParadigmPlus.AnswerList 01d27c10 06c3b860 ASI.ParadigmPlus.Answer 01d27c14 02960f44 ASI.ParadigmPlus.AnswerList 01d27c18 06c3ac90 ASI.ParadigmPlus.Answer 01d27c1c 02960f44 ASI.ParadigmPlus.AnswerList 01d27c20 06c3abcc ASI.ParadigmPlus.Answer 01d27c24 02960f44 ASI.ParadigmPlus.AnswerList 01d27c28 06c3ab08 ASI.ParadigmPlus.Answer 01d27c2c 02960f44 ASI.ParadigmPlus.AnswerList 01d27c30 06c3aa44 ASI.ParadigmPlus.Answer 01d27c34 02960f44 ASI.ParadigmPlus.AnswerList 01d27c38 06c3b4dc ASI.ParadigmPlus.Answer 01d27c3c 02960f44 ASI.ParadigmPlus.AnswerList 01d27c40 06c3a990 ASI.ParadigmPlus.Answer 01d27c44 02960f44 ASI.ParadigmPlus.AnswerList 01d27c48 06c3a8dc ASI.ParadigmPlus.Answer 01d27c4c 02960f44 ASI.ParadigmPlus.AnswerList 01d27c6c 02960e80 ASI.ParadigmPlus.Question 01d27c70 0295fa80 ASI.ParadigmPlus.QuestionList 01d27e04 029628d0 ASI.ParadigmPlus.Question 01d27e08 02961ce0 ASI.ParadigmPlus.QuestionList 01d27e28 029628d0 ASI.ParadigmPlus.Question 01d27e2c 02961ce0 ASI.ParadigmPlus.QuestionList 01d27f14 06b89804 ASI.ParadigmPlus.Answer 01d27f18 02962994 ASI.ParadigmPlus.AnswerList 01d27f1c 029628d0 ASI.ParadigmPlus.Question 01d27f20 02961ce0 ASI.ParadigmPlus.QuestionList 01d27f38 06c38e74 System.String 5:5 01d27f3c 02960564 ASI.ParadigmPlus.Question 01d27f40 0295fa80 ASI.ParadigmPlus.QuestionList 01d27f4c 06c38e74 System.String 5:5 01d27f50 02960564 ASI.ParadigmPlus.Question 01d27f54 0295fa80 ASI.ParadigmPlus.QuestionList 01d27f60 06c38e74 System.String 5:5 01d27f64 02960564 ASI.ParadigmPlus.Question 01d27f68 0295fa80 ASI.ParadigmPlus.QuestionList 01d27f88 06b89964 ASI.ParadigmPlus.Answer 01d27f8c 029628d0 ASI.ParadigmPlus.Question 01d27f90 02961ce0 ASI.ParadigmPlus.QuestionList 01d27fa8 06c4b34c System.String FDIA:FDIA 01d27fac 0295fd84 ASI.ParadigmPlus.Question 01d27fb0 0295fa80 ASI.ParadigmPlus.QuestionList 01d27fb4 06b896dc ASI.ParadigmPlus.Answer 01d27fb8 02962994 ASI.ParadigmPlus.AnswerList 01d27fbc 029628d0 ASI.ParadigmPlus.Question 01d27fc0 02961ce0 ASI.ParadigmPlus.QuestionList 01d27fc8 029fab00 System.String L:L 01d27fcc 029603a0 ASI.ParadigmPlus.Question 01d27fd0 0295fa80 ASI.ParadigmPlus.QuestionList 01d27fd4 06b89964 ASI.ParadigmPlus.Answer 01d27fd8 02962994 ASI.ParadigmPlus.AnswerList 01d27fdc 029628d0 ASI.ParadigmPlus.Question 01d27fe0 02961ce0 ASI.ParadigmPlus.QuestionList 01d27fe4 029628d0 ASI.ParadigmPlus.Question 01d27fe8 02961ce0 ASI.ParadigmPlus.QuestionList 01d28610 06b987c8 System.String WHT:WHT 01d28614 02961dd8 ASI.ParadigmPlus.Question 01d28618 02961ce0 ASI.ParadigmPlus.QuestionList 01d2872c 06ba3d08 System.String WHT:WHT 01d28730 029621f0 ASI.ParadigmPlus.Question 01d28734 02961ce0 ASI.ParadigmPlus.QuestionList 01d28778 029f1d94 ASI.ParadigmPlus.Answer 01d2877c 02963c14 ASI.ParadigmPlus.AnswerList 01d28780 06c37884 ASI.ParadigmPlus.Answer 01d28784 02963c14 ASI.ParadigmPlus.AnswerList 01d28788 06c379cc ASI.ParadigmPlus.Answer 01d2878c 02963c14 ASI.ParadigmPlus.AnswerList 01d28790 06c36798 ASI.ParadigmPlus.Answer 01d28794 02963c14 ASI.ParadigmPlus.AnswerList 01d28798 06c36510 ASI.ParadigmPlus.Answer 01d2879c 02963c14 ASI.ParadigmPlus.AnswerList 01d287a0 06c36648 ASI.ParadigmPlus.Answer 01d287a4 02963c14 ASI.ParadigmPlus.AnswerList 01d287ac 06c37a78 System.String Custom Paint 01d287b0 06c379cc ASI.ParadigmPlus.Answer 01d287b8 072eb468 System.Collections.ArrayList+ArrayListEnumeratorSimple 01d287bc 02963c14 ASI.ParadigmPlus.AnswerList 01d289dc 029640b8 ASI.ParadigmPlus.Question 01d289e0 02963fac ASI.ParadigmPlus.QuestionList 01d28a38 029f13f4 System.String Venting Sidelite Locking System 01d28a3c 029f1390 ASI.ParadigmPlus.Answer 01d28a44 072f0568 System.Collections.ArrayList+ArrayListEnumeratorSimple 01d28a48 0296417c ASI.ParadigmPlus.AnswerList 01d28a60 06c356f4 ASI.ParadigmPlus.Answer 01d28a68 06c4a518 System.String S000:S000 01d28a6c 0295ffec ASI.ParadigmPlus.Question 01d28a70 0295fa80 ASI.ParadigmPlus.QuestionList 01d28a7c 06c4a518 System.String S000:S000 01d28a80 0295ffec ASI.ParadigmPlus.Question 01d28a84 0295fa80 ASI.ParadigmPlus.QuestionList 01d28a90 0295f768 System.String CustItemNumber 01d28a98 06c4b34c System.String FDIA:FDIA 01d28a9c 0295fd84 ASI.ParadigmPlus.Question 01d28aa0 0295fa80 ASI.ParadigmPlus.QuestionList 01d28aa4 029ecd64 ASI.ParadigmPlus.Answer 01d28aa8 0296417c ASI.ParadigmPlus.AnswerList 01d28aac 029e95ac ASI.ParadigmPlus.Answer 01d28ab0 0296417c ASI.ParadigmPlus.AnswerList 01d28ab8 029f13f4 System.String Venting Sidelite Locking System 01d28abc 029f1390 ASI.ParadigmPlus.Answer 01d28ac4 072ef574 System.Collections.ArrayList+ArrayListEnumeratorSimple 01d28ac8 0296417c ASI.ParadigmPlus.AnswerList 01d28acc 029f1230 ASI.ParadigmPlus.Answer 01d28ad0 0296417c ASI.ParadigmPlus.AnswerList 01d28f4c 02961798 ASI.ParadigmPlus.Question 01d28f50 0295fa80 ASI.ParadigmPlus.QuestionList 01d2903c 0296466c ASI.ParadigmPlus.Question 01d29040 02963fac ASI.ParadigmPlus.QuestionList 01d290cc 06c07914 System.String C:C 01d290d0 02964268 ASI.ParadigmPlus.Question 01d290d4 02963fac ASI.ParadigmPlus.QuestionList 01d29144 06c30604 ASI.ParadigmPlus.Answer 01d29148 02964730 ASI.ParadigmPlus.AnswerList 01d2914c 0296466c ASI.ParadigmPlus.Question 01d29150 02963fac ASI.ParadigmPlus.QuestionList 01d29154 06c0f9d8 ASI.ParadigmPlus.Answer 01d29158 0296450c ASI.ParadigmPlus.AnswerList 01d2915c 02964448 ASI.ParadigmPlus.Question 01d29160 02963fac ASI.ParadigmPlus.QuestionList 01d29164 02964268 ASI.ParadigmPlus.Question 01d29168 02963fac ASI.ParadigmPlus.QuestionList 01d2991c 029d6c7c System.String 021022 01d29928 029d6c7c System.String 021022 01d29934 029d6c7c System.String 021022 01d29938 029d5700 ASI.ParadigmPlus.Answer 01d2993c 0296450c ASI.ParadigmPlus.AnswerList 01d29940 029d6bdc ASI.ParadigmPlus.Answer 01d29944 0296450c ASI.ParadigmPlus.AnswerList 01d29948 02964448 ASI.ParadigmPlus.Question 01d2994c 02963fac ASI.ParadigmPlus.QuestionList 01d2f908 06c4b34c System.String FDIA:FDIA 01d2f90c 0295fd84 ASI.ParadigmPlus.Question 01d2f910 0295fa80 ASI.ParadigmPlus.QuestionList 01d2ffd0 02964c28 ASI.ParadigmPlus.Question 01d2ffd4 02963fac ASI.ParadigmPlus.QuestionList 01d2ffe4 06c32030 System.String SB:SB 01d2ffe8 02964a54 ASI.ParadigmPlus.Question 01d2ffec 02963fac ASI.ParadigmPlus.QuestionList 01d2fffc 06c3368c ASI.ParadigmPlus.Answer 01d30000 02964b18 ASI.ParadigmPlus.AnswerList 01d30004 02964a54 ASI.ParadigmPlus.Question 01d30008 02963fac ASI.ParadigmPlus.QuestionList 01d3000c 02964a54 ASI.ParadigmPlus.Question 01d30010 02963fac ASI.ParadigmPlus.QuestionList 01d30144 06c32030 System.String SB:SB 01d30148 02964a54 ASI.ParadigmPlus.Question 01d3014c 02963fac ASI.ParadigmPlus.QuestionList 01d30154 06c31f90 ASI.ParadigmPlus.Answer 01d3015c 06c344d8 System.String (COM) Lifetime Brass 01d30160 06c34418 ASI.ParadigmPlus.Answer 01d30168 072f16a0 System.Collections.ArrayList+ArrayListEnumeratorSimple 01d3016c 02964b18 ASI.ParadigmPlus.AnswerList 01d30174 06c31f90 ASI.ParadigmPlus.Answer 01d30178 06c34294 ASI.ParadigmPlus.Answer 01d3017c 02964b18 ASI.ParadigmPlus.AnswerList 01d30180 06c33e48 ASI.ParadigmPlus.Answer 01d30184 02964b18 ASI.ParadigmPlus.AnswerList 01d30188 06c32e6c ASI.ParadigmPlus.Answer 01d3018c 02964b18 ASI.ParadigmPlus.AnswerList 01d30190 06c32b78 ASI.ParadigmPlus.Answer 01d30194 02964b18 ASI.ParadigmPlus.AnswerList ``` ^^ I had to cut off some of the above to make this post fit, but imagine it keeps going like that ^^ Please ignore the details of our custom code. All this seems excessive to me, but I am no expert at the stack. Most of those stack objects listed above (there are 1500+) are not function paramteters, so I would think they do not belong there. Here is an example of the kind of code that is generating all those items on the stack (tons of code like this is run): ``` gUnitType.Questions("French Door Style").CommonLogicValue = CommonLogicValues.AlwaysDisplay gUnitType.Questions("French Door Style").ShowAllAnswers() If Me.NumberOfUnits > 1 Then Me.Dimensions("Call Size Height").Answers("6-8 Handicap sill").Visible = False Me.Dimensions("Call Size Height").Answers("6-10 Handicap Sill").Visible = False Me.Dimensions("Call Size Height").Answers("7-0 Handicap Sill").Visible = False Me.Dimensions("Call Size Height").Answers("8-0 Handicap Sill").Visible = False End If ``` I am also no expert on VB (this code is from a different part of our application I do not normally work with), but is it normal for code like this to be filling up the stack with stuff? If anyone has any insight, or could even just point me in the direction of some resources with info about this kind of stuff, it would be greatly appreciated. Thanks for looking!
I thought I'd post back here with the resolution to this in case someone else runs into it. The replies above were all helpful, and pointed out why i might be overflowing the stack -- but the thing that I still couldn't come to grips with was why the exact same code ran fine in our winforms app. What I eventually discovered was that at some point microsoft changed the stack size of IIS threads from 1MB (like in the general .NET context) to 256k. This explained everything, including the especially frustrating fact that even the ASPX version ran fine under the visual studio dev server. I resolved the problem by working with this particular customer to drastically cut the ammount of code in the QuestionChangeLogic function mentioned above (when I looked up the source, the function had > 15,000 lines!). Thanks for the help guys.
93,335
<p>Does anyone know of a good tool to generate the WSDL for a service contract written in C# (i.e. set of methods that are tagged as "[OperationContract]" using WCF)? All the tools I've found work the other way around: create code stubs from a WSDL. I don't want to have to hand-jam a WSDL file. I've found tools for php and J2EE, but not C#. Thanks!</p>
[ { "answer_id": 93368, "author": "blowdart", "author_id": 2525, "author_profile": "https://Stackoverflow.com/users/2525", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/aa702581.aspx\" rel=\"nofollow noreferrer\">svcutil</a> or just host it...
2008/09/18
[ "https://Stackoverflow.com/questions/93335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59910/" ]
Does anyone know of a good tool to generate the WSDL for a service contract written in C# (i.e. set of methods that are tagged as "[OperationContract]" using WCF)? All the tools I've found work the other way around: create code stubs from a WSDL. I don't want to have to hand-jam a WSDL file. I've found tools for php and J2EE, but not C#. Thanks!
Easiest thing to do is host the service with a base address setup, and then just hit it from a browser with "?wsdl" appended to the end. Here's an example of a service configuration with a base address specified. Note this goes in the `<configuration><services>` element in your config: ``` <service name="MyServiceName" behaviorConfiguration="MyServiceBehavior"> <host> <baseAddresses> <add baseAddress="http://localhost:9000/MyService"/> </baseAddresses> </host> <endpoint address="net.tcp://localhost:9001/MyService" binding="netTcpBinding" contract="IMyService" bindingConfiguration="MyServiceBinding"/> </service> ``` Once you get it hosted, just go to `http://localhost:9000/MyService?wsdl` to see the WSDL definition.
93,353
<p>I need to make a random list of permutations. The elements can be anything but assume that they are the integers 0 through x-1. I want to make y lists, each containing z elements. The rules are that no list may contain the same element twice and that over all the lists, the number of times each elements is used is the same (or as close as possible). For instance, if my elements are 0,1,2,3, y is 6, and z is 2, then one possible solution is:</p> <pre> 0,3 1,2 3,0 2,1 0,1 2,3 </pre> <p>Each row has only unique elements and no element has been used more than 3 times. If y were 7, then 2 elements would be used 4 times, the rest 3.</p>
[ { "answer_id": 93465, "author": "PierreBdR", "author_id": 7136, "author_profile": "https://Stackoverflow.com/users/7136", "pm_score": 0, "selected": false, "text": "<p>Ok, one way to approximate that:</p>\n\n<p>1 - shuffle your list</p>\n\n<p>2 - take the y first elements to form the nex...
2008/09/18
[ "https://Stackoverflow.com/questions/93353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4454/" ]
I need to make a random list of permutations. The elements can be anything but assume that they are the integers 0 through x-1. I want to make y lists, each containing z elements. The rules are that no list may contain the same element twice and that over all the lists, the number of times each elements is used is the same (or as close as possible). For instance, if my elements are 0,1,2,3, y is 6, and z is 2, then one possible solution is: ``` 0,3 1,2 3,0 2,1 0,1 2,3 ``` Each row has only unique elements and no element has been used more than 3 times. If y were 7, then 2 elements would be used 4 times, the rest 3.
This could be improved, but it seems to do the job (Python): ``` import math, random def get_pool(items, y, z): slots = y*z use_each_times = slots/len(items) exceptions = slots - use_each_times*len(items) if (use_each_times > y or exceptions > 0 and use_each_times+1 > y): raise Exception("Impossible.") pool = {} for n in items: pool[n] = use_each_times for n in random.sample(items, exceptions): pool[n] += 1 return pool def rebalance(ret, pool, z): max_item = None max_times = None for item, times in pool.items(): if times > max_times: max_item = item max_times = times next, times = max_item, max_times candidates = [] for i in range(len(ret)): item = ret[i] if next not in item: candidates.append( (item, i) ) swap, swap_index = random.choice(candidates) swapi = [] for i in range(len(swap)): if swap[i] not in pool: swapi.append( (swap[i], i) ) which, i = random.choice(swapi) pool[next] -= 1 pool[swap[i]] = 1 swap[i] = next ret[swap_index] = swap def plist(items, y, z): pool = get_pool(items, y, z) ret = [] while len(pool.keys()) > 0: while len(pool.keys()) < z: rebalance(ret, pool, z) selections = random.sample(pool.keys(), z) for i in selections: pool[i] -= 1 if pool[i] == 0: del pool[i] ret.append( selections ) return ret print plist([0,1,2,3], 6, 2) ```
93,357
<p><strong>I want to read the contents of a URL but don't want to "hang" if the URL is unresponsive. I've created a BufferedReader using the URL...</strong></p> <pre><code>URL theURL = new URL(url); URLConnection urlConn = theURL.openConnection(); urlConn.setDoOutput(true); BufferedReader urlReader = new BufferedReader(newInputStreamReader(urlConn.getInputStream())); </code></pre> <p><strong>...and then begun the loop to read the contents...</strong></p> <pre><code>do { buf = urlReader.readLine(); if (buf != null) { resultBuffer.append(buf); resultBuffer.append("\n"); } } while (buf != null); </code></pre> <p><strong>...but if the read hangs then the application hangs.</strong></p> <p><strong>Is there a way, without grinding the code down to the socket level, to "time out" the read if necessary?</strong></p>
[ { "answer_id": 93418, "author": "jsight", "author_id": 1432, "author_profile": "https://Stackoverflow.com/users/1432", "pm_score": 5, "selected": true, "text": "<p>I think URLConnection.setReadTimeout is what you are looking for.</p>\n" }, { "answer_id": 93452, "author": "Pet...
2008/09/18
[ "https://Stackoverflow.com/questions/93357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13930/" ]
**I want to read the contents of a URL but don't want to "hang" if the URL is unresponsive. I've created a BufferedReader using the URL...** ``` URL theURL = new URL(url); URLConnection urlConn = theURL.openConnection(); urlConn.setDoOutput(true); BufferedReader urlReader = new BufferedReader(newInputStreamReader(urlConn.getInputStream())); ``` **...and then begun the loop to read the contents...** ``` do { buf = urlReader.readLine(); if (buf != null) { resultBuffer.append(buf); resultBuffer.append("\n"); } } while (buf != null); ``` **...but if the read hangs then the application hangs.** **Is there a way, without grinding the code down to the socket level, to "time out" the read if necessary?**
I think URLConnection.setReadTimeout is what you are looking for.
93,408
<p>I saw some code like the following in a JSP</p> <pre><code>&lt;c:if test="&lt;%=request.isUserInRole(RoleEnum.USER.getCode())%&gt;"&gt; &lt;li&gt;user&lt;/li&gt; &lt;/c:if&gt; </code></pre> <p>My confusion is over the "=" that appears in the value of the <code>test</code> attribute. My understanding was that anything included within <code>&lt;%= %&gt;</code> is printed to the output, but surely the value assigned to test must be a Boolean, so why does this work?</p> <p>For bonus points, is there any way to change the attribute value above such that it does not use scriptlet code? Presumably, that means using EL instead.</p> <p>Cheers, Don</p>
[ { "answer_id": 93469, "author": "Sindri Traustason", "author_id": 1113, "author_profile": "https://Stackoverflow.com/users/1113", "pm_score": 2, "selected": false, "text": "<p>Attributes in JSP tag libraries in general can be either static or resolved at request time. If they are resolv...
2008/09/18
[ "https://Stackoverflow.com/questions/93408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I saw some code like the following in a JSP ``` <c:if test="<%=request.isUserInRole(RoleEnum.USER.getCode())%>"> <li>user</li> </c:if> ``` My confusion is over the "=" that appears in the value of the `test` attribute. My understanding was that anything included within `<%= %>` is printed to the output, but surely the value assigned to test must be a Boolean, so why does this work? For bonus points, is there any way to change the attribute value above such that it does not use scriptlet code? Presumably, that means using EL instead. Cheers, Don
All that the `test` attribute looks for to determine if something is true is the string "true" (case in-sensitive). For example, the following code will print "Hello world!" ``` <c:if test="true">Hello world!</c:if> ``` The code within the `<%= %>` returns a boolean, so it will either print the string "true" or "false", which is exactly what the `<c:if>` tag looks for.
93,415
<p>I use <a href="http://files.emacsblog.org/ryan/elisp/maxframe.el" rel="noreferrer">maxframe.el</a> to maximize my Emacs frames.</p> <p>It works great on all three major platforms, except on my dual-head Mac setup (Macbook Pro 15-inch laptop with 23-inch monitor). </p> <p>When maximizing an Emacs frame, the frame expands to fill the width of <em>both</em> monitors and the height of the larger monitor. </p> <p>Obviously, I would like the frame to maximize to fill only the monitor it's on. How can I detect the resolutions of the two individual monitors using elisp? </p> <p>Thanks, Jacob</p> <p>EDIT: As Denis points out, setting mf-max-width is a reasonable workaround. But (as I should have mentioned) I was hoping for a solution that works on both monitors and with any resolution. Maybe something OSX-specific in the style of the Windows-specific w32-send-sys-command. </p>
[ { "answer_id": 93428, "author": "EfForEffort", "author_id": 14113, "author_profile": "https://Stackoverflow.com/users/14113", "pm_score": 2, "selected": false, "text": "<p>Does customising `mf-max-width' work? Its documentation:</p>\n\n<pre><code>\"*The maximum display width to support....
2008/09/18
[ "https://Stackoverflow.com/questions/93415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13747/" ]
I use [maxframe.el](http://files.emacsblog.org/ryan/elisp/maxframe.el) to maximize my Emacs frames. It works great on all three major platforms, except on my dual-head Mac setup (Macbook Pro 15-inch laptop with 23-inch monitor). When maximizing an Emacs frame, the frame expands to fill the width of *both* monitors and the height of the larger monitor. Obviously, I would like the frame to maximize to fill only the monitor it's on. How can I detect the resolutions of the two individual monitors using elisp? Thanks, Jacob EDIT: As Denis points out, setting mf-max-width is a reasonable workaround. But (as I should have mentioned) I was hoping for a solution that works on both monitors and with any resolution. Maybe something OSX-specific in the style of the Windows-specific w32-send-sys-command.
I quickly scanned the reference that you provided to `maxframe.el` and *I don't think* that you're using the same technique that I use. Does the following code snippet help you? ``` (defun toggle-fullscreen () "toggles whether the currently selected frame consumes the entire display or is decorated with a window border" (interactive) (let ((f (selected-frame))) (modify-frame-parameters f `((fullscreen . ,(if (eq nil (frame-parameter f 'fullscreen)) 'fullboth nil)))))) ```
93,423
<p>I have the following code:</p> <pre><code> String inputFile = "somefile.txt"; FileInputStream in = new FileInputStream(inputFile); FileChannel ch = in.getChannel(); ByteBuffer buf = ByteBuffer.allocateDirect(BUFSIZE); // BUFSIZE = 256 /* read the file into a buffer, 256 bytes at a time */ int rd; while ( (rd = ch.read( buf )) != -1 ) { buf.rewind(); for ( int i = 0; i &lt; rd/2; i++ ) { /* print each character */ System.out.print(buf.getChar()); } buf.clear(); } </code></pre> <p>But the characters get displayed at ?'s. Does this have something to do with Java using Unicode characters? How do I correct this?</p>
[ { "answer_id": 93521, "author": "Burkhard", "author_id": 12860, "author_profile": "https://Stackoverflow.com/users/12860", "pm_score": 0, "selected": false, "text": "<p>Yes, it is Unicode.</p>\n\n<p>If you have 14 Chars in your File, you only get 7 '?'.</p>\n\n<p>Solution pending. Still ...
2008/09/18
[ "https://Stackoverflow.com/questions/93423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10675/" ]
I have the following code: ``` String inputFile = "somefile.txt"; FileInputStream in = new FileInputStream(inputFile); FileChannel ch = in.getChannel(); ByteBuffer buf = ByteBuffer.allocateDirect(BUFSIZE); // BUFSIZE = 256 /* read the file into a buffer, 256 bytes at a time */ int rd; while ( (rd = ch.read( buf )) != -1 ) { buf.rewind(); for ( int i = 0; i < rd/2; i++ ) { /* print each character */ System.out.print(buf.getChar()); } buf.clear(); } ``` But the characters get displayed at ?'s. Does this have something to do with Java using Unicode characters? How do I correct this?
You have to know what the encoding of the file is, and then decode the ByteBuffer into a CharBuffer using that encoding. Assuming the file is ASCII: ``` import java.util.*; import java.io.*; import java.nio.*; import java.nio.channels.*; import java.nio.charset.*; public class Buffer { public static void main(String args[]) throws Exception { String inputFile = "somefile"; FileInputStream in = new FileInputStream(inputFile); FileChannel ch = in.getChannel(); ByteBuffer buf = ByteBuffer.allocateDirect(BUFSIZE); // BUFSIZE = 256 Charset cs = Charset.forName("ASCII"); // Or whatever encoding you want /* read the file into a buffer, 256 bytes at a time */ int rd; while ( (rd = ch.read( buf )) != -1 ) { buf.rewind(); CharBuffer chbuf = cs.decode(buf); for ( int i = 0; i < chbuf.length(); i++ ) { /* print each character */ System.out.print(chbuf.get()); } buf.clear(); } } } ```
93,439
<p>Is there any website/service which will enable me to add RSS subscription to any website?</p> <p>This is for my company I work. We have a website which displays company related news. These news are supplied by an external agency and they gets updated to our database automatically. Our website picks up random/new news and displays them. We are looking at adding a "Subscribe via RSS" button to our website.</p>
[ { "answer_id": 93459, "author": "Mark Ingram", "author_id": 986, "author_profile": "https://Stackoverflow.com/users/986", "pm_score": 2, "selected": false, "text": "<p>Your question is a little difficult to understand. Are you trying to generate the RSS for others to consume, or are you ...
2008/09/18
[ "https://Stackoverflow.com/questions/93439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12178/" ]
Is there any website/service which will enable me to add RSS subscription to any website? This is for my company I work. We have a website which displays company related news. These news are supplied by an external agency and they gets updated to our database automatically. Our website picks up random/new news and displays them. We are looking at adding a "Subscribe via RSS" button to our website.
If you have the data in your database, creating one yourself is fairly straight forward - there's a simple tutorial [here](http://www.downes.ca/cgi-bin/page.cgi?post=56). Once you've set up a feed, in the <head> of your page, you put text like: ``` <link rel="alternate" title="RSS Feed" href="http://www.example.com/rss-feed/latest/" type="application/rss+xml" /> ``` This allows the feed to be "auto-discovered" by your user's browser (e.g. the RSS icon appears in the address bar in FF).
93,462
<p>when an SQL Server Express DB is 'in recovery', you are unable to connect using SQL Authentication. </p> <p>Is there a simple way of determining the stat of the DB prior to connecting to it? (Using .Net)</p>
[ { "answer_id": 93594, "author": "Andy Irving", "author_id": 8553, "author_profile": "https://Stackoverflow.com/users/8553", "pm_score": 2, "selected": false, "text": "<pre><code>SELECT DATABASEPROPERTYEX ('master', 'STATUS') AS 'Status';\n</code></pre>\n\n<p>Replace 'master' with your da...
2008/09/18
[ "https://Stackoverflow.com/questions/93462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
when an SQL Server Express DB is 'in recovery', you are unable to connect using SQL Authentication. Is there a simple way of determining the stat of the DB prior to connecting to it? (Using .Net)
``` SELECT DATABASEPROPERTYEX ('master', 'STATUS') AS 'Status'; ``` Replace 'master' with your database name
93,472
<p>Is it possible to use DateTimePicker (Winforms) to pick both date and time (in the dropdown)? How do you change the custom display of the picked value? Also, is it possible to enable the user to type the date/time manually?</p>
[ { "answer_id": 93606, "author": "Nescio", "author_id": 14484, "author_profile": "https://Stackoverflow.com/users/14484", "pm_score": 6, "selected": false, "text": "<p>Unfortunately, this is one of the many misnomers in the framework, or at best a violation of SRP. <br></p>\n\n<p>To use t...
2008/09/18
[ "https://Stackoverflow.com/questions/93472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5363/" ]
Is it possible to use DateTimePicker (Winforms) to pick both date and time (in the dropdown)? How do you change the custom display of the picked value? Also, is it possible to enable the user to type the date/time manually?
Set the Format to Custom and then specify the format: ``` dateTimePicker1.Format = DateTimePickerFormat.Custom; dateTimePicker1.CustomFormat = "MM/dd/yyyy hh:mm:ss"; ``` or however you want to lay it out. You could then type in directly the date/time. If you use MMM, you'll need to use the numeric value for the month for entry, unless you write some code yourself for that (e.g., 5 results in May) Don't know about the picker for date and time together. Sounds like a custom control to me.
93,511
<p>How to get a counter inside xsl:for-each loop that would reflect the number of current element processed.<br> For example my source XML is</p> <pre><code>&lt;books&gt; &lt;book&gt; &lt;title&gt;The Unbearable Lightness of Being &lt;/title&gt; &lt;/book&gt; &lt;book&gt; &lt;title&gt;Narcissus and Goldmund&lt;/title&gt; &lt;/book&gt; &lt;book&gt; &lt;title&gt;Choke&lt;/title&gt; &lt;/book&gt; &lt;/books&gt; </code></pre> <p>What I want to get is:</p> <pre><code>&lt;newBooks&gt; &lt;newBook&gt; &lt;countNo&gt;1&lt;/countNo&gt; &lt;title&gt;The Unbearable Lightness of Being &lt;/title&gt; &lt;/newBook&gt; &lt;newBook&gt; &lt;countNo&gt;2&lt;/countNo&gt; &lt;title&gt;Narcissus and Goldmund&lt;/title&gt; &lt;/newBook&gt; &lt;newBook&gt; &lt;countNo&gt;3&lt;/countNo&gt; &lt;title&gt;Choke&lt;/title&gt; &lt;/newBook&gt; &lt;/newBooks&gt; </code></pre> <p>The XSLT to modify:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&gt; &lt;xsl:template match="/"&gt; &lt;newBooks&gt; &lt;xsl:for-each select="books/book"&gt; &lt;newBook&gt; &lt;countNo&gt;???&lt;/countNo&gt; &lt;title&gt; &lt;xsl:value-of select="title"/&gt; &lt;/title&gt; &lt;/newBook&gt; &lt;/xsl:for-each&gt; &lt;/newBooks&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>So the question is what to put in place of ???. Is there any standard keyword or do I simply must declare a variable and increment it inside the loop?</p> <p>As the question is pretty long I should probably expect one line or one word answer :)</p>
[ { "answer_id": 93553, "author": "redsquare", "author_id": 6440, "author_profile": "https://Stackoverflow.com/users/6440", "pm_score": 8, "selected": true, "text": "<p><code>position()</code>. E.G.:</p>\n\n<pre><code>&lt;countNo&gt;&lt;xsl:value-of select=\"position()\" /&gt;&lt;/countNo&...
2008/09/18
[ "https://Stackoverflow.com/questions/93511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3241/" ]
How to get a counter inside xsl:for-each loop that would reflect the number of current element processed. For example my source XML is ``` <books> <book> <title>The Unbearable Lightness of Being </title> </book> <book> <title>Narcissus and Goldmund</title> </book> <book> <title>Choke</title> </book> </books> ``` What I want to get is: ``` <newBooks> <newBook> <countNo>1</countNo> <title>The Unbearable Lightness of Being </title> </newBook> <newBook> <countNo>2</countNo> <title>Narcissus and Goldmund</title> </newBook> <newBook> <countNo>3</countNo> <title>Choke</title> </newBook> </newBooks> ``` The XSLT to modify: ``` <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <newBooks> <xsl:for-each select="books/book"> <newBook> <countNo>???</countNo> <title> <xsl:value-of select="title"/> </title> </newBook> </xsl:for-each> </newBooks> </xsl:template> </xsl:stylesheet> ``` So the question is what to put in place of ???. Is there any standard keyword or do I simply must declare a variable and increment it inside the loop? As the question is pretty long I should probably expect one line or one word answer :)
`position()`. E.G.: ``` <countNo><xsl:value-of select="position()" /></countNo> ```
93,541
<p>I have a custom user control with a textbox on it and I'd like to expose the baseline (of the text in the textbox) snapline outside of the custom control. I know that you create a designer (inherited from ControlDesigner) and override SnapLines to get access to the snaplines, but I'm wondering how to get the text baseline of a control that I have exposed by my custom user control.</p>
[ { "answer_id": 95013, "author": "BenR", "author_id": 18039, "author_profile": "https://Stackoverflow.com/users/18039", "pm_score": 2, "selected": false, "text": "<p>You're on the right track. You will need to override the SnapLines property in your designr and do something like this:</p...
2008/09/18
[ "https://Stackoverflow.com/questions/93541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2848/" ]
I have a custom user control with a textbox on it and I'd like to expose the baseline (of the text in the textbox) snapline outside of the custom control. I know that you create a designer (inherited from ControlDesigner) and override SnapLines to get access to the snaplines, but I'm wondering how to get the text baseline of a control that I have exposed by my custom user control.
I just had a similar need, and I solved it like this: ``` public override IList SnapLines { get { IList snapLines = base.SnapLines; MyControl control = Control as MyControl; if (control == null) { return snapLines; } IDesigner designer = TypeDescriptor.CreateDesigner( control.textBoxValue, typeof(IDesigner)); if (designer == null) { return snapLines; } designer.Initialize(control.textBoxValue); using (designer) { ControlDesigner boxDesigner = designer as ControlDesigner; if (boxDesigner == null) { return snapLines; } foreach (SnapLine line in boxDesigner.SnapLines) { if (line.SnapLineType == SnapLineType.Baseline) { snapLines.Add(new SnapLine(SnapLineType.Baseline, line.Offset + control.textBoxValue.Top, line.Filter, line.Priority)); break; } } } return snapLines; } } ``` This way it's actually creating a temporary sub-designer for the subcontrol in order to find out where the "real" baseline snapline is. This seemed reasonably performant in testing, but if perf becomes a concern (and if the internal textbox doesn't move) then most of this code can be extracted to the Initialize method. This also assumes that the textbox is a direct child of the UserControl. If there are other layout-affecting controls in the way then the offset calculation becomes a bit more complicated.
93,569
<p>For example, if I declare a long variable, can I assume it will always be aligned on a "sizeof(long)" boundary? Microsoft Visual C++ online help says so, but is it standard behavior?</p> <p>some more info:</p> <p>a. It is possible to explicitely create a misaligned integer (*bar):</p> <blockquote> <p>char foo[5]</p> <p>int * bar = (int *)(&amp;foo[1]);</p> </blockquote> <p>b. Apparently, #pragma pack() only affects structures, classes, and unions.</p> <p>c. MSVC documentation states that POD types are aligned to their respective sizes (but is it always or by default, and is it standard behavior, I don't know)</p>
[ { "answer_id": 93585, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 0, "selected": false, "text": "<p>Yes, all types are always aligned to at least their alignment requirements.</p>\n\n<p>How could it be otherwise?</p...
2008/09/18
[ "https://Stackoverflow.com/questions/93569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12291/" ]
For example, if I declare a long variable, can I assume it will always be aligned on a "sizeof(long)" boundary? Microsoft Visual C++ online help says so, but is it standard behavior? some more info: a. It is possible to explicitely create a misaligned integer (\*bar): > > char foo[5] > > > int \* bar = (int \*)(&foo[1]); > > > b. Apparently, #pragma pack() only affects structures, classes, and unions. c. MSVC documentation states that POD types are aligned to their respective sizes (but is it always or by default, and is it standard behavior, I don't know)
As others have mentioned, this isn't part of the standard and is left up to the compiler to implement as it sees fit for the processor in question. For example, VC could easily implement different alignment requirements for an ARM processor than it does for x86 processors. Microsoft VC implements what is basically called natural alignment up to the size specified by the #pragma pack directive or the /Zp command line option. This means that, for example, any POD type with a size smaller or equal to 8 bytes will be aligned based on its size. Anything larger will be aligned on an 8 byte boundary. If it is important that you control alignment for different processors and different compilers, then you can use a packing size of 1 and pad your structures. ``` #pragma pack(push) #pragma pack(1) struct Example { short data1; // offset 0 short padding1; // offset 2 long data2; // offset 4 }; #pragma pack(pop) ``` In this code, the `padding1` variable exists only to make sure that data2 is naturally aligned. Answer to a: Yes, that can easily cause misaligned data. On an x86 processor, this doesn't really hurt much at all. On other processors, this can result in a crash or a very slow execution. For example, the Alpha processor would throw a processor exception which would be caught by the OS. The OS would then inspect the instruction and then do the work needed to handle the misaligned data. Then execution continues. The `__unaligned` keyword can be used in VC to mark unaligned access for non-x86 programs (i.e. for CE).
93,578
<p>I cannot use the Resource File API from within a file system plugin due to a PlatSec issue:</p> <pre><code>*PlatSec* ERROR - Capability check failed - Can't load filesystemplugin.PXT because it links to bafl.dll which has the following capabilities missing: TCB </code></pre> <p>My understanding of the issue is that:</p> <p>File system plugins are dlls which are executed within the context of the file system process. Therefore all file system plugins must have the <code>TCB</code> PlatSec privilege which in turn means they cannot link against a dll that is not in the <code>TCB</code>.</p> <p>Is there a way around this (without resorting to a text file or an intermediate server)? I suspect not - but it would be good to get a definitive answer.</p>
[ { "answer_id": 94169, "author": "MathewI", "author_id": 17938, "author_profile": "https://Stackoverflow.com/users/17938", "pm_score": 3, "selected": true, "text": "<p>The Symbian file server has the following capabilities:</p>\n\n<pre><code>TCB ProtServ DiskAdmin AllFiles PowerMgmt CommD...
2008/09/18
[ "https://Stackoverflow.com/questions/93578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8565/" ]
I cannot use the Resource File API from within a file system plugin due to a PlatSec issue: ``` *PlatSec* ERROR - Capability check failed - Can't load filesystemplugin.PXT because it links to bafl.dll which has the following capabilities missing: TCB ``` My understanding of the issue is that: File system plugins are dlls which are executed within the context of the file system process. Therefore all file system plugins must have the `TCB` PlatSec privilege which in turn means they cannot link against a dll that is not in the `TCB`. Is there a way around this (without resorting to a text file or an intermediate server)? I suspect not - but it would be good to get a definitive answer.
The Symbian file server has the following capabilities: ``` TCB ProtServ DiskAdmin AllFiles PowerMgmt CommDD ``` So any DLL being loaded into the file server process must have at least these capabilities. There is no way around this, short of writing a new proxy process as you allude to. However, there is a more fundamental reason why you shouldn't be using `bafl.dll` from within a fileserver plugin: this DLL provides utility functions which interface to the file servers client API. Attempting to use it from within the filer server will not work; at best, it will lead to the file server deadlocking as it attempts to connect to itself. I'd suggest rethinking that you're trying to do, and investigating an internal file-server API to achieve it instead.
93,583
<p>In a asp.net web application, I want to write to a file. This function will first get data from the database, and then write out the flat file.</p> <p>What can I do to make sure only 1 write occurs, and once the write occurrs, the other threads that maybe want to write to the file don't since the write took place.</p> <p>I want to have this write done ONLY if it hasn't been done in say 15 minutes.</p> <p>I know there is a lock keyword, so should I wrap everything in a lock, then check if it has been updated in 15 minutes or more, or visa versa?</p> <p><b>Update</b></p> <p>Workflow:</p> <p>Since this is a web application, the multiple instances will be people viewing a particular web page. I could use the build in cache system, but if asp.net recycles it will be expensive to rebuild the cache so I just want to write it out to a flat file. My other option would be just to create a windows service, but that is more work to manage that I want.</p>
[ { "answer_id": 93597, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 2, "selected": false, "text": "<p>Synchronize your writing code to lock on a shared object so that only one thread gets inside the block. Others wait till the...
2008/09/18
[ "https://Stackoverflow.com/questions/93583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
In a asp.net web application, I want to write to a file. This function will first get data from the database, and then write out the flat file. What can I do to make sure only 1 write occurs, and once the write occurrs, the other threads that maybe want to write to the file don't since the write took place. I want to have this write done ONLY if it hasn't been done in say 15 minutes. I know there is a lock keyword, so should I wrap everything in a lock, then check if it has been updated in 15 minutes or more, or visa versa? **Update** Workflow: Since this is a web application, the multiple instances will be people viewing a particular web page. I could use the build in cache system, but if asp.net recycles it will be expensive to rebuild the cache so I just want to write it out to a flat file. My other option would be just to create a windows service, but that is more work to manage that I want.
Synchronize your writing code to lock on a shared object so that only one thread gets inside the block. Others wait till the current one exits. ``` lock(this) { // perform the write. } ``` Update: I assumed that you have a shared object. If these are different processes on the same machine, you'd need something like a Named Mutex. [Looky here for an example](http://msdn.microsoft.com/en-us/library/aa332344(VS.71).aspx)
93,590
<p>I have a question about using streams in .NET to load files from disk. I am trying to pinpoint a performance problem and want to be sure it's where I think it is.</p> <pre><code>Dim provider1 As New MD5CryptoServiceProvider Dim stream1 As FileStream stream1 = New FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read) provider1.ComputeHash(stream1) </code></pre> <p>Q: Are the bytes read from disk when I create the FileStream object, or when the object consuming the stream, in this case an MD5 Hash algorithm, actually reads it?</p> <p>I see significant performance problems on my web host when using the <code>ComputeHash</code> method, compared to my local test environment. I'm just trying to make sure that the performance problem is in the hashing and not in the disk access.</p>
[ { "answer_id": 93644, "author": "MichaelT", "author_id": 288629, "author_profile": "https://Stackoverflow.com/users/288629", "pm_score": 0, "selected": false, "text": "<p>Yes content of the file will be read then you run ComputeHash method and not when you just open a FileStream.</p>\n\n...
2008/09/18
[ "https://Stackoverflow.com/questions/93590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3059/" ]
I have a question about using streams in .NET to load files from disk. I am trying to pinpoint a performance problem and want to be sure it's where I think it is. ``` Dim provider1 As New MD5CryptoServiceProvider Dim stream1 As FileStream stream1 = New FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read) provider1.ComputeHash(stream1) ``` Q: Are the bytes read from disk when I create the FileStream object, or when the object consuming the stream, in this case an MD5 Hash algorithm, actually reads it? I see significant performance problems on my web host when using the `ComputeHash` method, compared to my local test environment. I'm just trying to make sure that the performance problem is in the hashing and not in the disk access.
FileStream simply exposes an IO.Stream around a file object, and uses buffers. It doesn't read the entire file in the constructor (the file could be larger than RAM). The performance issue is most likely in the hashing, and you can perform some simple benchmarks to prove whether it's because of file IO or the algorithm itself. But one of the first things you might try is: ``` provider1.ComputeHash(stream1.ToArray()); ``` This should make the FileStream read the entire file and return an array of bytes. .ToArray() may invoke a faster method than the .Read() method that ComputeHash will call.
93,625
<p>I have a list with two <code>&lt;div&gt;</code>s in every <code>&lt;li&gt;</code> and I want to float them one next to the other and I want the <code>&lt;li&gt;</code> to take the whole availabe space. How do I do it?</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;style type="text/css"&gt; body { } ul { } li { } .a { } .b { } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;ul&gt; &lt;li&gt; &lt;div class="a"&gt; content &lt;/div&gt; &lt;div class="b"&gt; content &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 93646, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": -1, "selected": false, "text": "<pre><code>li{width:100%;}\n.a{}\n.b{float: left;}\n</code></pre>\n\n<p>That should do as required from my knowledge of C...
2008/09/18
[ "https://Stackoverflow.com/questions/93625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17781/" ]
I have a list with two `<div>`s in every `<li>` and I want to float them one next to the other and I want the `<li>` to take the whole availabe space. How do I do it? ``` <html> <head> <title></title> <style type="text/css"> body { } ul { } li { } .a { } .b { } </style> </head> <body> <ul> <li> <div class="a"> content </div> <div class="b"> content </div> </li> </ul> </body> </html> ```
```css *{ margin: 0; padding: 0;} li{ width: 100%: display: block; } li:after{ clear: both; } div.a{ width: 49%; float: left; } div.b{ width: 49%; float: left; } ``` Should do the trick.
93,638
<p>I have a WPF app with many list based controls in a window, which all are bound to different CollectionViews.</p> <p>At the window level is there a way to get the current selected item for the currently in focus list based control? I know I can do this with some fairly trivial code by looking for the in focus element but does WPF support this as a concept out of the box?</p> <p>Something like Window.CurrentSelectedDataItem would be great. I am looking into using this as a way to centralize command management for enabling disabling commands based on a current selected data item.</p>
[ { "answer_id": 95031, "author": "Andy", "author_id": 3857, "author_profile": "https://Stackoverflow.com/users/3857", "pm_score": 1, "selected": false, "text": "<p>I don't think that there is a property like you specify, but as an alternative you could register a ClassHandler for the List...
2008/09/18
[ "https://Stackoverflow.com/questions/93638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a WPF app with many list based controls in a window, which all are bound to different CollectionViews. At the window level is there a way to get the current selected item for the currently in focus list based control? I know I can do this with some fairly trivial code by looking for the in focus element but does WPF support this as a concept out of the box? Something like Window.CurrentSelectedDataItem would be great. I am looking into using this as a way to centralize command management for enabling disabling commands based on a current selected data item.
I don't think that there is a property like you specify, but as an alternative you could register a ClassHandler for the ListBox.SelectionChanged event in your Window class: ``` EventManager.RegisterClassHandler(typeof(ListBox), ListBox.SelectionChanged, new SelectionChangedEventHandler(this.OnListBoxSelectionChanged)); ``` This will get called whenever the selection changes in any ListBox in your application. You can use the sender argument to determine which ListBox it was that changed its selection, and cache this value for when you need it.
93,650
<p>How do you apply stroke (outline around text) to a textblock in xaml in WPF?</p>
[ { "answer_id": 94235, "author": "Tim Erickson", "author_id": 8787, "author_profile": "https://Stackoverflow.com/users/8787", "pm_score": 1, "selected": false, "text": "<p>In Blend you could convert the TextBlock to a Path, and then use the normal Stroke properties. But I'm assuming you ...
2008/09/18
[ "https://Stackoverflow.com/questions/93650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3798/" ]
How do you apply stroke (outline around text) to a textblock in xaml in WPF?
Below is my more idiomatically WPF, full-featured take on this. It supports pretty much everything you'd expect, including: * all font related properties including stretch and style * text alignment (left, right, center, justify) * text wrapping * text trimming * text decorations (underline, strike through etcetera) Here's a simple example of what can be achieved with it: ``` <local:OutlinedTextBlock FontFamily="Verdana" FontSize="20pt" FontWeight="ExtraBold" TextWrapping="Wrap" StrokeThickness="1" Stroke="{StaticResource TextStroke}" Fill="{StaticResource TextFill}"> Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit </local:OutlinedTextBlock> ``` Which results in: ![enter image description here](https://i.stack.imgur.com/gyDYX.png) Here's the code for the control: ```cs using System; using System.ComponentModel; using System.Globalization; using System.Windows; using System.Windows.Documents; using System.Windows.Markup; using System.Windows.Media; [ContentProperty("Text")] public class OutlinedTextBlock : FrameworkElement { public static readonly DependencyProperty FillProperty = DependencyProperty.Register( "Fill", typeof(Brush), typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(Brushes.Black, FrameworkPropertyMetadataOptions.AffectsRender)); public static readonly DependencyProperty StrokeProperty = DependencyProperty.Register( "Stroke", typeof(Brush), typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(Brushes.Black, FrameworkPropertyMetadataOptions.AffectsRender)); public static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register( "StrokeThickness", typeof(double), typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(1d, FrameworkPropertyMetadataOptions.AffectsRender)); public static readonly DependencyProperty FontFamilyProperty = TextElement.FontFamilyProperty.AddOwner( typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(OnFormattedTextUpdated)); public static readonly DependencyProperty FontSizeProperty = TextElement.FontSizeProperty.AddOwner( typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(OnFormattedTextUpdated)); public static readonly DependencyProperty FontStretchProperty = TextElement.FontStretchProperty.AddOwner( typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(OnFormattedTextUpdated)); public static readonly DependencyProperty FontStyleProperty = TextElement.FontStyleProperty.AddOwner( typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(OnFormattedTextUpdated)); public static readonly DependencyProperty FontWeightProperty = TextElement.FontWeightProperty.AddOwner( typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(OnFormattedTextUpdated)); public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", typeof(string), typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(OnFormattedTextInvalidated)); public static readonly DependencyProperty TextAlignmentProperty = DependencyProperty.Register( "TextAlignment", typeof(TextAlignment), typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(OnFormattedTextUpdated)); public static readonly DependencyProperty TextDecorationsProperty = DependencyProperty.Register( "TextDecorations", typeof(TextDecorationCollection), typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(OnFormattedTextUpdated)); public static readonly DependencyProperty TextTrimmingProperty = DependencyProperty.Register( "TextTrimming", typeof(TextTrimming), typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(OnFormattedTextUpdated)); public static readonly DependencyProperty TextWrappingProperty = DependencyProperty.Register( "TextWrapping", typeof(TextWrapping), typeof(OutlinedTextBlock), new FrameworkPropertyMetadata(TextWrapping.NoWrap, OnFormattedTextUpdated)); private FormattedText formattedText; private Geometry textGeometry; public OutlinedTextBlock() { this.TextDecorations = new TextDecorationCollection(); } public Brush Fill { get { return (Brush)GetValue(FillProperty); } set { SetValue(FillProperty, value); } } public FontFamily FontFamily { get { return (FontFamily)GetValue(FontFamilyProperty); } set { SetValue(FontFamilyProperty, value); } } [TypeConverter(typeof(FontSizeConverter))] public double FontSize { get { return (double)GetValue(FontSizeProperty); } set { SetValue(FontSizeProperty, value); } } public FontStretch FontStretch { get { return (FontStretch)GetValue(FontStretchProperty); } set { SetValue(FontStretchProperty, value); } } public FontStyle FontStyle { get { return (FontStyle)GetValue(FontStyleProperty); } set { SetValue(FontStyleProperty, value); } } public FontWeight FontWeight { get { return (FontWeight)GetValue(FontWeightProperty); } set { SetValue(FontWeightProperty, value); } } public Brush Stroke { get { return (Brush)GetValue(StrokeProperty); } set { SetValue(StrokeProperty, value); } } public double StrokeThickness { get { return (double)GetValue(StrokeThicknessProperty); } set { SetValue(StrokeThicknessProperty, value); } } public string Text { get { return (string)GetValue(TextProperty); } set { SetValue(TextProperty, value); } } public TextAlignment TextAlignment { get { return (TextAlignment)GetValue(TextAlignmentProperty); } set { SetValue(TextAlignmentProperty, value); } } public TextDecorationCollection TextDecorations { get { return (TextDecorationCollection)this.GetValue(TextDecorationsProperty); } set { this.SetValue(TextDecorationsProperty, value); } } public TextTrimming TextTrimming { get { return (TextTrimming)GetValue(TextTrimmingProperty); } set { SetValue(TextTrimmingProperty, value); } } public TextWrapping TextWrapping { get { return (TextWrapping)GetValue(TextWrappingProperty); } set { SetValue(TextWrappingProperty, value); } } protected override void OnRender(DrawingContext drawingContext) { this.EnsureGeometry(); drawingContext.DrawGeometry(this.Fill, new Pen(this.Stroke, this.StrokeThickness), this.textGeometry); } protected override Size MeasureOverride(Size availableSize) { this.EnsureFormattedText(); // constrain the formatted text according to the available size // the Math.Min call is important - without this constraint (which seems arbitrary, but is the maximum allowable text width), things blow up when availableSize is infinite in both directions // the Math.Max call is to ensure we don't hit zero, which will cause MaxTextHeight to throw this.formattedText.MaxTextWidth = Math.Min(3579139, availableSize.Width); this.formattedText.MaxTextHeight = Math.Max(0.0001d, availableSize.Height); // return the desired size return new Size(this.formattedText.Width, this.formattedText.Height); } protected override Size ArrangeOverride(Size finalSize) { this.EnsureFormattedText(); // update the formatted text with the final size this.formattedText.MaxTextWidth = finalSize.Width; this.formattedText.MaxTextHeight = finalSize.Height; // need to re-generate the geometry now that the dimensions have changed this.textGeometry = null; return finalSize; } private static void OnFormattedTextInvalidated(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { var outlinedTextBlock = (OutlinedTextBlock)dependencyObject; outlinedTextBlock.formattedText = null; outlinedTextBlock.textGeometry = null; outlinedTextBlock.InvalidateMeasure(); outlinedTextBlock.InvalidateVisual(); } private static void OnFormattedTextUpdated(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { var outlinedTextBlock = (OutlinedTextBlock)dependencyObject; outlinedTextBlock.UpdateFormattedText(); outlinedTextBlock.textGeometry = null; outlinedTextBlock.InvalidateMeasure(); outlinedTextBlock.InvalidateVisual(); } private void EnsureFormattedText() { if (this.formattedText != null || this.Text == null) { return; } this.formattedText = new FormattedText( this.Text, CultureInfo.CurrentUICulture, this.FlowDirection, new Typeface(this.FontFamily, this.FontStyle, this.FontWeight, FontStretches.Normal), this.FontSize, Brushes.Black); this.UpdateFormattedText(); } private void UpdateFormattedText() { if (this.formattedText == null) { return; } this.formattedText.MaxLineCount = this.TextWrapping == TextWrapping.NoWrap ? 1 : int.MaxValue; this.formattedText.TextAlignment = this.TextAlignment; this.formattedText.Trimming = this.TextTrimming; this.formattedText.SetFontSize(this.FontSize); this.formattedText.SetFontStyle(this.FontStyle); this.formattedText.SetFontWeight(this.FontWeight); this.formattedText.SetFontFamily(this.FontFamily); this.formattedText.SetFontStretch(this.FontStretch); this.formattedText.SetTextDecorations(this.TextDecorations); } private void EnsureGeometry() { if (this.textGeometry != null) { return; } this.EnsureFormattedText(); this.textGeometry = this.formattedText.BuildGeometry(new Point(0, 0)); } } ```
93,653
<p>I've got a stored procedure in my database, that looks like this</p> <pre><code>ALTER PROCEDURE [dbo].[GetCountingAnalysisResults] @RespondentFilters varchar AS BEGIN @RespondentFilters = '''8ec94bed-fed6-4627-8d45-21619331d82a, 114c61f2-8935-4755-b4e9-4a598a51cc7f''' DECLARE @SQL nvarchar(600) SET @SQL = 'SELECT * FROM Answer WHERE Answer.RespondentId IN ('+@RespondentFilters+''')) GROUP BY ChosenOptionId' exec sp_executesql @SQL END </code></pre> <p>It compiles and executes, but somehow it doesn't give me good results, just like the IN statement wasn't working. Please, if anybody know the solution to this problem, help me.</p>
[ { "answer_id": 93701, "author": "Jeremiah Peschka", "author_id": 11780, "author_profile": "https://Stackoverflow.com/users/11780", "pm_score": 1, "selected": false, "text": "<p>It looks like you don't have closing quotes around your @RespondentFilters <pre>'8ec94bed-fed6-4627-8d45-216193...
2008/09/18
[ "https://Stackoverflow.com/questions/93653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16003/" ]
I've got a stored procedure in my database, that looks like this ``` ALTER PROCEDURE [dbo].[GetCountingAnalysisResults] @RespondentFilters varchar AS BEGIN @RespondentFilters = '''8ec94bed-fed6-4627-8d45-21619331d82a, 114c61f2-8935-4755-b4e9-4a598a51cc7f''' DECLARE @SQL nvarchar(600) SET @SQL = 'SELECT * FROM Answer WHERE Answer.RespondentId IN ('+@RespondentFilters+''')) GROUP BY ChosenOptionId' exec sp_executesql @SQL END ``` It compiles and executes, but somehow it doesn't give me good results, just like the IN statement wasn't working. Please, if anybody know the solution to this problem, help me.
You need single quotes around each GUID in the list ``` @RespondentFilters = '''8ec94bed-fed6-4627-8d45-21619331d82a'', ''114c61f2-8935-4755-b4e9-4a598a51cc7f''' ```
93,672
<p>Is there a 7-Zip command-line switch that prevents the filenames from echoing to the screen as they are added to the archive?</p>
[ { "answer_id": 93702, "author": "freespace", "author_id": 8297, "author_profile": "https://Stackoverflow.com/users/8297", "pm_score": 1, "selected": false, "text": "<p>If it doesn't have one, you can still redirect the output using <code>&gt;</code> into a file, then deleting the file af...
2008/09/18
[ "https://Stackoverflow.com/questions/93672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7519/" ]
Is there a 7-Zip command-line switch that prevents the filenames from echoing to the screen as they are added to the archive?
Not built in, but if you add ``` <7z command here> 2>&1 NUL ``` to the end of your command-line, it will redirect all the output into the null device and stops it echoing to the screen. This is the MS-DOS equivalent of ``` 2>&1 /dev/null ``` in Linux and Unix systems.
93,695
<p>My users would like to be able to hit <kbd>Ctrl</kbd>+<kbd>S</kbd> to save a form. Is there a good cross-browser way of capturing the <kbd>Ctrl</kbd>+<kbd>S</kbd> key combination and submit my form?</p> <p>App is built on Drupal, so jQuery is available.</p>
[ { "answer_id": 93836, "author": "Jim", "author_id": 8427, "author_profile": "https://Stackoverflow.com/users/8427", "pm_score": 8, "selected": true, "text": "<pre><code>$(window).keypress(function(event) {\n if (!(event.which == 115 &amp;&amp; event.ctrlKey) &amp;&amp; !(event.which =...
2008/09/18
[ "https://Stackoverflow.com/questions/93695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1902010/" ]
My users would like to be able to hit `Ctrl`+`S` to save a form. Is there a good cross-browser way of capturing the `Ctrl`+`S` key combination and submit my form? App is built on Drupal, so jQuery is available.
``` $(window).keypress(function(event) { if (!(event.which == 115 && event.ctrlKey) && !(event.which == 19)) return true; alert("Ctrl-S pressed"); event.preventDefault(); return false; }); ``` Key codes can differ between browsers, so you may need to check for more than just 115.
93,716
<p>How can I hide the title bar from a Windows Form but still have a Resizing Frame?</p>
[ { "answer_id": 93721, "author": "Brian Gillespie", "author_id": 6151, "author_profile": "https://Stackoverflow.com/users/6151", "pm_score": 5, "selected": true, "text": "<p>Setting FormBorderStyle = None will remove the title bar (at both design and\nrun time) - and also remove your abil...
2008/09/18
[ "https://Stackoverflow.com/questions/93716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6151/" ]
How can I hide the title bar from a Windows Form but still have a Resizing Frame?
Setting FormBorderStyle = None will remove the title bar (at both design and run time) - and also remove your ability to resize the form. If you need a border you can set: ``` ControlBox = false Text = "" ```
93,720
<p><strong>How do I represent an aggregation relation between two classes in UML, such that each class has a link to the other class's interface, not the implementing class?</strong></p> <p>E.g. I have a class Foo that implements iFoo, and Bar that implements iBar. Foo should have a member variable of type iBar, and Bar should have a member variable of type iFoo.</p> <p>If I create an aggregation between the two implementing classes, then the member will be of the type of the implementing class, not the superclass. And aggregations between interfaces are invalid in UML (and don't make much sense).</p>
[ { "answer_id": 93721, "author": "Brian Gillespie", "author_id": 6151, "author_profile": "https://Stackoverflow.com/users/6151", "pm_score": 5, "selected": true, "text": "<p>Setting FormBorderStyle = None will remove the title bar (at both design and\nrun time) - and also remove your abil...
2008/09/18
[ "https://Stackoverflow.com/questions/93720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16399/" ]
**How do I represent an aggregation relation between two classes in UML, such that each class has a link to the other class's interface, not the implementing class?** E.g. I have a class Foo that implements iFoo, and Bar that implements iBar. Foo should have a member variable of type iBar, and Bar should have a member variable of type iFoo. If I create an aggregation between the two implementing classes, then the member will be of the type of the implementing class, not the superclass. And aggregations between interfaces are invalid in UML (and don't make much sense).
Setting FormBorderStyle = None will remove the title bar (at both design and run time) - and also remove your ability to resize the form. If you need a border you can set: ``` ControlBox = false Text = "" ```
93,728
<p>I want to do the following imports in a class.</p> <pre><code>import org.eclipse.jdt.core.dom.*; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.internal.compiler.ClassFile; import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.Compiler; import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies; import org.eclipse.jdt.internal.compiler.ICompilerRequestor; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.env.INameEnvironment; import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.BadLocationException; import org.eclipse.text.edits.TextEdit; </code></pre> <p>How can I import the JDT within Eclipse? Cheers.</p>
[ { "answer_id": 93820, "author": "delfuego", "author_id": 16414, "author_profile": "https://Stackoverflow.com/users/16414", "pm_score": 2, "selected": false, "text": "<p>Unless I'm misunderstanding you, you just need to include the JDT JAR files on your classpath; they're all available in...
2008/09/18
[ "https://Stackoverflow.com/questions/93728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5915/" ]
I want to do the following imports in a class. ``` import org.eclipse.jdt.core.dom.*; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.internal.compiler.ClassFile; import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.Compiler; import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies; import org.eclipse.jdt.internal.compiler.ICompilerRequestor; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.env.INameEnvironment; import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.BadLocationException; import org.eclipse.text.edits.TextEdit; ``` How can I import the JDT within Eclipse? Cheers.
I think I found an easier way to do this: * right-click on your project in the Package Explorer; * choose "Build Path..."; * choose "Configure Build Path"; * choose the Libraries tab; * click the "Add Variable..." button; * in the list box, choose the "ECLIPSE\_HOME" entry, and then click the "Extend" button; * in the list box, open up the "plugins" folder entry, scroll way down, and shift-click all the org.eclipse.jdt.\* JAR files that are in the file listing *beneath* the folders; * click OK until you're all the way back out. That should do it.
93,744
<p>For the life of me, I can't remember how to set, delete, toggle or test a bit in a bitfield. Either I'm unsure or I mix them up because I rarely need these. So a "bit-cheat-sheet" would be nice to have.</p> <p>For example: </p> <pre><code>flags = flags | FlagsEnum.Bit4; // Set bit 4. </code></pre> <p>or</p> <pre><code>if ((flags &amp; FlagsEnum.Bit4)) == FlagsEnum.Bit4) // Is there a less verbose way? </code></pre> <p>Can you give examples of all the other common operations, preferably in C# syntax using a [Flags] enum?</p>
[ { "answer_id": 93780, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": 1, "selected": false, "text": "<p>C++ operations are: &amp; | ^ ~ (for and, or, xor and not bitwise operations). Also of interest are >> and &lt;&lt;, wh...
2008/09/18
[ "https://Stackoverflow.com/questions/93744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15328/" ]
For the life of me, I can't remember how to set, delete, toggle or test a bit in a bitfield. Either I'm unsure or I mix them up because I rarely need these. So a "bit-cheat-sheet" would be nice to have. For example: ``` flags = flags | FlagsEnum.Bit4; // Set bit 4. ``` or ``` if ((flags & FlagsEnum.Bit4)) == FlagsEnum.Bit4) // Is there a less verbose way? ``` Can you give examples of all the other common operations, preferably in C# syntax using a [Flags] enum?
**I did some more work on these extensions - [You can find the code here](http://hugoware.net:4000/blog/enumeration-extensions-2-0)** I wrote some extension methods that extend System.Enum that I use often... I'm not claiming that they are bulletproof, but they have helped... *Comments removed...* ``` namespace Enum.Extensions { public static class EnumerationExtensions { public static bool Has<T>(this System.Enum type, T value) { try { return (((int)(object)type & (int)(object)value) == (int)(object)value); } catch { return false; } } public static bool Is<T>(this System.Enum type, T value) { try { return (int)(object)type == (int)(object)value; } catch { return false; } } public static T Add<T>(this System.Enum type, T value) { try { return (T)(object)(((int)(object)type | (int)(object)value)); } catch(Exception ex) { throw new ArgumentException( string.Format( "Could not append value from enumerated type '{0}'.", typeof(T).Name ), ex); } } public static T Remove<T>(this System.Enum type, T value) { try { return (T)(object)(((int)(object)type & ~(int)(object)value)); } catch (Exception ex) { throw new ArgumentException( string.Format( "Could not remove value from enumerated type '{0}'.", typeof(T).Name ), ex); } } } } ``` Then they are used like the following ``` SomeType value = SomeType.Grapes; bool isGrapes = value.Is(SomeType.Grapes); //true bool hasGrapes = value.Has(SomeType.Grapes); //true value = value.Add(SomeType.Oranges); value = value.Add(SomeType.Apples); value = value.Remove(SomeType.Grapes); bool hasOranges = value.Has(SomeType.Oranges); //true bool isApples = value.Is(SomeType.Apples); //false bool hasGrapes = value.Has(SomeType.Grapes); //false ```
93,767
<p>I am using the mootools based Rokbox plugin, on one of my sites, and I can't figure out how to close it with javascript.</p> <p>I triggered the click event on the close button, but that did not work.</p> <p>I found the code in the rokbox source that is used to add the click listener</p> <pre><code>this.closeButton.addEvent('click',function(e){new Event(e).stop();self.swtch=false;self.close(e)}); </code></pre> <p>but since it is minified i cannot find what "this" refers to</p>
[ { "answer_id": 94526, "author": "Aeon", "author_id": 13289, "author_profile": "https://Stackoverflow.com/users/13289", "pm_score": 1, "selected": false, "text": "<p>The <code>this</code> likely refers to the rokbox instance; I don't think you need to worry about it, you're interested in ...
2008/09/18
[ "https://Stackoverflow.com/questions/93767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am using the mootools based Rokbox plugin, on one of my sites, and I can't figure out how to close it with javascript. I triggered the click event on the close button, but that did not work. I found the code in the rokbox source that is used to add the click listener ``` this.closeButton.addEvent('click',function(e){new Event(e).stop();self.swtch=false;self.close(e)}); ``` but since it is minified i cannot find what "this" refers to
The `this` likely refers to the rokbox instance; I don't think you need to worry about it, you're interested in the code that runs on the click event. The salient part looks to be the following: ``` self.swtch=false; self.close(e); ``` `self` most likely refers to the rokbox instance, again, so assuming you instantiate it with something like ``` var rokbox = new RokBox(...); ``` you should be able to just call ``` rokbox.close(); ``` and have it close. I haven't looked at rokbox source, so no guarantees, and not quite sure what the `swtch=false` does, so you probably will need to experiment a bit.
93,770
<p>For deployment reasons, I am trying to use IJW to wrap a C# assembly in C++ instead of using a COM Callable Wrapper. </p> <p>I've done it on other projects, but on this one, I am getting an EEFileLoadException. Any help would be appreciated!</p> <p>Managed C++ wrapper code (this is in a DLL):</p> <pre><code>extern "C" __declspec(dllexport) IMyObject* CreateMyObject(void) { //this class references c# in the constructor return new CMyWrapper( ); } extern "C" __declspec(dllexport) void DeleteMyObject(IMyObject* pConfigFile) { delete pConfigFile; } extern "C" __declspec(dllexport) void TestFunction(void) { ::MessageBox(NULL, _T("My Message Box"), _T("Test"), MB_OK); } </code></pre> <p>Test Code (this is an EXE):</p> <pre><code>typedef void* (*CreateObjectPtr)(); typedef void (*TestFunctionPtr)(); int _tmain testwrapper(int argc, TCHAR* argv[], TCHAR* envp[]) { HMODULE hModule = ::LoadLibrary(_T("MyWrapper")); _ASSERT(hModule != NULL); PVOID pFunc1 = ::GetProcAddress(hModule, "TestFunction"); _ASSERT(pFunc1 != NULL); TestFunctionPtr pTest = (TestFunctionPtr)pFunc1; PVOID pFunc2 = ::GetProcAddress(hModule, "CreateMyObject"); _ASSERT(pFunc2 != NULL); CreateObjectPtr pCreateObjectFunc = (CreateObjectPtr)pFunc2; (*pTest)(); //this successfully pops up a message box (*pCreateObjectFunc)(); //this tosses an EEFileLoadException return 0; } </code></pre> <p>For what it's worth, the Event Log reports the following: .NET Runtime version 2.0.50727.143 - Fatal Execution Engine Error (79F97075) (80131506)</p> <p>Unfortunately, Microsoft has no information on that error.</p>
[ { "answer_id": 94320, "author": "Adam Tegen", "author_id": 4066, "author_profile": "https://Stackoverflow.com/users/4066", "pm_score": 4, "selected": false, "text": "<p>The first issue is to make sure the Debugger type is set to mixed. Then you get useful exceptions.</p>\n" }, { ...
2008/09/18
[ "https://Stackoverflow.com/questions/93770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4066/" ]
For deployment reasons, I am trying to use IJW to wrap a C# assembly in C++ instead of using a COM Callable Wrapper. I've done it on other projects, but on this one, I am getting an EEFileLoadException. Any help would be appreciated! Managed C++ wrapper code (this is in a DLL): ``` extern "C" __declspec(dllexport) IMyObject* CreateMyObject(void) { //this class references c# in the constructor return new CMyWrapper( ); } extern "C" __declspec(dllexport) void DeleteMyObject(IMyObject* pConfigFile) { delete pConfigFile; } extern "C" __declspec(dllexport) void TestFunction(void) { ::MessageBox(NULL, _T("My Message Box"), _T("Test"), MB_OK); } ``` Test Code (this is an EXE): ``` typedef void* (*CreateObjectPtr)(); typedef void (*TestFunctionPtr)(); int _tmain testwrapper(int argc, TCHAR* argv[], TCHAR* envp[]) { HMODULE hModule = ::LoadLibrary(_T("MyWrapper")); _ASSERT(hModule != NULL); PVOID pFunc1 = ::GetProcAddress(hModule, "TestFunction"); _ASSERT(pFunc1 != NULL); TestFunctionPtr pTest = (TestFunctionPtr)pFunc1; PVOID pFunc2 = ::GetProcAddress(hModule, "CreateMyObject"); _ASSERT(pFunc2 != NULL); CreateObjectPtr pCreateObjectFunc = (CreateObjectPtr)pFunc2; (*pTest)(); //this successfully pops up a message box (*pCreateObjectFunc)(); //this tosses an EEFileLoadException return 0; } ``` For what it's worth, the Event Log reports the following: .NET Runtime version 2.0.50727.143 - Fatal Execution Engine Error (79F97075) (80131506) Unfortunately, Microsoft has no information on that error.
The problem was where the DLLs were located. * c:\dlls\managed.dll * c:\dlls\wrapper.dll * c:\exe\my.exe I confirmed this by copying managed.dll into c:\exe and it worked without issue. Apparently, the CLR won't look for managed DLLs in the path of the unmanaged DLL and will only look for it where the executable is. (or in the GAC). For reasons not worth going into, this is the structure I need, which meant that I needed to give the CLR a hand in located the managed dll. See code below: AssemblyResolver.h: ``` /// <summary> /// Summary for AssemblyResolver /// </summary> public ref class AssemblyResolver { public: static Assembly^ MyResolveEventHandler( Object^ sender, ResolveEventArgs^ args ) { Console::WriteLine( "Resolving..." ); Assembly^ thisAssembly = Assembly::GetExecutingAssembly(); String^ thisPath = thisAssembly->Location; String^ directory = Path::GetDirectoryName(thisPath); String^ pathToManagedAssembly = Path::Combine(directory, "managed.dll"); Assembly^ newAssembly = Assembly::LoadFile(pathToManagedAssembly); return newAssembly; } }; ``` Wrapper.cpp: ``` #include "AssemblyResolver.h" extern "C" __declspec(dllexport) IMyObject* CreateMyObject(void) { try { AppDomain^ currentDomain = AppDomain::CurrentDomain; currentDomain->AssemblyResolve += gcnew ResolveEventHandler( AssemblyResolver::MyResolveEventHandler ); return new CMyWrapper( ); } catch(System::Exception^ e) { System::Console::WriteLine(e->Message); return NULL; } } ```
93,832
<p>What is the preferred way to open a URL from a thick client application on Windows using C# and the .NET framework? I want it to use the default browser.</p>
[ { "answer_id": 93862, "author": "Matthias Meid", "author_id": 17713, "author_profile": "https://Stackoverflow.com/users/17713", "pm_score": 2, "selected": false, "text": "<p>I'd use the <a href=\"https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.start#System_Diagnos...
2008/09/18
[ "https://Stackoverflow.com/questions/93832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17891/" ]
What is the preferred way to open a URL from a thick client application on Windows using C# and the .NET framework? I want it to use the default browser.
The following code surely works: ``` Process.Start("http://www.yoururl.com/Blah.aspx"); ``` It opens the default browser (technically, the default program that handles HTTP URIs).
93,839
<p>If you have binary strings (literally String objects that contain only 1's and 0's), how would you output them as bits into a file?</p> <p>This is for a text compressor I was working on; it's still bugging me, and it'd be nice to finally get it working. Thanks!</p>
[ { "answer_id": 93889, "author": "Tomer Gabel", "author_id": 11558, "author_profile": "https://Stackoverflow.com/users/11558", "pm_score": 4, "selected": true, "text": "<p>Easiest is to simply take 8 consecutive characters, turn them into a byte and output that byte. Pad with zeros at the...
2008/09/18
[ "https://Stackoverflow.com/questions/93839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6833/" ]
If you have binary strings (literally String objects that contain only 1's and 0's), how would you output them as bits into a file? This is for a text compressor I was working on; it's still bugging me, and it'd be nice to finally get it working. Thanks!
Easiest is to simply take 8 consecutive characters, turn them into a byte and output that byte. Pad with zeros at the end if you can recognize the end-of-stream, or add a header with length (in bits) at the beginning of the file. The inner loop would look something like: ``` byte[] buffer = new byte[ ( string.length + 7 ) / 8 ]; for ( int i = 0; i < buffer.length; ++i ) { byte current = 0; for ( int j = 7; j >= 0; --j ) if ( string[ i * 8 + j ] == '1' ) current |= 1 << j; output( current ); } ``` You'll need to make some adjustments, but that's the general idea.
93,853
<p>I have seen this problem arise in many different circumstances and would like to get the best practices for fixing / debugging it on StackOverflow.</p> <p>To use a real world example this occurred to me this morning:</p> <pre><code>expected announcement.rb to define Announcement </code></pre> <p>The class worked fine in development, testing <em>and</em> from a production console, but failed from in a production Mongrel. Here's the class:</p> <pre><code>class Announcement &lt; ActiveRecord::Base has_attachment :content_type =&gt; 'audio/mp3', :storage =&gt; :s3 end </code></pre> <p>The issue I would like addressed in the answers is not so much solving this specific problem, but how to properly debug to get Rails to give you a meaningful error as expected x.rb to define X.rb' is often a red herring...</p> <p><strong>Edit (3 great responses so far, each w/ a partial solution</strong>)</p> <p><strong>Debugging:</strong></p> <ol> <li><p>From Joe Van Dyk: Try accessing the model via a console on the environment / instance that is causing the error (in the case above: script/console production then type in 'Announcement'.</p></li> <li><p>From Otto: Try setting a minimal plugin set via an initializer, eg: config.plugins = [ :exception_notification, :ssl_requirement, :all ] then re-enable one at a time.</p></li> </ol> <p><strong>Specific causes:</strong></p> <ol> <li><p>From Ian Terrell: if you're using attachment_fu make sure you have the correct image processor installed. attachment_fu will require it even if you aren't attaching an image.</p></li> <li><p>From Otto: make sure you didn't name a model that conflicts with a built-in Rails class, eg: Request.</p></li> <li><p>From Josh Lewis: make sure you don't have duplicated class or module names somewhere in your application (or Gem list).</p></li> </ol>
[ { "answer_id": 94243, "author": "Joe Van Dyk", "author_id": 17076, "author_profile": "https://Stackoverflow.com/users/17076", "pm_score": 5, "selected": true, "text": "<p>That is a tricky one. </p>\n\n<p>What generally works for me is to run \"script/console production\" on the producti...
2008/09/18
[ "https://Stackoverflow.com/questions/93853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4748/" ]
I have seen this problem arise in many different circumstances and would like to get the best practices for fixing / debugging it on StackOverflow. To use a real world example this occurred to me this morning: ``` expected announcement.rb to define Announcement ``` The class worked fine in development, testing *and* from a production console, but failed from in a production Mongrel. Here's the class: ``` class Announcement < ActiveRecord::Base has_attachment :content_type => 'audio/mp3', :storage => :s3 end ``` The issue I would like addressed in the answers is not so much solving this specific problem, but how to properly debug to get Rails to give you a meaningful error as expected x.rb to define X.rb' is often a red herring... **Edit (3 great responses so far, each w/ a partial solution**) **Debugging:** 1. From Joe Van Dyk: Try accessing the model via a console on the environment / instance that is causing the error (in the case above: script/console production then type in 'Announcement'. 2. From Otto: Try setting a minimal plugin set via an initializer, eg: config.plugins = [ :exception\_notification, :ssl\_requirement, :all ] then re-enable one at a time. **Specific causes:** 1. From Ian Terrell: if you're using attachment\_fu make sure you have the correct image processor installed. attachment\_fu will require it even if you aren't attaching an image. 2. From Otto: make sure you didn't name a model that conflicts with a built-in Rails class, eg: Request. 3. From Josh Lewis: make sure you don't have duplicated class or module names somewhere in your application (or Gem list).
That is a tricky one. What generally works for me is to run "script/console production" on the production server, and type in: `Announcement` That will usually give you a better error message. But you said you already tried that?
93,888
<p>By default the session expiry seems to be 20 minutes. </p> <p>Update: I do not want the session to expire until the browser is closed.</p> <p>Update2: This is my scenario. User logs into site. Plays around the site. Leaves computer to go for a shower (>20 mins ;)). Comes back to computer and <em>should</em> be able to play around. He closes browser, which deletes session cookie. The next time he comes to the site from a new browser instance, he would need to login again.</p> <p>In PHP I can set session.cookie_lifetime in php.ini to zero to achieve this. </p>
[ { "answer_id": 93907, "author": "Thomas Jespersen", "author_id": 8547, "author_profile": "https://Stackoverflow.com/users/8547", "pm_score": 1, "selected": false, "text": "<p>This is default. When you have a session, it stores the session in a \"Session Cookie\", which is automatically d...
2008/09/18
[ "https://Stackoverflow.com/questions/93888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17404/" ]
By default the session expiry seems to be 20 minutes. Update: I do not want the session to expire until the browser is closed. Update2: This is my scenario. User logs into site. Plays around the site. Leaves computer to go for a shower (>20 mins ;)). Comes back to computer and *should* be able to play around. He closes browser, which deletes session cookie. The next time he comes to the site from a new browser instance, he would need to login again. In PHP I can set session.cookie\_lifetime in php.ini to zero to achieve this.
If you want to extend the session beyond 20 minutes, you change the default using the IIS admin or you can set it in the web.config file. For example, to set the timeout to 60 minutes in web.config: ``` <configuration> <system.web> <sessionState timeout="60" /> ... other elements omitted ... </system.web> ... other elements omitted .... </configuration> ``` You can do the same for a particular user in code with: ``` Session.Timeout = 60 ``` Whichever method you choose, you can change the timeout to whatever value you think is reasonable to allow your users to do other things and still maintain their session. There are downsides of course: for the user, there is the possible security issue of leaving their browser unattended and having it still logged in when someone else starts to use it. For you there is the issue of memory usage on the server - the longer sessions last, the more memory you'll be using at any one time. Whether or not that matters depends on the load on your server. If you don't want to guesstimate a reasonable extended timeout, you'll need to use one of the other techniques already suggested, requiring some JavaScript running in the browser to ping the server periodically and/or abandon the session when a page is unloaded (provided the user isn't going to another page on your site, of course).
93,932
<p>We are getting an error in a VB6 application that sends data back and forth over TCP sockets. We get a runtime error "out of string space". Has anyone seen this or have any thoughts on why this would happen? It seems like we are hitting some VB6 threshhold so any other thoughts would be helpful as well.</p>
[ { "answer_id": 94043, "author": "Robit", "author_id": 17026, "author_profile": "https://Stackoverflow.com/users/17026", "pm_score": 2, "selected": false, "text": "<p>Text found on MSDN:</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/aa264524(VS.60).aspx\" rel=\"nofollow nore...
2008/09/18
[ "https://Stackoverflow.com/questions/93932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
We are getting an error in a VB6 application that sends data back and forth over TCP sockets. We get a runtime error "out of string space". Has anyone seen this or have any thoughts on why this would happen? It seems like we are hitting some VB6 threshhold so any other thoughts would be helpful as well.
As others have pointed out, every string concatenation in VB will allocate a new string and then copy the data over and then de-allocate the original once it can. In a loop this can cause issues. To work around this you can create a simple StringBuilder class like this one: ``` Option Explicit Private data As String Private allocLen As Long Private currentPos As Long Public Function Text() As String Text = Left(data, currentPos) End Function Public Function Length() As Long Length = currentPos End Function Public Sub Add(s As String) Dim newLen As Long newLen = Len(s) If ((currentPos + newLen) > allocLen) Then data = data & Space((currentPos + newLen)) allocLen = Len(data) End If Mid(data, currentPos + 1, newLen) = s currentPos = currentPos + newLen End Sub Private Sub Class_Initialize() data = Space(10240) allocLen = Len(data) currentPos = 1 End Sub ``` This class will minimize the number of string allocations by forcing the string to be built with spaces in it and then overwriting the spaces as needed. It re-allocates to roughly double its size when it finds that it does not have enough space pre-initialized. The Text method will return the portion of the string that is actually used.
93,976
<p>How do you check if a one-character String is a letter - including any letters with accents?</p> <p>I had to work this out recently, so I'll answer it myself, after the recent VB6 question reminded me.</p>
[ { "answer_id": 93979, "author": "Peter Hilton", "author_id": 2670, "author_profile": "https://Stackoverflow.com/users/2670", "pm_score": 6, "selected": true, "text": "<p>Just checking if a letter is in A-Z because that doesn't include letters with accents or letters in other alphabets.</...
2008/09/18
[ "https://Stackoverflow.com/questions/93976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2670/" ]
How do you check if a one-character String is a letter - including any letters with accents? I had to work this out recently, so I'll answer it myself, after the recent VB6 question reminded me.
Just checking if a letter is in A-Z because that doesn't include letters with accents or letters in other alphabets. I found out that you can use the regular expression class for 'Unicode letter', or one of its case-sensitive variations: ``` string.matches("\\p{L}"); // Unicode letter string.matches("\\p{Lu}"); // Unicode upper-case letter ``` You can also do this with *Character* class: ``` Character.isLetter(character); ``` but that is less convenient if you need to check more than one letter.
93,983
<p>How can I take the string <code>foo[]=1&amp;foo[]=5&amp;foo[]=2</code> and return a collection with the values <code>1,5,2</code> in that order. I am looking for an answer using regex in C#. Thanks</p>
[ { "answer_id": 94009, "author": "jjnguy", "author_id": 2598, "author_profile": "https://Stackoverflow.com/users/2598", "pm_score": 1, "selected": false, "text": "<p>I don't know C#, but...</p>\n\n<p>In java:</p>\n\n<pre><code>String[] nums = String.split(yourString, \"&amp;?foo[]\");\n</...
2008/09/18
[ "https://Stackoverflow.com/questions/93983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17872/" ]
How can I take the string `foo[]=1&foo[]=5&foo[]=2` and return a collection with the values `1,5,2` in that order. I am looking for an answer using regex in C#. Thanks
In C# you can use capturing groups ``` private void RegexTest() { String input = "foo[]=1&foo[]=5&foo[]=2"; String pattern = @"foo\[\]=(\d+)"; Regex regex = new Regex(pattern); foreach (Match match in regex.Matches(input)) { Console.Out.WriteLine(match.Groups[1]); } } ```
93,989
<p>In .NET, what's the best way to prevent multiple instances of an app from running at the same time? And if there's no "best" technique, what are some of the caveats to consider with each solution?</p>
[ { "answer_id": 94005, "author": "Aaron Jensen", "author_id": 11229, "author_profile": "https://Stackoverflow.com/users/11229", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://en.csharp-online.net/Application_Architecture_in_Windows_Forms_2.0\" rel=\"nofollow noreferrer\">h...
2008/09/18
[ "https://Stackoverflow.com/questions/93989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5682/" ]
In .NET, what's the best way to prevent multiple instances of an app from running at the same time? And if there's no "best" technique, what are some of the caveats to consider with each solution?
Use Mutex. One of the examples above using GetProcessByName has many caveats. Here is a good article on the subject: <http://odetocode.com/Blogs/scott/archive/2004/08/20/401.aspx> ``` [STAThread] static void Main() { using(Mutex mutex = new Mutex(false, "Global\\" + appGuid)) { if(!mutex.WaitOne(0, false)) { MessageBox.Show("Instance already running"); return; } Application.Run(new Form1()); } } private static string appGuid = "c0a76b5a-12ab-45c5-b9d9-d693faa6e7b9"; ```
94,011
<p>Here is my problem: I've got a dialog with some parameters that the user can change (via a spinner for example). Each time one of these parameters is changed, I launch a thread to update a 3D view according to the new parameter value. If the user changes another value (or the same value again by clicking many times on the spinner arrow) while the first thread is working, I would like to abort the first thread (and the update of the 3D view) and launch a new one with the latest parameter value.</p> <p>How can I do something like that?</p> <p>PS: There is no loop in the <code>run()</code> method of my thread, so checking for a flag is not an option: the thread updating the 3D view basically only calls a single method that is very long to execute. I can't add any flag in this method asking to abort either as I do not have access to its code.</p>
[ { "answer_id": 94031, "author": "Dave L.", "author_id": 3093, "author_profile": "https://Stackoverflow.com/users/3093", "pm_score": 3, "selected": false, "text": "<p>The thread that is updating the 3D view should periodically check some flag (use a <code>volatile boolean</code>) to see i...
2008/09/18
[ "https://Stackoverflow.com/questions/94011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2612/" ]
Here is my problem: I've got a dialog with some parameters that the user can change (via a spinner for example). Each time one of these parameters is changed, I launch a thread to update a 3D view according to the new parameter value. If the user changes another value (or the same value again by clicking many times on the spinner arrow) while the first thread is working, I would like to abort the first thread (and the update of the 3D view) and launch a new one with the latest parameter value. How can I do something like that? PS: There is no loop in the `run()` method of my thread, so checking for a flag is not an option: the thread updating the 3D view basically only calls a single method that is very long to execute. I can't add any flag in this method asking to abort either as I do not have access to its code.
Try interrupt() as some have said to see if it makes any difference to your thread. If not, try destroying or closing a resource that will make the thread stop. That has a chance of being a little better than trying to throw Thread.stop() at it. If performance is tolerable, you might view each 3D update as a discrete non-interruptible event and just let it run through to conclusion, checking afterward if there's a new latest update to perform. This might make the GUI a little choppy to users, as they would be able to make five changes, then see the graphical results from how things were five changes ago, then see the result of their latest change. But depending on how long this process is, it might be tolerable, and it would avoid having to kill the thread. Design might look like this: ``` boolean stopFlag = false; Object[] latestArgs = null; public void run() { while (!stopFlag) { if (latestArgs != null) { Object[] args = latestArgs; latestArgs = null; perform3dUpdate(args); } else { Thread.sleep(500); } } } public void endThread() { stopFlag = true; } public void updateSettings(Object[] args) { latestArgs = args; } ```
94,023
<p>I came across a controller in an older set of code (Rails 1.2.3) that had the following in a controller:</p> <pre><code>class GenericController &gt; ApplicationController # filters and such model :some_model </code></pre> <p>Although the name of the model does not match the name of the model, is there any reason to specify this? Or is this something that has disappeared from later versions of Rails?</p>
[ { "answer_id": 94040, "author": "Joe Van Dyk", "author_id": 17076, "author_profile": "https://Stackoverflow.com/users/17076", "pm_score": 1, "selected": false, "text": "<p>Yes, that is something that has disappeared in later versions of Rails. There is no need to specify it.</p>\n" },...
2008/09/18
[ "https://Stackoverflow.com/questions/94023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13710/" ]
I came across a controller in an older set of code (Rails 1.2.3) that had the following in a controller: ``` class GenericController > ApplicationController # filters and such model :some_model ``` Although the name of the model does not match the name of the model, is there any reason to specify this? Or is this something that has disappeared from later versions of Rails?
This had to do with dependency injection. I don't recall the details. By now it's just a glorified `require`, which you don't need because rails auto-requires files for missing constants.
94,037
<p>How can I convert a character to its ASCII code using JavaScript?</p> <p>For example:</p> <blockquote> <p>get 10 from &quot;\n&quot;.</p> </blockquote>
[ { "answer_id": 94049, "author": "Jim", "author_id": 8427, "author_profile": "https://Stackoverflow.com/users/8427", "pm_score": 12, "selected": true, "text": "<pre><code>\"\\n\".charCodeAt(0);\n</code></pre>\n" }, { "answer_id": 9539389, "author": "Mohsen", "author_id": 6...
2008/09/18
[ "https://Stackoverflow.com/questions/94037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4465/" ]
How can I convert a character to its ASCII code using JavaScript? For example: > > get 10 from "\n". > > >
``` "\n".charCodeAt(0); ```
94,053
<p>For ASP.Net application deployment what type of information (if any) are you storing in the machine.config? </p> <p>If you're not using it, how are you managing environment specific configuration settings that may change for each environment?</p> <p>I'm looking for some "best practices" and the benefits/pitfalls of each. We're about to deploy a brand new application to production in two months and I've got some latitude in these types of decisions. I want to make sure that I'm approaching things in the best way possible and attempting to avoid shooting myself in the foot at a later date. </p> <p>FYI We're using it (machine.config) currently for just the DB connection information and storing all other variables that might change in a config table in the database.</p>
[ { "answer_id": 94152, "author": "Jesse C. Slicer", "author_id": 3312, "author_profile": "https://Stackoverflow.com/users/3312", "pm_score": 2, "selected": false, "text": "<p>I use machine.config for not just ASP.NET, but for overall config as well. I implemented a hash algorithm (Tiger)...
2008/09/18
[ "https://Stackoverflow.com/questions/94053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
For ASP.Net application deployment what type of information (if any) are you storing in the machine.config? If you're not using it, how are you managing environment specific configuration settings that may change for each environment? I'm looking for some "best practices" and the benefits/pitfalls of each. We're about to deploy a brand new application to production in two months and I've got some latitude in these types of decisions. I want to make sure that I'm approaching things in the best way possible and attempting to avoid shooting myself in the foot at a later date. FYI We're using it (machine.config) currently for just the DB connection information and storing all other variables that might change in a config table in the database.
We are considering using machine.config to add one key for the environment, and then have one section in the web.config which is excactly the same for all environments. This way we can do a "real" XCopy deployment. E.g. in the machine.config for every computer (local dev workstations, stage servers, build servers, production servers), we'll add the following: ``` <appSettings> <add key="Environment" value="Staging"/> </appSettings> ``` Then, any configuration element that is environment-specific gets the environment appended, like so: ``` <connectionStrings> <add name="Customers.Staging" provider="..." connectionString="..."/> </connectionStrings> <appSettings> <add key="NTDomain.Staging" value="test.mydomain.com"/> </appSettings> ``` One problem that we don't have a solution for is how to enable say tracing in web.config for debugging environment and not for live environment. Another problem is that the live connectionstring incl. username and password is now in your Source Control system. This is however not a problem for us.
94,074
<p>I'm using wget to connect to a secure site like this:</p> <p><code>wget -nc -i inputFile</code></p> <p>where inputeFile consists of URLs like this:</p> <p><code><a href="https://clientWebsite.com/TheirPageName.asp?orderValue=1.00&amp;merchantID=36&amp;programmeID=92&amp;ref=foo&amp;Ofaz=0" rel="nofollow noreferrer">https://clientWebsite.com/TheirPageName.asp?orderValue=1.00&amp;merchantID=36&amp;programmeID=92&amp;ref=foo&amp;Ofaz=0</a></code></p> <p>This page returns a small gif file. For some reason, this is taking around 2.5 minutes. When I paste the same URL into a browser, I get back a response within seconds. </p> <p>Does anyone have any idea what could be causing this?</p> <p>The version of wget, by the way, is "GNU Wget 1.9+cvs-stable (Red Hat modified)"</p>
[ { "answer_id": 94100, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 3, "selected": false, "text": "<ol>\n<li><p>Try forging your UserAgent</p>\n\n<pre><code>-U \"Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-GB; rv:1.9...
2008/09/18
[ "https://Stackoverflow.com/questions/94074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm using wget to connect to a secure site like this: `wget -nc -i inputFile` where inputeFile consists of URLs like this: `<https://clientWebsite.com/TheirPageName.asp?orderValue=1.00&merchantID=36&programmeID=92&ref=foo&Ofaz=0>` This page returns a small gif file. For some reason, this is taking around 2.5 minutes. When I paste the same URL into a browser, I get back a response within seconds. Does anyone have any idea what could be causing this? The version of wget, by the way, is "GNU Wget 1.9+cvs-stable (Red Hat modified)"
1. Try forging your UserAgent ``` -U "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-GB; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1" ``` 2. Disable Ceritificate Checking ( slow ) ``` --no-check-certificate ``` 3. Debug whats happening by enabling verbostity ``` -v ``` 4. Eliminate need for DNS lookups: Hardcode thier IP address in your HOSTS file ``` /etc/hosts 123.122.121.120 foo.bar.com ```
94,123
<p>I'm working on a webapp, and every so often we run into situations where pages will load without applying CSS. This problem has shown up in IE6, IE7, Safari 3, and FF3.</p> <p>A page refresh will always fix the problem.</p> <p>There are 3 CSS files loaded, all within the same style block using @import:</p> <pre><code>&lt;STYLE type="text/css"&gt; @import url([base css file]); @import url([skin css file]); @import url([generated css path]); &lt;/STYLE&gt; </code></pre> <p>In any situation when we take the time to examine the html source, nothing is out of the ordinary. Access logs seem normal as well - we're getting HTTP 304 responses for the static CSS files whenever they are requested, and an HTTP 200 response for our generated CSS.</p> <p>The mimetype is text/css for the css files and the generated css. We're using an iPlanet server, which forwards requests to a Tomcat server.</p> <p>davebug asked: </p> <blockquote> <p>Is it always the same css file not loading, or is the problem with all of them, evenly?</p> </blockquote> <p>None of the CSS files load. Any styles defined within the HTML work fine, but nothing in any of the CSS files works when this happens.</p>
[ { "answer_id": 94166, "author": "Joe Van Dyk", "author_id": 17076, "author_profile": "https://Stackoverflow.com/users/17076", "pm_score": -1, "selected": false, "text": "<p>Use ab or httperf or curl or something to repeatedly load the CSS files from the webserver. Perhaps it's not consi...
2008/09/18
[ "https://Stackoverflow.com/questions/94123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17887/" ]
I'm working on a webapp, and every so often we run into situations where pages will load without applying CSS. This problem has shown up in IE6, IE7, Safari 3, and FF3. A page refresh will always fix the problem. There are 3 CSS files loaded, all within the same style block using @import: ``` <STYLE type="text/css"> @import url([base css file]); @import url([skin css file]); @import url([generated css path]); </STYLE> ``` In any situation when we take the time to examine the html source, nothing is out of the ordinary. Access logs seem normal as well - we're getting HTTP 304 responses for the static CSS files whenever they are requested, and an HTTP 200 response for our generated CSS. The mimetype is text/css for the css files and the generated css. We're using an iPlanet server, which forwards requests to a Tomcat server. davebug asked: > > Is it always the same css file not loading, or is the problem with all of them, evenly? > > > None of the CSS files load. Any styles defined within the HTML work fine, but nothing in any of the CSS files works when this happens.
I've had a similar thing happen that I was able to fix by including a base style sheet first using the "link rel" method rather than "@import". i.e. move your [base css file] inclusion to: ``` <link rel="stylesheet" href="[base css file]" type="text/css" media="screen" /> ``` and put it before the others.
94,141
<p>I have the following script, where the first and third <code>document.writeline</code> are static and <strong>the second is generated</strong>:</p> <pre><code>&lt;script language="javascript" type="text/javascript"&gt; document.write("&lt;script language='javascript' type='text/javascript' src='before.js'&gt;&lt;\/sc" + "ript&gt;"); document.write("&lt;script language='javascript' type='text/javascript'&gt;alert('during');&lt;\/sc" + "ript&gt;"); document.write("&lt;script language='javascript' type='text/javascript' src='after.js'&gt;&lt;\/sc" + "ript&gt;"); &lt;/script&gt; </code></pre> <p>Firefox and Chrome will display <em>before</em>, <em>during</em> and <em>after</em>, while Internet Explorer first shows <em>during</em> and only then does it show <em>before</em> and <em>after</em>.</p> <p>I've come across <a href="http://www.elctech.com/blog/nesting-document-write" rel="noreferrer">an article that states</a> that I'm not the first to encounter this, but that hardly makes me feel any better.</p> <p><strong>Does anyone know how I can set the order to be deterministic in all browsers, or hack IE to work like all the other, sane browsers do?</strong></p> <p><strong>Caveats</strong>: The code snippet is a very simple repro. It is generated on the server and the second script is the only thing that changes. It's a long script and the reason there are two scripts before and after it are so that the browser will cache them and the dynamic part of the code will be as small as possible. It may also appears many times in the same page with different generated code.</p>
[ { "answer_id": 94328, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 1, "selected": false, "text": "<p>Slides 25/26 of <a href=\"http://sites.google.com/site/io/even-faster-web-sites\" rel=\"nofollow noreferrer\">this presen...
2008/09/18
[ "https://Stackoverflow.com/questions/94141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4979/" ]
I have the following script, where the first and third `document.writeline` are static and **the second is generated**: ``` <script language="javascript" type="text/javascript"> document.write("<script language='javascript' type='text/javascript' src='before.js'><\/sc" + "ript>"); document.write("<script language='javascript' type='text/javascript'>alert('during');<\/sc" + "ript>"); document.write("<script language='javascript' type='text/javascript' src='after.js'><\/sc" + "ript>"); </script> ``` Firefox and Chrome will display *before*, *during* and *after*, while Internet Explorer first shows *during* and only then does it show *before* and *after*. I've come across [an article that states](http://www.elctech.com/blog/nesting-document-write) that I'm not the first to encounter this, but that hardly makes me feel any better. **Does anyone know how I can set the order to be deterministic in all browsers, or hack IE to work like all the other, sane browsers do?** **Caveats**: The code snippet is a very simple repro. It is generated on the server and the second script is the only thing that changes. It's a long script and the reason there are two scripts before and after it are so that the browser will cache them and the dynamic part of the code will be as small as possible. It may also appears many times in the same page with different generated code.
I've found an answer more to my liking: ``` <script language="javascript" type="text/javascript"> document.write("<script language='javascript' type='text/javascript' src='before.js'><\/sc" + "ript>"); document.write("<script defer language='javascript' type='text/javascript'>alert('during');<\/sc" + "ript>"); document.write("<script defer language='javascript' type='text/javascript' src='after.js'><\/sc" + "ript>"); </script> ``` This will defer the loading of both *during* and *after* until the page has finished loading. I think this is as good as I can get. Hopefully, someone will be able to give a better answer.
94,153
<p>I am attempting to use the 'tempfile' module for manipulating and creating text files. Once the file is ready I want to save it to disk. I thought it would be as simple as using 'shutil.copy'. However, I get a 'permission denied' IOError:</p> <pre><code>&gt;&gt;&gt; import tempfile, shutil &gt;&gt;&gt; f = tempfile.TemporaryFile(mode ='w+t') &gt;&gt;&gt; f.write('foo') &gt;&gt;&gt; shutil.copy(f.name, 'bar.txt') Traceback (most recent call last): File "&lt;pyshell#5&gt;", line 1, in &lt;module&gt; shutil.copy(f.name, 'bar.txt') File "C:\Python25\lib\shutil.py", line 80, in copy copyfile(src, dst) File "C:\Python25\lib\shutil.py", line 46, in copyfile fsrc = open(src, 'rb') IOError: [Errno 13] Permission denied: 'c:\\docume~1\\me\\locals~1\\temp\\tmpvqq3go' &gt;&gt;&gt; </code></pre> <p>Is this not intended when using the 'tempfile' library? Is there a better way to do this? (Maybe I am overlooking something very trivial)</p>
[ { "answer_id": 94206, "author": "Hans Sjunnesson", "author_id": 8683, "author_profile": "https://Stackoverflow.com/users/8683", "pm_score": 3, "selected": false, "text": "<p>You could always use <em>shutil.copyfileobj</em>, in your example:</p>\n\n<pre><code>new_file = open('bar.txt', 'r...
2008/09/18
[ "https://Stackoverflow.com/questions/94153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
I am attempting to use the 'tempfile' module for manipulating and creating text files. Once the file is ready I want to save it to disk. I thought it would be as simple as using 'shutil.copy'. However, I get a 'permission denied' IOError: ``` >>> import tempfile, shutil >>> f = tempfile.TemporaryFile(mode ='w+t') >>> f.write('foo') >>> shutil.copy(f.name, 'bar.txt') Traceback (most recent call last): File "<pyshell#5>", line 1, in <module> shutil.copy(f.name, 'bar.txt') File "C:\Python25\lib\shutil.py", line 80, in copy copyfile(src, dst) File "C:\Python25\lib\shutil.py", line 46, in copyfile fsrc = open(src, 'rb') IOError: [Errno 13] Permission denied: 'c:\\docume~1\\me\\locals~1\\temp\\tmpvqq3go' >>> ``` Is this not intended when using the 'tempfile' library? Is there a better way to do this? (Maybe I am overlooking something very trivial)
The file you create with `TemporaryFile` or `NamedTemporaryFile` is automatically removed when it's closed, which is why you get an error. If you don't want this, you can use `mkstemp` instead (see the docs for [tempfile](https://docs.python.org/3/library/tempfile.html#tempfile.mkstemp)). ``` >>> import tempfile, shutil, os >>> fd, path = tempfile.mkstemp() >>> os.write(fd, 'foo') >>> os.close(fd) >>> shutil.copy(path, 'bar.txt') >>> os.remove(path) ```
94,154
<p>I'm trying to configure the Quick Launch menu to only display the ancestors and descendant nodes of the currently select node. The menu also needs to display all the childern of the root node. More simply:</p> <p>Given a site map of:</p> <p><strong>RootSite</strong></p> <p>---<strong>SubSite1</strong> = navigation set at "Display the current site, the navigation items below the current site, and the current site's siblings"</p> <p>-----<strong>Heading1</strong> = navigation set at "Display the same navigation items as the parent site"</p> <p>-------<strong>Page1</strong> = navigation set at "Display the same navigation items as the parent site"</p> <p>-------<strong>Page2</strong> = navigation set at "Display the same navigation items as the parent site"</p> <p>-----<strong>Heading2</strong> = navigation set at "Display the same navigation items as the parent site"</p> <p>---<strong>SubSite2</strong> = navigation set at "Display the current site, the navigation items below the current site, and the current site's siblings"</p> <p>-----<strong>Heading1</strong> = navigation set at "Display the same navigation items as the parent site"</p> <p>SiteMapProvider configuration:</p> <pre><code>&lt;PublishingNavigation:PortalSiteMapDataSource ID="SiteMapDS" Runat="server" SiteMapProvider="CurrentNavSiteMapProvider" EnableViewState="true" StartFromCurrentNode="true" ShowStartingNode="false"/&gt; </code></pre> <p>The expected and actual behavior of the Quick Launch menu displayed at SubSite1 is:</p> <p>---SubSite1</p> <p>-----Heading1</p> <p>-------Page1</p> <p>-------Page2</p> <p>-----Heading2</p> <p>---SubSite2</p> <p>The expected behavior of the menu after navigating to Heading1 of SubSite2:</p> <p>---SubSite1</p> <p>---SubSite2</p> <p>-----Heading1</p> <p>What I actually see after navigating to Heading1 of SubSite2:</p> <p>---SubSite1</p> <p>-----Heading1</p> <p>-------Page1</p> <p>-------Page2</p> <p>-----Heading2</p> <p>---SubSite2</p> <p>-----Heading1</p> <p>This does not match what I expect to see if I set the Heading1 navigation to "Display the same navigation items as the parent site" and SubSite2 is set to "Display the current site, the navigation items below the current site, and the current site's siblings". I expect Heading1 to inherit the navigation item of SubSite2 with the SubSite1 items collapsed from view. I've also played with the various Trim... attributes without success. Any help will be greatly appreciated!</p>
[ { "answer_id": 98428, "author": "Nat", "author_id": 13813, "author_profile": "https://Stackoverflow.com/users/13813", "pm_score": 1, "selected": false, "text": "<p>I personally don't like the html that the default menu provides (table based layout).\nFortunately the SharePoint team has r...
2008/09/18
[ "https://Stackoverflow.com/questions/94154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9711/" ]
I'm trying to configure the Quick Launch menu to only display the ancestors and descendant nodes of the currently select node. The menu also needs to display all the childern of the root node. More simply: Given a site map of: **RootSite** ---**SubSite1** = navigation set at "Display the current site, the navigation items below the current site, and the current site's siblings" -----**Heading1** = navigation set at "Display the same navigation items as the parent site" -------**Page1** = navigation set at "Display the same navigation items as the parent site" -------**Page2** = navigation set at "Display the same navigation items as the parent site" -----**Heading2** = navigation set at "Display the same navigation items as the parent site" ---**SubSite2** = navigation set at "Display the current site, the navigation items below the current site, and the current site's siblings" -----**Heading1** = navigation set at "Display the same navigation items as the parent site" SiteMapProvider configuration: ``` <PublishingNavigation:PortalSiteMapDataSource ID="SiteMapDS" Runat="server" SiteMapProvider="CurrentNavSiteMapProvider" EnableViewState="true" StartFromCurrentNode="true" ShowStartingNode="false"/> ``` The expected and actual behavior of the Quick Launch menu displayed at SubSite1 is: ---SubSite1 -----Heading1 -------Page1 -------Page2 -----Heading2 ---SubSite2 The expected behavior of the menu after navigating to Heading1 of SubSite2: ---SubSite1 ---SubSite2 -----Heading1 What I actually see after navigating to Heading1 of SubSite2: ---SubSite1 -----Heading1 -------Page1 -------Page2 -----Heading2 ---SubSite2 -----Heading1 This does not match what I expect to see if I set the Heading1 navigation to "Display the same navigation items as the parent site" and SubSite2 is set to "Display the current site, the navigation items below the current site, and the current site's siblings". I expect Heading1 to inherit the navigation item of SubSite2 with the SubSite1 items collapsed from view. I've also played with the various Trim... attributes without success. Any help will be greatly appreciated!
I followed @Nat's guidance into the murky world Sharepoint webparts to achieve the behavior I described above. My approach was to roll my own version of the [MossMenu webpart](http://blogs.msdn.com/ecm/archive/2006/12/02/customizing-the-wss-3-0-moss-2007-menu-control-mossmenu-source-code-released.aspx "MossMenu webpart") that Microsoft has released through the ECM Team Blog. This code is based on the native AspMenu control. I used this control to "intercept" the native SiteMapDataSource injected into through DataSourceId attribute in the markup and create a new XML data source to exhibit the desired behavior. I've included the final source code at the end of this wordy answer. Here are the bits from the master page markup: ``` <%@ Register TagPrefix="myCustom" Namespace="YourCompany.CustomWebParts" Assembly="YourCompany.CustomWebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" %> ... <myCustom:MossMenu ID="CurrentNav" runat="server" datasourceID="SiteMapDS" orientation="Vertical" UseCompactMenus="true" StaticDisplayLevels="6" MaximumDynamicDisplayLevels="0" StaticSubMenuIndent="5" ItemWrap="false" AccessKey="3" CssClass="leftNav" SkipLinkText="<%$Resources:cms,masterpages_skiplinktext%>"> <LevelMenuItemStyles> <asp:MenuItemStyle CssClass="Nav" /> <asp:MenuItemStyle CssClass="SecNav" /> </LevelMenuItemStyles> <StaticHoverStyle CssClass="leftNavHover"/> <StaticSelectedStyle CssClass="leftNavSelected"/> <DynamicMenuStyle CssClass="leftNavFlyOuts" /> <DynamicMenuItemStyle CssClass="leftNavFlyOutsItem"/> <DynamicHoverStyle CssClass="leftNavFlyOutsHover"/> </myCustom:MossMenu> <PublishingNavigation:PortalSiteMapDataSource ID="SiteMapDS" Runat="server" SiteMapProvider="CurrentNavSiteMapProvider" EnableViewState="true" StartFromCurrentNode="true" ShowStartingNode="false"/> ... ``` I followed the excellent step-by-step instructions to create my custom web part in the comments section of the [MossMenu webpart](http://blogs.msdn.com/ecm/archive/2006/12/02/customizing-the-wss-3-0-moss-2007-menu-control-mossmenu-source-code-released.aspx "MossMenu webpart") at "Wednesday, September 19, 2007 7:20 AM by Roel". In my googling, I also found something to configure a Sharepoint site to display exceptions in the same lovely way that ASP.NET does by making the web.config changes [here](http://blog.thekid.me.uk/archive/2007/02/15/a-solution-to-quot-an-unexpected-error-has-occurred-quot-in-wss-v3.aspx). I decided to call my custom behavior a "compact menu" so I created a UseCompactMenus property on the control. If you don't set this attribute in the markup to true, the control will behave identically to an AspMenu control. My application has the user always starting from the home page at the site map root. I can have the custom control store the initial (complete) site map when the root page is displayed. This is stored in a static string for use in the customizing behavior. If you application doesn't follow this assumption, the control will not work as expected. On the initial application page, only the direct child pages to the root page are displayed in the menu. Clicking on these menu nodes will open all the child nodes under it but keeps the sibling nodes "closed". If you click on one of the other sibling nodes, it collapses the current node and it opens the newly selected node. That's it, enjoy!! ``` using System; using System.Text; using System.ComponentModel; using System.Collections.Generic; using System.Security.Permissions; using System.Xml; using System.Xml.Serialization; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.Design.WebControls; using Microsoft.SharePoint; using Microsoft.SharePoint.Utilities; using Microsoft.SharePoint.Security; namespace YourCompany.CustomWebParts { [AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] [SharePointPermission(SecurityAction.LinkDemand, ObjectModel = true)] [SharePointPermission(SecurityAction.InheritanceDemand, ObjectModel = true)] [Designer(typeof(MossMenuDesigner))] [ToolboxData("<{0}:MossMenu runat=\"server\" />")] public class MossMenu : System.Web.UI.WebControls.Menu { private string idPrefix; // a url->menuItem dictionary private Dictionary<string, System.Web.UI.WebControls.MenuItem> menuItemDictionary = new Dictionary<string, System.Web.UI.WebControls.MenuItem>(StringComparer.OrdinalIgnoreCase); private bool customSelectionEnabled = true; private bool selectStaticItemsOnly = true; private bool performTargetBinding = true; //** Variables used for compact menu behavior **// private bool useCompactMenus = false; private static bool showStartingNode; private static string originalSiteMap; /// <summary> /// Controls whether or not the control performs compacting of the site map to display only ancestor and child nodes of the selected and first level root childern. /// </summary> [Category("Behavior")] public bool UseCompactMenus { get { return this.useCompactMenus; } set { this.useCompactMenus = value; } } /// <summary> /// Controls whether or not the control performs custom selection/highlighting. /// </summary> [Category("Behavior")] public bool CustomSelectionEnabled { get { return this.customSelectionEnabled; } set { this.customSelectionEnabled = value; } } /// <summary> /// Controls whether only static items may be selected or if /// dynamic (fly-out) items may be selected too. /// </summary> [Category("Behavior")] public bool SelectStaticItemsOnly { get { return this.selectStaticItemsOnly; } set { this.selectStaticItemsOnly = value; } } /// <summary> /// Controls whether or not to bind the Target property of any menu /// items to the Target property in the SiteMapNode's Attributes /// collection. /// </summary> [Category("Behavior")] public bool PerformTargetBinding { get { return this.performTargetBinding; } set { this.performTargetBinding = value; } } /// <summary> /// Gets the ClientID of this control. /// </summary> public override string ClientID { [SharePointPermission(SecurityAction.Demand, ObjectModel = true)] get { if (this.idPrefix == null) { this.idPrefix = SPUtility.GetNewIdPrefix(this.Context); } return SPUtility.GetShortId(this.idPrefix, this); } } [SharePointPermission(SecurityAction.Demand, ObjectModel = true)] protected override void OnMenuItemDataBound(MenuEventArgs e) { base.OnMenuItemDataBound(e); if (this.customSelectionEnabled) { // store in the url->item dictionary this.menuItemDictionary[e.Item.NavigateUrl] = e.Item; } if (this.performTargetBinding) { // try to bind to the Target property if the data item is a SiteMapNode SiteMapNode smn = e.Item.DataItem as SiteMapNode; if (smn != null) { string target = smn["Target"]; if (!string.IsNullOrEmpty(target)) { e.Item.Target = target; } } } } /// <id guid="08e034e7-5872-4a31-a771-84cac1dcd53d" /> /// <owner alias="MarkWal"> /// </owner> [SharePointPermission(SecurityAction.Demand, ObjectModel = true)] protected override void OnPreRender(System.EventArgs e) { SiteMapDataSource dataSource = this.GetDataSource() as SiteMapDataSource; SiteMapProvider provider = (dataSource != null) ? dataSource.Provider : null; if (useCompactMenus && dataSource != null && provider != null) { showStartingNode = dataSource.ShowStartingNode; SiteMapNodeCollection rootChildNodes = provider.RootNode.ChildNodes; if (provider.CurrentNode.Equals(provider.RootNode)) { //** Store original site map for future use in compacting menus **// if (originalSiteMap == null) { //Store original SiteMapXML for future adjustments: XmlDocument newSiteMapDoc = new XmlDocument(); newSiteMapDoc.LoadXml("<?xml version='1.0' ?>" + "<siteMapNode title='" + provider.RootNode.Title + "' url='" + provider.RootNode.Url + "' />"); foreach (SiteMapNode node in rootChildNodes) { XmlNode newNode = GetXmlSiteMapNode(newSiteMapDoc.DocumentElement, node); newSiteMapDoc.DocumentElement.AppendChild(newNode); //Create XML for all the child nodes for selected menu item: NavigateSiteMap(newNode, node); } originalSiteMap = newSiteMapDoc.OuterXml; } //This is set to only display the child nodes of the root node on first view: this.StaticDisplayLevels = 1; } else { // //Adjust site map for this page // XmlDocument newSiteMapDoc = InitializeNewSiteMapXml(provider, rootChildNodes); //Clear the current default site map: this.DataSourceID = null; //Create the new site map data source XmlDataSource newSiteMap = new XmlDataSource(); newSiteMap.ID = "XmlDataSource1"; newSiteMap.EnableCaching = false; //Required to prevent redisplay of the previous menu //Add bindings for dynamic site map: MenuItemBindingCollection bindings = this.DataBindings; bindings.Clear(); MenuItemBinding binding = new MenuItemBinding(); binding.DataMember = "siteMapNode"; binding.TextField = "title"; binding.Text = "title"; binding.NavigateUrlField = "url"; binding.NavigateUrl = "url"; binding.ValueField = "url"; binding.Value = "url"; bindings.Add(binding); //Bind menu to new site map: this.DataSource = newSiteMap; //Assign the newly created dynamic site map: ((XmlDataSource)this.DataSource).Data = newSiteMapDoc.OuterXml; /** this expression removes the root if initialized: **/ if (!showStartingNode) ((XmlDataSource)this.DataSource).XPath = "/siteMapNode/siteMapNode"; /** Re-initialize menu data source with new site map: **/ this.DataBind(); /** Find depth of current node: **/ int depth = 0; SiteMapNode currNode = provider.CurrentNode; do { depth++; currNode = currNode.ParentNode; } while (currNode != null); //Set the StaticDisplayLevels to match the current depth: if (depth >= this.StaticDisplayLevels) this.StaticDisplayLevels = depth; } } base.OnPreRender(e); // output some script to override the default menu flyout behaviour; this helps to avoid // intermittent "Operation Aborted" errors Page.ClientScript.RegisterStartupScript( typeof(MossMenu), "overrideMenu_HoverStatic", "if (typeof(overrideMenu_HoverStatic) == 'function' && typeof(Menu_HoverStatic) == 'function')\n" + "{\n" + "_spBodyOnLoadFunctionNames.push('enableFlyoutsAfterDelay');\n" + "Menu_HoverStatic = overrideMenu_HoverStatic;\n" + "}\n", true); // output some script to avoid a known issue with SSL Termination and the ASP.NET // Menu implementation. http://support.microsoft.com/?id=910444 Page.ClientScript.RegisterStartupScript( typeof(MossMenu), "MenuHttpsWorkaround_" + this.ClientID, this.ClientID + "_Data.iframeUrl='/_layouts/images/blank.gif';", true); // adjust the fly-out indicator arrow direction for locale if not already set if (this.Orientation == System.Web.UI.WebControls.Orientation.Vertical && ((string.IsNullOrEmpty(this.StaticPopOutImageUrl) && this.StaticEnableDefaultPopOutImage) || (string.IsNullOrEmpty(this.DynamicPopOutImageUrl) && this.DynamicEnableDefaultPopOutImage))) { SPWeb currentWeb = SPContext.Current.Web; if (currentWeb != null) { uint localeId = currentWeb.Language; bool isBidiWeb = SPUtility.IsRightToLeft(currentWeb, currentWeb.Language); string arrowUrl = "/_layouts/images/" + (isBidiWeb ? "largearrowleft.gif" : "largearrowright.gif"); if (string.IsNullOrEmpty(this.StaticPopOutImageUrl) && this.StaticEnableDefaultPopOutImage) { this.StaticPopOutImageUrl = arrowUrl; } if (string.IsNullOrEmpty(this.DynamicPopOutImageUrl) && this.DynamicEnableDefaultPopOutImage) { this.DynamicPopOutImageUrl = arrowUrl; } } } if (provider == null) { // if we're not attached to a SiteMapDataSource we'll just leave everything alone return; } else if (this.customSelectionEnabled) { MenuItem selectedMenuItem = this.SelectedItem; SiteMapNode currentNode = provider.CurrentNode; // if no menu item is presently selected, we need to work our way up from the current // node until we can find a node in the menu item dictionary while (selectedMenuItem == null && currentNode != null) { this.menuItemDictionary.TryGetValue(currentNode.Url, out selectedMenuItem); currentNode = currentNode.ParentNode; } if (this.selectStaticItemsOnly) { // only static items may be selected, keep moving up until we find an item // that falls within the static range while (selectedMenuItem != null && selectedMenuItem.Depth >= this.StaticDisplayLevels) { selectedMenuItem = selectedMenuItem.Parent; } // if we found an item to select, go ahead and select (highlight) it if (selectedMenuItem != null && selectedMenuItem.Selectable) { selectedMenuItem.Selected = true; } } } } private XmlDocument InitializeNewSiteMapXml(SiteMapProvider provider, SiteMapNodeCollection rootChildNodes) { /** Find the level 1 ancestor node of the current node: **/ SiteMapNode levelOneAncestorOfSelectedNode = null; SiteMapNode currNode = provider.CurrentNode; do { levelOneAncestorOfSelectedNode = (currNode.ParentNode == null ? levelOneAncestorOfSelectedNode : currNode); currNode = currNode.ParentNode; } while (currNode != null); /** Initialize base SiteMapXML **/ XmlDocument newSiteMapDoc = new XmlDocument(); newSiteMapDoc.LoadXml(originalSiteMap); /** Prune out the childern nodes that shouldn't display: **/ currNode = provider.CurrentNode; do { if (currNode.ParentNode != null) { SiteMapNodeCollection currNodeSiblings = currNode.ParentNode.ChildNodes; foreach (SiteMapNode siblingNode in currNodeSiblings) { if (siblingNode.HasChildNodes) { if (provider.CurrentNode.Equals(siblingNode)) { //Remove all the childerns child nodes from display: SiteMapNodeCollection currNodesChildren = siblingNode.ChildNodes; foreach (SiteMapNode childNode in currNodesChildren) { XmlNode currentXmNode = GetCurrentXmlNode(newSiteMapDoc, childNode); DeleteChildNodes(currentXmNode); } } else if (!provider.CurrentNode.IsDescendantOf(siblingNode) && !levelOneAncestorOfSelectedNode.Equals(siblingNode)) { XmlNode currentXmNode = GetCurrentXmlNode(newSiteMapDoc, siblingNode); DeleteChildNodes(currentXmNode); } } } } currNode = currNode.ParentNode; } while (currNode != null); return newSiteMapDoc; } private XmlNode GetCurrentXmlNode(XmlDocument newSiteMapDoc, SiteMapNode node) { //Find this node in the original site map: XmlNode currentXmNode = newSiteMapDoc.DocumentElement.SelectSingleNode( "//siteMapNode[@url='" + node.Url + "']"); return currentXmNode; } private void DeleteChildNodes(XmlNode currentXmNode) { if (currentXmNode != null && currentXmNode.HasChildNodes) { //Remove child nodes: XmlNodeList xmlNodes = currentXmNode.ChildNodes; int lastNodeIndex = xmlNodes.Count - 1; for (int i = lastNodeIndex; i >= 0; i--) { currentXmNode.RemoveChild(xmlNodes[i]); } } } private XmlNode GetXmlSiteMapNode(XmlNode currentDocumentNode, SiteMapNode currentNode) { XmlElement newNode = currentDocumentNode.OwnerDocument.CreateElement("siteMapNode"); XmlAttribute newAttr = currentDocumentNode.OwnerDocument.CreateAttribute("title"); newAttr.InnerText = currentNode.Title; newNode.Attributes.Append(newAttr); newAttr = currentDocumentNode.OwnerDocument.CreateAttribute("url"); newAttr.InnerText = currentNode.Url; newNode.Attributes.Append(newAttr); return newNode; } private void NavigateSiteMap(XmlNode currentDocumentNode, SiteMapNode currentNode) { foreach (SiteMapNode node in currentNode.ChildNodes) { //Add this node to structure: XmlNode newNode = GetXmlSiteMapNode(currentDocumentNode, node); currentDocumentNode.AppendChild(newNode); if (node.HasChildNodes) { //Make a recursive call to add any child nodes: NavigateSiteMap(newNode, node); } } } } [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2117:AptcaTypesShouldOnlyExtendAptcaBaseTypes")] public sealed class MossMenuDesigner : MenuDesigner { [PermissionSet(SecurityAction.Demand, Name = "FullTrust")] protected override void DataBind(BaseDataBoundControl dataBoundControl) { try { dataBoundControl.DataBind(); } catch { base.DataBind(dataBoundControl); } } [PermissionSet(SecurityAction.Demand, Name = "FullTrust")] public override string GetDesignTimeHtml() { System.Web.UI.WebControls.Menu menu = (System.Web.UI.WebControls.Menu)ViewControl; int oldDisplayLevels = menu.MaximumDynamicDisplayLevels; string designTimeHtml = string.Empty; try { menu.MaximumDynamicDisplayLevels = 0; // ASP.NET MenuDesigner has some dynamic/static item trick in design time // to show dynamic item in design time. We only want to show preview without // dynamic menu items. designTimeHtml = base.GetDesignTimeHtml(); } catch (Exception e) { designTimeHtml = GetErrorDesignTimeHtml(e); } finally { menu.MaximumDynamicDisplayLevels = oldDisplayLevels; } return designTimeHtml; } } } ```
94,161
<p>I'm working on a project that will be distributed with GNU autoconf/automake, and I have a set of bash scripts which call awk scripts. I would like the bash scripts to end up in the $PATH, but not the awk scripts. How should I insert these into the project? Should they be put in with other binaries?</p> <p>Also, is there a way to determine the final location of the file after installation? I presume that /usr/local/bin isn't <em>always</em> where the executables end up...</p>
[ { "answer_id": 94259, "author": "terminus", "author_id": 9232, "author_profile": "https://Stackoverflow.com/users/9232", "pm_score": 3, "selected": true, "text": "<p>Add something like this to Makefile.am</p>\n\n<pre><code>scriptsdir = $(prefix)/bin\nscripts_DATA = awkscript1 awkscript2\...
2008/09/18
[ "https://Stackoverflow.com/questions/94161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17925/" ]
I'm working on a project that will be distributed with GNU autoconf/automake, and I have a set of bash scripts which call awk scripts. I would like the bash scripts to end up in the $PATH, but not the awk scripts. How should I insert these into the project? Should they be put in with other binaries? Also, is there a way to determine the final location of the file after installation? I presume that /usr/local/bin isn't *always* where the executables end up...
Add something like this to Makefile.am ``` scriptsdir = $(prefix)/bin scripts_DATA = awkscript1 awkscript2 ``` In this case it will install awkscript in $(prefix)/bin (you can also use $(bindir)). Note: Dont forget that the first should be named name + dir (scripts -> scriptsdir) and the second should be name + \_DATA (scripts -> scripts\_DATA).
94,171
<p>In C#.Net WPF During UserControl.Load -></p> <p>What is the best way of showing a whirling circle / 'Loading' Indicator on the UserControl until it has finished gathering data and rendering it's contents?</p>
[ { "answer_id": 95143, "author": "dcstraw", "author_id": 10391, "author_profile": "https://Stackoverflow.com/users/10391", "pm_score": 5, "selected": true, "text": "<p>I generally would create a layout like this:</p>\n\n<pre><code>&lt;Grid&gt;\n &lt;Grid x:Name=\"MainContent\" IsEnable...
2008/09/18
[ "https://Stackoverflow.com/questions/94171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/352728/" ]
In C#.Net WPF During UserControl.Load -> What is the best way of showing a whirling circle / 'Loading' Indicator on the UserControl until it has finished gathering data and rendering it's contents?
I generally would create a layout like this: ``` <Grid> <Grid x:Name="MainContent" IsEnabled="False"> ... </Grid> <Grid x:Name="LoadingIndicatorPanel"> ... </Grid> </Grid> ``` Then I load the data on a worker thread, and when it's finished I update the UI under the "MainContent" grid and enable the grid, then set the LoadingIndicatorPanel's Visibility to Collapsed. I'm not sure if this is what you were asking or if you wanted to know how to show an animation in the loading label. If it's the animation you're after, please update your question to be more specific.
94,177
<p>I have the following XAML: </p> <pre><code>&lt;TextBlock Text="{Binding ElementName=EditListBox, Path=SelectedItems.Count}" Margin="0,0,5,0"/&gt; &lt;TextBlock Text="items selected"&gt; &lt;TextBlock.Style&gt; &lt;Style TargetType="{x:Type TextBlock}"&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding ElementName=EditListBox, Path=SelectedItems.Count}" Value="1"&gt; &lt;Setter Property="TextBlock.Text" Value="item selected"&gt;&lt;/Setter&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/TextBlock.Style&gt; &lt;/TextBlock&gt; </code></pre> <p>The first text block happily changes with SelectedItems.Count, showing 0,1,2, etc. The datatrigger on the second block never seems to fire to change the text.</p> <p>Any thoughts?</p>
[ { "answer_id": 94690, "author": "Alan Le", "author_id": 1133, "author_profile": "https://Stackoverflow.com/users/1133", "pm_score": 5, "selected": true, "text": "<p>The DataTrigger is firing but the Text field for your second TextBlock is hard-coded as \"items selected\" so it won't be a...
2008/09/18
[ "https://Stackoverflow.com/questions/94177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2284/" ]
I have the following XAML: ``` <TextBlock Text="{Binding ElementName=EditListBox, Path=SelectedItems.Count}" Margin="0,0,5,0"/> <TextBlock Text="items selected"> <TextBlock.Style> <Style TargetType="{x:Type TextBlock}"> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=EditListBox, Path=SelectedItems.Count}" Value="1"> <Setter Property="TextBlock.Text" Value="item selected"></Setter> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> ``` The first text block happily changes with SelectedItems.Count, showing 0,1,2, etc. The datatrigger on the second block never seems to fire to change the text. Any thoughts?
The DataTrigger is firing but the Text field for your second TextBlock is hard-coded as "items selected" so it won't be able to change. To see it firing, you can remove Text="items selected". Your problem is a good candidate for using a **ValueConverter** instead of **DataTrigger**. Here's how to create and use the ValueConverter to get it to set the Text to what you want. **Create this ValueConverter:** ``` public class CountToSelectedTextConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if ((int)value == 1) return "item selected"; else return "items selected"; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion } ``` **Add the namespace reference to your the assembly the converter is located:** ``` xmlns:local="clr-namespace:ValueConverterExample" ``` **Add the converter to your resources:** ``` <Window.Resources> <local:CountToSelectedTextConverter x:Key="CountToSelectedTextConverter"/> </Window.Resources> ``` **Change your second textblock to:** ``` <TextBlock Text="{Binding ElementName=EditListBox, Path=SelectedItems.Count, Converter={StaticResource CountToSelectedTextConverter}}"/> ```
94,263
<p>When constructing an ArgumentException, a couple of the overloads take a string that is the invalid argument's parameter name. I figure it would be nice to not have to remember to update this ctor param whenever I change the method's param name. Is there a simple way to do this using reflection?</p> <p><strong>Update:</strong> thanks to the 2 respondents so far. You both answer the question well, but the solution still leaves me with a maintenance headache. (Okay, a <strong>tiny</strong> headache, but still...) To explain, if I were to <em>reorder</em> the params later -- or remove an earlier param -- I'd have to remember to change my exception-construction code again. Is there a way I can use something along the lines of</p> <pre><code>Object.ReferenceEquals(myParam, &lt;insert code here&gt;) </code></pre> <p>to be sure I'm dealing with the relevant parameter? That way, the compiler would step in to prevent me badly constructing the exception.</p> <p>That said, I'm starting to suspect that the "simple" part of the original question not that forthcoming. Maybe I should just put up with using string literals. :)</p>
[ { "answer_id": 94300, "author": "Brian", "author_id": 1750627, "author_profile": "https://Stackoverflow.com/users/1750627", "pm_score": 3, "selected": true, "text": "<p>You can use either Modules or RSL.</p>\n\n<p>RSLs have the advantage of getting cached by flash rather than the browser...
2008/09/18
[ "https://Stackoverflow.com/questions/94263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8705/" ]
When constructing an ArgumentException, a couple of the overloads take a string that is the invalid argument's parameter name. I figure it would be nice to not have to remember to update this ctor param whenever I change the method's param name. Is there a simple way to do this using reflection? **Update:** thanks to the 2 respondents so far. You both answer the question well, but the solution still leaves me with a maintenance headache. (Okay, a **tiny** headache, but still...) To explain, if I were to *reorder* the params later -- or remove an earlier param -- I'd have to remember to change my exception-construction code again. Is there a way I can use something along the lines of ``` Object.ReferenceEquals(myParam, <insert code here>) ``` to be sure I'm dealing with the relevant parameter? That way, the compiler would step in to prevent me badly constructing the exception. That said, I'm starting to suspect that the "simple" part of the original question not that forthcoming. Maybe I should just put up with using string literals. :)
You can use either Modules or RSL. RSLs have the advantage of getting cached by flash rather than the browser so they stick around longer. Modules are easier to create and use. I have used modules and had issues with modules failing to load (code needs to handle that case). I haven't tried RSLs yet. Here is some documentation on creating RSLs <http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:Flex_3_RSLs>