|
Does anyone know how to set environment variables in .NET?
|
|
|
|
|
The System.Environment class has methods to read the environment variables. However, this class has no method to set the environment variables for the current process.
To work around this problem, use the interop services to set the environment variables. Use SetEnvironmentVariable function.
ex
using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
namespace SetEnv
{
///
/// Summary description for Class1.
///
public class SampleSetEnvironmentVariable
{
// Import the kernel32 dll.
[DllImport("kernel32.dll",CharSet=CharSet.Auto, SetLastError=true)]
[return:MarshalAs(UnmanagedType.Bool)]
// The declaration is similar to the SDK function
public static extern bool SetEnvironmentVariable(string lpName, string lpValue);
public SampleSetEnvironmentVariable()
{
}
public static bool SetEnvironmentVariableEx(string environmentVariable, string variableValue)
{
try
{
// Get the write permission to set the environment variable.
EnvironmentPermission environmentPermission = new EnvironmentPermission(EnvironmentPermissionAccess.Write,environmentVariable);
environmentPermission.Demand();
return SetEnvironmentVariable(environmentVariable, variableValue);
}
catch( SecurityException e)
{
Console.WriteLine("Exception:" + e.Message);
}
return false;
}
}
class MyClass
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
// Create a sample environment variable and set its value (for the current process).
SampleSetEnvironmentVariable.SetEnvironmentVariableEx("TESTENV", "TestValue");
// Verify that environment variable is set correctly.
Console.WriteLine("The value of TESTENV is: " + Environment.GetEnvironmentVariable("TESTENV"));
}
}
}
Hi all this is Deeps..
|
|
|
|
|
During loading HTML page into HTMLDocument (IHTMLDocument2.write method), how could be launching of scripts in that page prevented?
|
|
|
|
|
Anyone out there know of a .net control for writing/printing cheques?
Can't seem to find anything!
Thanks, Brent
|
|
|
|
|
Do people still use cheques?!?
[Sorry, I don't know of such a control]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Most people don't
Most Businesses still do :*)
Brent
|
|
|
|
|
|
I wish there was an advanced .NET board but here goes.
Does anyone have experience with sending faxes from a .NET Website? I believe I am looking for a service that would allow someone to fax a PDF document or the actual web page to someone. I have looked around and saw a few but I am not sure about the system requirements. It looks like some of them are Web Services with no installations which is good (I think). It will be on a shared hosting plan but hopefully my shared hosting plan if anything special is needed.
Thanks.....Rob
Rob Taylor
www.tconsult.com
|
|
|
|
|
My colleagues and I are using .NET 2003 along with visual source safe on our developments. We keep running into compilation problems where we have multiple projects in our solution and some of the projects have references to other projects in the same solution. We keep getting errors when we compile saying that Visual Studio can't copy the dlls that we are making into the runtime folder because they are being held by another process. We've tried endless permutations of the Copy Local property on each of the references.
Has anyone run into similar problems?
does anyone know how to help?
Thanks.
|
|
|
|
|
|
Some advice:
1. always use project references. if you look in your .csproj file you'll notice the references use GUIDs, this means you have a project ref. however, you can only do this if you are referencing a project in the same solution.
2. if you have web projects, delete your VsWebCache, and make sure you don't have a run away process. just to be safe you could kill aspnet_wp.exe or restart iis.
[deleting vswebcache]
[STAThread]<br />
static void Main(string[] args)<br />
{<br />
foreach (string dir in Directory.GetDirectories(@"c:\documents and settings"))<br />
{<br />
string webCacheDir = dir + @"\VSWebCache";<br />
if (Directory.Exists(webCacheDir))<br />
{<br />
Console.WriteLine("Deleting " + webCacheDir + "...");<br />
Directory.Delete(webCacheDir, true);<br />
}<br />
}<br />
}
R.Bischoff
Denn Gott hat die Menschen so sehr geliebt, daß er seinen einzigen Sohn für sie hergab. Jeder, der an ihn glaubt, wird nicht verlorengehen, sondern das ewige Leben haben
|
|
|
|
|
Hi!
Is there anyone who knows whether it is possible to use more than 2 GB of main memory with the .net framework on a 32 Bit resp. 64 Bit system?!
|
|
|
|
|
|
Hi,
Soliant is quite true.
I once wrote a small program which went through the file system recursively and stored the streams of all files in a hashtable...
The prog worked fine in loading more than 2 GB of data in the memory... it seemed as if it was efficiently and smartly doing paging... without any error...
But obviously in this case other application's performance was getting affected.
regards
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
I have a form with controls bound to a DataView (could also be a DataTable). Every navigation example I see shows the typical "previous", "next", "first", and "last" navigation using buttons. I'm interested in being able to navigate (directly) to a given position in the BindingContext.
For example, if I know the primary key value of an entry in the data table, how do I directly navigate to that position within the BindingContext? Is there some way to use the Find method for the data table and then back into the corresponding position in the BindingContext?
Right now I am starting at the beginning of the BindingContext and iterating through each entry until I find the entry I'm looking for. This is an order O(n) operation and I'm hoping to find something much faster.
Kurt
|
|
|
|
|
i have the same prob
|
|
|
|
|
Just wondering:
Is someone using another framework, like Mono or Portable.NET ?
----------------------
I think war is a dangerous place.
George W. Bush - Washington DC, May 7th 2003
|
|
|
|
|
|
Portable.NET is not equivalent to the compact framework. Its goal is, like Mono, to rebuild a complete framework. It runs on GNU/Linux, Windows, Solaris, NetBSD, FreeBSD and MacOS X.
I've installed both Mono and P.NET under Linux, and... well it works, even if the System.Windows.Forms namespace and others are not very complete.
See www.go-mono.com
and
www.southern-storm.com.au/portable_net.html
for more info.
----------------------
I think war is a dangerous place.
George W. Bush - Washington DC, May 7th 2003
|
|
|
|
|
How can I create a listbox with each item presented by a combobox?
Thanks in advance.
|
|
|
|
|
|
Hello!
The ControlPaint.DrawComboButton() requires the rectangle inside which the button should be painted. Getting the height is easy, since probably it is equal to combobox height. However, what about the width? In my XP Pro machine it is about 19 pixels, but I would rather find a way to get the width rather than hard code it into the code.
I had a look at System.Windows.Forms.SystemInformation, but it doesn't include this information.
Regards,
Victor.
phpWebNotes is a page annotation system modelled after php.net.
http://webnotes.futureware.biz/demo.php[^]
|
|
|
|
|
Objective: Our Requirement is a Plugin Application in c# (.Net).
Our Proposed Solution Contains a Base Application (.exe), which contains a MDI Sort
Of Windows Form (Parent Form),acting as a Launching Pad & Display Area for our Plugins(dll’s). Basically our all Plugin contains a form and are all together an independent applications, except they are dll’s.
Problem: All the Plugin Forms are to be Opened/embedded into a panel on the Base Application Form. This is something MDI Parent/Child sort of Relationship across the Applications.
Is there any way to accomplish this?
OR Is there other way around to do the same (embedding)?
Regards
Dhanak
|
|
|
|
|
Sorry I don't see any Solution for this.
|
|
|
|
|
Hi,
Herez some tips to develop plugin architechture...
1) Your base application should either be aware of the plugin directory or should read the location of the plugins from an XML file.
2) Use reflection on the plugin DLLs to find the plugin class and invoke methods on it.
3) If you intend to use the plugin as a embedded composite control over a form then make sure that the plugin class is derived from "System.Windows.Forms.UserControl". Use Reflection to create an object of the plugin class. Use "this.Controls.Add()" method to add the plugin object into the form at the specified location.
4) If you intend to use the plugin as an MDI child then make sure the plugin class is derived from "System.Windows.Forms.Form" . Using reflection get the object of the plugin class and then do the following. (consider "objPlugin" the object of the plugin class)
objPlugin.MdiParent = this;
objPlugin.Show();
Hope these tips help you in developing what you intend to. I'm leaving the reflection and other such codes for your imagination.
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|