|
Check out the Process class. (Docs on MSDN[^])
Process.Start("C:\\mypath\myexe.exe", "myargs /moreargs");
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Can any one of you let me know, how can I replace a pattern in an html file using C#?
I have the contents of the html file stored in a string. I just need to replace some of the elements which have a similar pattern?
ex: I have a field {Token = LoanNumber} in the html file.
I just need to replace Loan Number with some text by finding the pattern "{Token=}".
Any suggestions are welcome.
Thanks.
|
|
|
|
|
You can use Regular Expressions to do this. Given the example string you posted, your pattern matching string might look something like this:
String token = "Token";
String pattern = @"\{" + token + @"=[\w]*\}";
This will find "{token=somevalue} ".
Your replacement string will look something like this:
String newValue = @"4321";
String replacement = @"{" + token + @"=" + newvalue + @"}";
So now, in a RegEx Replace operation, the result will be:
I have a field {SomeToken=54342643} in the HTML file.
will become
I have a field {SomeToken=4321} in the HTML file.
Create the RegEx object and execute the replacement with something like this:
RegEx regEx = New RegEx( strPattern, RegexOptions.IgnoreCase );
String resultHTML = regEx.Replace( strSourceHTML, strReplacementString );
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Im writing a PocketPC app. The application works fine with the emulator but when i deploy it to my xda2 when trying to create the dataset i get the following error
An unhandled exception of type 'System.TypeLoadException' occurred in System.Windows.Forms.dll<br />
<br />
Additional information: Could not load type System.Data.DataSet from assembly System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=B77A5C561934E089.
Anyone have a suggestion of whats wrong and how to fix it?
|
|
|
|
|
I could be wrong here, but it sounds like you developed your app on one version of the .NET Framework and the Pocket PC is running the other? (1.0 and 1.1)...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I believe the problem could be because I just installed the Whidbey release. So maybe VS.NET2003 has compiled my app against CF 2.0 rather than 1.0. How can i change what version of the framework an application uses?
|
|
|
|
|
Well, since your using the beta version, I don't know if this is going to work. Go to your Project Properties and find the Supported Runtimes option. The problem is, I don't know if your going to find this option in a CF Project! If not, you'll have to install the Whidbey Framework on your Pocket PC.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I decided to uninstall the CF on the xda and then reinstall it. But before installing it i decided to give the app a go, and strangely it works fine now, although i removed the cf from the settings->remove programs. Oh well it works now!
|
|
|
|
|
I have a .NET client app and a .NET console server app. Whenever the server throws an error, the exception information is as follows, regardless of the type of exception thrown: "The server encountered an internal error. For more information, turn on customErrors in the server's .config file"
Well, I'm currently not using a .config file for the server. Is there a way to turn on custom errors through code? RemotingConfiguration.CustomErrorsEnabled apparently has no effect, unless I'm using it wrong. Any ideas?
#include "witty_sig.h"
|
|
|
|
|
Not using a Web.config file? Why not? You should. It's just a file named Web.config put into the web application's root directory (not necessarily the web server's root directory) with the following (for your needs):
<configuration>
<system.web>
<customErrors mode="On" />
</system.web>
</configuration> Otherwise, you can handle the HttpApplication.Error event and do whatever you want. Typically you implement this in an IHttpModule implementation, but you'd need a .config file to configure your ASP.NET application to use it! You can also handle this in your Global.asax file (or its code-behind file) as well, but many times it's better to abstract your code by making it modular and/or service-oriented.
Seriously, though, you should use a Web.config file. You can configure runtime settings (not just for ASP.NET, but for all of .NET), security, impersonation, etc. etc.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm sorry I should've been more clear. The server application is not a web application. It's a standard .NET console application that talks to clients via .NET Remoting. Web.config applies only to web applications correct?
#include "witty_sig.h"
|
|
|
|
|
Correct, but the error resolution message you're getting is typical of ASP.NET web applications, which is why I assumed you were using ASP.NET. What exactly, then, is returning you such an error?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
An example would be when the client tells the server to perform some task and waits for return. While the server is performing some task, it will throw an exception. The client catches the exception, but doesn't tell me the exception type, message, stack trace, etc. and tells me to enable custom errors on the server if I want more information.
#include "witty_sig.h"
|
|
|
|
|
What I mentioned before is close, but now that I understand your client/server app a little better, I can tell you that you need to configure pretty much the same thing, except instead of using <system.web> use <system.runtime.remoting> and set the mode attribute to "on" (lower-case "o", for some reason - not very consistent).
This .config file would be named the same as your client application + .config at the end. The RemotingConfiguration.CustomErrorsEnabled method is merely a way to determine if custom errors are displayed based on the locality of the remote call.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you Heath I'll give that a whirl.
#include "witty_sig.h"
|
|
|
|
|
Did this actually work? Could you post an example or emial it to me. I am having the same problem and I am not having any success getting it to work. Currently, I am also not using a config file.
C LaMorticella
Client Instant Access
|
|
|
|
|
I have a form that is being maximized. The form is a child form of an MDI parent and there is another child form docked on the left as a menu. Therefore, when the form is maximized it needs to be maximized to (for instance location 256, 0, 200, 200 instead of 0,0,456,200 (where above is x, y, width, height). I'm having a real issue finding an event that fires BEFORE a maximize command to set the bounds and the maximizedbounds property doesn't seem to be doing any good. Any ideas, events, etc.?
Brian
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." - Douglas Adams
|
|
|
|
|
Override WndProc and handle the WM_SIZING (0x0214) message. This is sent to a window procedure (and keep in mind that almost all Windows Forms controls encapsulate native controls and dialogs) before being resized. The Message.WParam specifies the edge that is being resized and the Message.LParam specifies the RECT (which you must define in managed code - a System.Drawing.Rectangle will not suffice because it stores coordinates differently).
Set the Message.Result to new IntPtr(1) to signal that you've processed it and don't want your Form to be resized.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is it possible to get a reference to the object that is calling a method (maybe through something like Reflection)?
i.e. something like:
<br />
public class A<br />
{<br />
private B b;<br />
<br />
public A()<br />
{<br />
b.SomeMethod()<br />
}<br />
}<br />
<br />
public class B<br />
{<br />
public void SomeMethod()<br />
{<br />
if(callingInstance.Type == typeof(A)<br />
}<br />
}<br />
|
|
|
|
|
You can get the calling assembly using Assembly.GetCallingAssembly , but not the calling type. Since this is an object-oriented development platform, a more appropriate implementation would accept the caller as a parameter to the method, typically declared as an abstract class or an interface. The caller would have to implement that interface or extend that abstract base class and override whatever members are appropriate to call, so that your method or class can call those methods without knowing about a specific implementation of those methods.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello!
I want to check if a program is installed. For instance I want to see if the Visual C++ Toolkit 2003 is installed on my computer. How can I do this in C#?
Thank you for helping me!
|
|
|
|
|
|
Even after enumerating and possibly finsing the correct registry key, you should check for the exsistence of the dll or exe. Windows applications are infamous for not removing all registry entries after an un-install or even people will delete directories without using the un-install. Top and bottom is even if it has a registry key, don't assume that it's there.
Just expanding on what Heath mentioned.
Yes, I program in VB, but only to feed my addiction to a warm place to sleep and food to eat!
Visit my Code Project blog (Mobile Audio project)[^]
|
|
|
|
|
True to a point (although he didn't ask about files - merely products), but Windows Installer - unless you explicitly change the execution sequence from the default or change the Component table attributes or transitive condition to keep the component installed during uninstall - will remove all files it placed there originally. Windows Installer really is a powerful package distribution system, something I've been working with since it's 1.0 beta days and am currently beta testing for 3.0. If you're interested, you should take a look at the Windows Installer SDK on MSDN.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
[original posting]I want to check if a program is installed. For instance I want to see if the Visual C++ Toolkit 2003 is installed on my computer. How can I do this in C#?
The point I'm refering to is that just because something has a registry entry, doesn't mean it exists, only that it was installed at some point in time. I know from experience not to take anything for granted if it has a registry entry.
Heath Stewart wrote:
(although he didn't ask about files - merely products),
He wants to see if a specific product is installed. I merely wanted to point out that an un-install may have failed or been un-installed incorrectly (like deleting directory - infamous in users ) and still have left registry entries that may be included in the enum.
Regards,
Eric C. Tomlinson
P.S. Haven't used Windows Installer yet, all the clients I work for have subjected me to Installshield Maybe someday I'll be able to use it on something that I write (and actually finish)
Yes, I program in VB, but only to feed my addiction to a warm place to sleep and food to eat!
Visit my Code Project blog (Mobile Audio project)[^]
|
|
|
|