I'm working on a method that parses through a html source file, and puts coldfusion comments around script tags. My problem is that the String.Input method is not working with the line read from my streamreader. When using the debugger, it hits the .Input(index, string) line, but it does actually change my string. I think this is because the line is in a stream, but I'm not sure. I know there is a programmatically simple workaround for this, but I haven't done it in so long that I can't remember. Suggestions please - my code is as follows:
privatevoid outputnoscript(StreamReader reader, StreamWriter writer)
string line = "";
int opencounter = 0;
int closecounter = 0;
line = reader.ReadLine();
MatchCollection opencollection = Regex.Matches(line, "<script",RegexOptions.IgnoreCase);
for (int i = 0; i < opencollection.Count; i++)
//insert a <!--- at the position in the current match, +5 for every <!--- already inserted
Match openmatch = opencollection[i];
line.Insert(openmatch.Index + opencounter, "<!---");
opencounter += 5;
MatchCollection closecollection = Regex.Matches(line, "/script>", RegexOptions.IgnoreCase);
for (int i = 0; i < closecollection.Count; i++)
//insert a ---> at the position in the current match, +4 for every ---> already inserted
Match closematch = closecollection[i];
//plus 8 is to accomodate for the fact that regex returns the position of "/" in "/script>"
line.Insert(closematch.Index + 8 + closecounter, "--->");
closecounter += 4;
There is no Input member of the String class, but looking at your code I assume you mean Insert.
Strings are immutable. Performing an operation on a string does not change the string itself, but changes a copy of the string and returns it. So, either use something like string s = line.Insert(...) and write that using writer.WriteLine, or use a StringBuilder which is a mutable string.
Is it just me or did Microsoft leave out a nice feature like allowing datagrid hyperlink columns for Windows Forms projects??? It's easy to do in ASP........
I've looked all over for someone who has succeeded to create a dataGrid.dataColumn hyperlink. I'm not using a database, just importing a firewall.txt file and sorting the IP's looking for duplicate access attempts. The idea is to simply click on the questionable IP and jump to arin.net for a quick look, however............ help......
Ok, I'm sure there's an easy answer to this... I just can't figure this out? DUH..
I have a main application (form) that brings up a different form. What I want to do, is to detect ANY click while this new form is up. If the click is OUTSIDE the bounds of this form, I want to perform some action (such as closing the form). Any ideas?
If you're just wanting to monitor mouse messages for a short period of time (such as for a popup/menu), you can set the form's Capture property to true. This will redirect all mouse messages to your window. After the first click outside of your window, the mouse capture will be released and you won't get any more mouse messages from outside your form.
Other windows, including child windows on your form, will not recieve any mouse messages while your form has the mouse capture. If you need child windows to recieve mouse messages, release the capture when the mouse moves within your form's bounds.
Note that it is bad practice to capture the mouse for more than just a brief period/operation, as the mouse pointer is a shared system resource.
"A people that values its privileges above its principles soon loses both." -- Dwight D. Eisenhower
Well, a maybe simpler way could be to add an event handler for the Leave or Deactivate event.
The moment the user clicks outside your form it's losing focus and this event can be caught and handled.
But you have to remember that when you close the form yourself then these events are generated as well IIRC.
And that switching the window by using Alt-TAB for example also triggers this event, not just mouse clicks.
If your application uses a message queue (i.e., a Windows Forms application), you can use SendKeys.Send("+"), otherwise use SendKeys.SendWait("+") (which you could also use in a Windows Forms application if you'd like). This sends a message for the SHIFT key, a safe key to wake-up the machine (and stop the screensaver, unless the particular screensaver doesn't simply quit with certain key strokes or mouse movement).
Ok got a big problem. I have a brand new machine..i.e I rebuilt it and now I want to run a web project that references some C++ assemblies and some C# assemblies. I have done everything by the book but I keep getting the same error:
Parser Error Message: File or assembly name Core.Data.TM1, or one of its dependencies, was not found.
With the trace as follows:
=== Pre-bind state information ===
LOG: DisplayName = Core.Data.TM1
LOG: Appbase = file:///c:/inetpub/wwwroot/TMJTester
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: Core.Data.TM1
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/tmjtester/51fb5434/c4dfe5c7/Core.Data.TM1.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/tmjtester/51fb5434/c4dfe5c7/Core.Data.TM1/Core.Data.TM1.DLL.
LOG: Attempting download of new URL file:///c:/inetpub/wwwroot/TMJTester/bin/Core.Data.TM1.DLL.
LOG: Publisher policy file is not found.
LOG: No redirect found in host configuration file (C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet.config).
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: Core.Data.TM1, Version=188.8.131.52, Culture=neutral, PublicKeyToken=4c3e63d723dc8458
sameer handa wrote: I have done everything by the book but I keep getting the same error
And what book is that? Make sure that your assemblies are strongly named, and it's best to intall them into the GAC. There are known problems with using signed files in the private path (bin sub-directory by default for ASP.NET). The .NET service pack documentation claims this is by design, however.
If you need additional help, please be specific about how you have set up your ASP.NET Web Application. I.e., where are your assemblies (remember that the PATH environment variable matters not) and are they strongly named?
The fusion log above just states that an assembly cannot be found so it is searching for redirects and in common locations. All that means is that the assembly cannot be found.
Believe - when developed and deployed correctly (i.e., typically into the GAC) .NET assemblies do end DLL hell. I recommend you read the section How the Runtime Locates Assemblies[^] in the .NET Framework SDK - the only "book" I ever follow.
Thanks in part to your verbal smackdown I was inspired to read the SDK last night. Sometimes...reading the big C# book is not the same as reading the SDK.
Anyway I think I am close to finding the problem.....The problem is that in the Temporary ASP.NET Files directory there is a file being created called
__AssemblyInfo__.ini which has "wrong" information i.e it has the wrong
PublicKeyToken=4c3e63d723dc8458. Not quite sure where it is getting this information and I say this simply because it is my 3rd day here and I am not that familar with the code and set up yet.
So if yuo have any ideas on where I could start may be good.
I'm sorry you view it as a "verbal smackdown" - it wasn't intended as such.
Make sure the correct assembly is installed into the GAC. If your putting signed assemblies into the bin sub-directory (it works, but you may have problems when the AppDomain is recreated due to changes in the web application). This is done for you automatically if you add references to other assemblies (besides those already in the GAC, or those with "Copy Local" set to "True") or projects in your solution.
I also recommend you shutdown the web site(s), clear the Temporary ASP.NET Files" directory, and restart the web site(s). This should recreate all information once you have everything in place correctly as I described above.
I have 2 questions, and answering either will easily solve a problem.
The first, where might I find the lovely bitmaps and such that Microsoft uses in their operating system so that I can use these same ones in my application? Particularly, the arrow button that you see at the ends of slider bars and combo boxes.
If I have a combobox with nothing in its list, and I click the dropdown button, how can I prevent the list from showing one blank line?
See the ControlPaint.DrawComboButton method in the .NET Framework SDK for one option. Otherwise, you'll need to include bitmaps yourself, either embedding them into a ResX file (using an ImageList in the designer does this for you, which base64-encodes it) or embed them as manifest resources by adding them to your project and changing the build action to "Embedded Resource". You can access these bitmaps (which I use generically for pixel map images) using Assembly.GetManifestResourceStream or some methods on the Image and Bitmap classes allow you to specify a manifest resource from which an Image or Bitmap (derivative of Image) is created.
It's important to understand that most of the Windows Forms controls are not implement in .NET, per se. They encapsulate the Windows Common Controls, so it's the native window classes that are being used and which take care of drawing themselves (for the most part).
It's not supposed to fire. As I've tried to remind those in this forum many times, most of the Windows Forms controls encapsulate the Windows Common Controls. The TextBox encapsulates (wraps) the Edit control, which paints itself and cannot be overridden as many other controls can (like the Static class, which is encapsulated in the Label class). Even the ListView doesn't work the same with the call to OnPaint. In order to custom draw items, you have to handle the right notification messages.
That third parameter should not use out, mind you - it should be marshaled as an [out] param using the OutAttribute only, otherwise the CLR will crash. See the Platform SDK for usage, but it's really pretty easy to do. To easily allocate a string of a certain size, you can use new string('\0', size) or declare those as StringBuilders and modify your source accordingly.
Then you can parse and include these in your CookieContainer for use with the HttpWebRequest.
I was wondering if there is way for me to set current input language using C# (not Windows settings)... for instance whenever user focues my form I want to set current language to, let's say Spanish.
Anyone can help?
And... yes; I presume that languages are installed but it would be good if in response would be included a hint to where can I see how to detect currently installed languages on computer and do little validation.
Last Visit: 31-Dec-99 18:00 Last Update: 6-Oct-22 1:41