Hi All,
I've got a simple wrapper static test method on a class to expand the
environment variables on a specified string:
public static string ExpandEnvironmentStr(string Str)
{
return Environment.ExpandEnvironmentVariables(Str);
}
For some apparently security related reason it crashes with the following
exception:
An unhandled exception of type 'System.Security.SecurityException' occurred
in mscorlib.dll
Additional information: Request for the permission of type
System.Security.Permissions.EnvironmentPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
Being a security newbe I just can't figure out from the MS doc's what this
means and how to use the EnvironmentPermission to fix it. The doc's only
confused me completely. All I need to do is be able to read stuff from the
Environment class (expanding variables and retreiving special folders,
etc.). All the MS doc's examples say something like this... which doesn't
help me at all. I need to know HOW to keep it secure.
// <-- Keep this information secure! -->
Do I need some kind of assembly permission attribute in the AssemlyInfo.cs
file or some kind of attribute on this method? If so, what? Can someone
please explain this to me and give me working example? I'm baffled.
Many thanks in advance,
--
John Bowman
Verona, WI 18*******@charter.net 13 2170
"John Bowman" <jm******@charter.net> wrote in message
news:uP**************@TK2MSFTNGP09.phx.gbl... Hi All,
I've got a simple wrapper static test method on a class to expand the environment variables on a specified string:
public static string ExpandEnvironmentStr(string Str) { return Environment.ExpandEnvironmentVariables(Str); }
For some apparently security related reason it crashes with the following exception:
An unhandled exception of type 'System.Security.SecurityException' occurred in mscorlib.dll
Additional information: Request for the permission of type System.Security.Permissions.EnvironmentPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
Being a security newbe I just can't figure out from the MS doc's what this means and how to use the EnvironmentPermission to fix it. The doc's only confused me completely. All I need to do is be able to read stuff from the Environment class (expanding variables and retreiving special folders, etc.). All the MS doc's examples say something like this... which doesn't help me at all. I need to know HOW to keep it secure.
// <-- Keep this information secure! -->
Do I need some kind of assembly permission attribute in the AssemlyInfo.cs file or some kind of attribute on this method? If so, what? Can someone please explain this to me and give me working example? I'm baffled.
Many thanks in advance,
-- John Bowman Verona, WI 18*******@charter.net
Assuming you are running from a file share / Intranet site, the Code Access
Security (CAS) settings only allow you to read the USERNAME environment
variable and nothing else. If you copy the program locally you should be
able to have the program execute normally. This is because non-local code is
given fewer permissions than local code.
However, assuming you actually need to be able to run from the non-local
machine you need to adjust CAS policy in some way to give extra permissions
to this site or assembly. There are a couple of ways to do this.
CAS assigns permissions based on the information about the executing code
(like its origin in terms of where it is running from or who authored it)
this information is called Evidence.
The CAS policy on a machine performs tests on this evidence and assigns
groups of permissions (called Permission Sets) based on the code passing
this test. The mapping of a test of evidence to a permissoin set is called a
code group. You can see all of this policy configuration in the .NET
configuration utility (mscorcfg.msc) under the Runtime Security Policy
section.
The basic configuration is principally based on IE Zone (LocalMachine,
Intranet, Internet, etc). Your code is executing from the Intranet to you
need to add a code group under the Local Intranet codegroup. Make a test of
evidence based on the site, URL or stong name or your assembly and map it to
a permission set that will grant your code the rights it needs. You could
create a custom one that grants unrestricted access to the environment block
but you could set it to FullTrust for now. A custom one is better as it
means your code only has access to the things it needs to do (principle of
least privilege).
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
Richard,
Thanks for the explanations, it is a start in my learning curve. But I've
got nothing to do with the Internet for this program. It will ONLY be
installed and executed locally. This is even currently on a development
system where I've got Admin priviledges for the sake of testing/debugging.
Furthermore, when I use the "Evaluate Assembly" tool under the .NET 1.1
Configuration tool, it claims my assembly gets "Unrestricted" permissions.
So I still don't have a clue as to how to properly code this. I've used
Environment.GetFolderaPath() and Environment.NewLine, etc. before and never
had a problem.
Any more help?
John
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> wrote in message news:eu*************@TK2MSFTNGP09.phx.gbl... "John Bowman" <jm******@charter.net> wrote in message news:uP**************@TK2MSFTNGP09.phx.gbl... Hi All,
I've got a simple wrapper static test method on a class to expand the environment variables on a specified string:
public static string ExpandEnvironmentStr(string Str) { return Environment.ExpandEnvironmentVariables(Str); }
For some apparently security related reason it crashes with the following exception:
An unhandled exception of type 'System.Security.SecurityException' occurred in mscorlib.dll
Additional information: Request for the permission of type System.Security.Permissions.EnvironmentPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
Being a security newbe I just can't figure out from the MS doc's what this means and how to use the EnvironmentPermission to fix it. The doc's only confused me completely. All I need to do is be able to read stuff from the Environment class (expanding variables and retreiving special folders, etc.). All the MS doc's examples say something like this... which doesn't help me at all. I need to know HOW to keep it secure.
// <-- Keep this information secure! -->
Do I need some kind of assembly permission attribute in the AssemlyInfo.cs file or some kind of attribute on this method? If so, what? Can someone please explain this to me and give me working example? I'm baffled.
Many thanks in advance,
-- John Bowman Verona, WI 18*******@charter.net
Assuming you are running from a file share / Intranet site, the Code Access Security (CAS) settings only allow you to read the USERNAME environment variable and nothing else. If you copy the program locally you should be able to have the program execute normally. This is because non-local code is given fewer permissions than local code.
However, assuming you actually need to be able to run from the non-local machine you need to adjust CAS policy in some way to give extra permissions to this site or assembly. There are a couple of ways to do this.
CAS assigns permissions based on the information about the executing code (like its origin in terms of where it is running from or who authored it) this information is called Evidence.
The CAS policy on a machine performs tests on this evidence and assigns groups of permissions (called Permission Sets) based on the code passing this test. The mapping of a test of evidence to a permissoin set is called a code group. You can see all of this policy configuration in the .NET configuration utility (mscorcfg.msc) under the Runtime Security Policy section.
The basic configuration is principally based on IE Zone (LocalMachine, Intranet, Internet, etc). Your code is executing from the Intranet to you need to add a code group under the Local Intranet codegroup. Make a test of evidence based on the site, URL or stong name or your assembly and map it to a permission set that will grant your code the rights it needs. You could create a custom one that grants unrestricted access to the environment block but you could set it to FullTrust for now. A custom one is better as it means your code only has access to the things it needs to do (principle of least privilege).
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
"John Bowman" <jm******@charter.net> wrote in message
news:OZ**************@TK2MSFTNGP09.phx.gbl... Richard,
Thanks for the explanations, it is a start in my learning curve. But I've got nothing to do with the Internet for this program. It will ONLY be installed and executed locally. This is even currently on a development system where I've got Admin priviledges for the sake of testing/debugging. Furthermore, when I use the "Evaluate Assembly" tool under the .NET 1.1 Configuration tool, it claims my assembly gets "Unrestricted" permissions. So I still don't have a clue as to how to properly code this. I've used Environment.GetFolderaPath() and Environment.NewLine, etc. before and never had a problem.
Any more help?
John
Hmmm - so the evaluate assembly tool says you have fulltrust? Then it should
work.
Create a console app with the following code in it and make sure that
executes correctly, then copy it to the same place as the app you are trying
to run and try it there
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Environment.ExpandEnvironmentVar iables("%windir%"));
}
}
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
"John Bowman" <jm******@charter.net> wrote in message
news:OZ**************@TK2MSFTNGP09.phx.gbl... Richard,
Thanks for the explanations, it is a start in my learning curve. But I've got nothing to do with the Internet for this program. It will ONLY be installed and executed locally. This is even currently on a development system where I've got Admin priviledges for the sake of testing/debugging. Furthermore, when I use the "Evaluate Assembly" tool under the .NET 1.1 Configuration tool, it claims my assembly gets "Unrestricted" permissions. So I still don't have a clue as to how to properly code this. I've used Environment.GetFolderaPath() and Environment.NewLine, etc. before and never had a problem.
Any more help?
John
Oh, and admin privilege is nothing to do with CAS. CAS layers on top of
windows security and can provide extra restrictions based on the evidence
(it can't however extend permissions not granted by windows security)
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
Richard,
Thanks again for the additional assistance. The test app works perfectly,
even in the same location as the real app. When I copy your line:
Console.WriteLine(Environment.ExpandEnvironmentVar iables("%windir%"));
into my code to replace my existing function. It crashes just like my code.
Any other ideas?
John
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... "John Bowman" <jm******@charter.net> wrote in message news:OZ**************@TK2MSFTNGP09.phx.gbl... Richard,
Thanks for the explanations, it is a start in my learning curve. But I've got nothing to do with the Internet for this program. It will ONLY be installed and executed locally. This is even currently on a development system where I've got Admin priviledges for the sake of testing/debugging. Furthermore, when I use the "Evaluate Assembly" tool under the .NET 1.1 Configuration tool, it claims my assembly gets "Unrestricted" permissions. So I still don't have a clue as to how to properly code this. I've used Environment.GetFolderaPath() and Environment.NewLine, etc. before and never had a problem.
Any more help?
John
Hmmm - so the evaluate assembly tool says you have fulltrust? Then it should work.
Create a console app with the following code in it and make sure that executes correctly, then copy it to the same place as the app you are trying to run and try it there
using System;
class Program { static void Main(string[] args) { Console.WriteLine(Environment.ExpandEnvironmentVar iables("%windir%")); } }
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
"John Bowman" <jm******@charter.net> wrote in message
news:ez****************@TK2MSFTNGP12.phx.gbl... Richard,
Thanks again for the additional assistance. The test app works perfectly, even in the same location as the real app. When I copy your line:
Console.WriteLine(Environment.ExpandEnvironmentVar iables("%windir%"));
into my code to replace my existing function. It crashes just like my code.
Any other ideas?
John
How is your code being loaded - are you a plug-in or something like that?
There is obviously something fundementally different about the .exe I sent
and how your code executes - can you give us some more detail about what
your application does?
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
Richard,
Thanks again for continuing to try and help me out. Basically, it's an
installer launcher. It figures out what installers are on the media and then
launches them in succession. Nothing really fancy. The
Environment.ExpandVariables method is used whenever a folder spec is
retrieved from various places (such as the registry or ini file) to make
certain that any environment strings embedded in the retrieved value are
properly expanded. This same routine worked fine in another one of my apps.
Then I just lifted the code (such as it is <g>) and put it in here and now
it refuses to cooperate.
John
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> wrote in message news:ek*************@TK2MSFTNGP10.phx.gbl... "John Bowman" <jm******@charter.net> wrote in message news:ez****************@TK2MSFTNGP12.phx.gbl... Richard,
Thanks again for the additional assistance. The test app works perfectly, even in the same location as the real app. When I copy your line:
Console.WriteLine(Environment.ExpandEnvironmentVar iables("%windir%"));
into my code to replace my existing function. It crashes just like my code.
Any other ideas?
John
How is your code being loaded - are you a plug-in or something like that? There is obviously something fundementally different about the .exe I sent and how your code executes - can you give us some more detail about what your application does?
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
Ricahrd,
Thanks again for continuing trying to help me out. Basically, the program is
an installer launcher. It figures out what MSI based installers are present
on the media and runs them - nothing really fancy. It uses the
Environment.ExpandVariables method to make certain that any folder spec
strings retrieved from ini or registry are properly expanded before the
program makes any use of them. I had this code in another program and simply
lifted it for this one and now it doesn't work.
John
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> wrote in message news:ek*************@TK2MSFTNGP10.phx.gbl... "John Bowman" <jm******@charter.net> wrote in message news:ez****************@TK2MSFTNGP12.phx.gbl... Richard,
Thanks again for the additional assistance. The test app works perfectly, even in the same location as the real app. When I copy your line:
Console.WriteLine(Environment.ExpandEnvironmentVar iables("%windir%"));
into my code to replace my existing function. It crashes just like my code.
Any other ideas?
John
How is your code being loaded - are you a plug-in or something like that? There is obviously something fundementally different about the .exe I sent and how your code executes - can you give us some more detail about what your application does?
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
Sorry about the accidental double posts...
John
"John Bowman" <jm******@charter.net> wrote in message
news:u4**************@tk2msftngp13.phx.gbl... Ricahrd,
Thanks again for continuing trying to help me out. Basically, the program is an installer launcher. It figures out what MSI based installers are present on the media and runs them - nothing really fancy. It uses the Environment.ExpandVariables method to make certain that any folder spec strings retrieved from ini or registry are properly expanded before the program makes any use of them. I had this code in another program and simply lifted it for this one and now it doesn't work.
John
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co dot uk> wrote in message news:ek*************@TK2MSFTNGP10.phx.gbl... "John Bowman" <jm******@charter.net> wrote in message news:ez****************@TK2MSFTNGP12.phx.gbl... Richard,
Thanks again for the additional assistance. The test app works perfectly, even in the same location as the real app. When I copy your line:
Console.WriteLine(Environment.ExpandEnvironmentVar iables("%windir%"));
into my code to replace my existing function. It crashes just like my code.
Any other ideas?
John
How is your code being loaded - are you a plug-in or something like that? There is obviously something fundementally different about the .exe I sent and how your code executes - can you give us some more detail about what your application does?
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
"John Bowman" <jm******@charter.net> wrote in message
news:Ou**************@TK2MSFTNGP15.phx.gbl... Richard,
Thanks again for continuing to try and help me out. Basically, it's an installer launcher. It figures out what installers are on the media and then launches them in succession. Nothing really fancy. The Environment.ExpandVariables method is used whenever a folder spec is retrieved from various places (such as the registry or ini file) to make certain that any environment strings embedded in the retrieved value are properly expanded. This same routine worked fine in another one of my apps. Then I just lifted the code (such as it is <g>) and put it in here and now it refuses to cooperate.
John
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co dot uk> wrote in message news:ek*************@TK2MSFTNGP10.phx.gbl... "John Bowman" <jm******@charter.net> wrote in message news:ez****************@TK2MSFTNGP12.phx.gbl... Richard,
Thanks again for the additional assistance. The test app works perfectly, even in the same location as the real app. When I copy your line:
Console.WriteLine(Environment.ExpandEnvironmentVar iables("%windir%"));
into my code to replace my existing function. It crashes just like my code.
Any other ideas?
John
How is your code being loaded - are you a plug-in or something like that? There is obviously something fundementally different about the .exe I sent and how your code executes - can you give us some more detail about what your application does?
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
So John, I'm struggling a bit here as the way your code is getting executed
does not appear to be the same as you double clicking on a normal .exe.
Do you have something like
[assembly: PermissionSet( SecurityAction.RequestMinimum, Name =
"Internet")]
[assembly: PermissionSet( SecurityAction.RequestOptional, Name =
"Intranet")]
on the assembly?
What causes your code to run - the user starting the program explicitly or
something else?
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
Richard,
The program is started by someone double clicking on the .EXE like any
other. It will reside on the local hard drive, or a CD or a DVD. Since it's
an installer launcher and is used for launching both MSI isntallers and MSI
patches, it's possible that it might be downloaded as part of a software
update/patch, then executed. But it will not be run over the internet.
Someone might place it onto a shared network location where multiple users
can double click on it.
Also, I do not have any PermissionSet's on the assembly. Didn't know I
needed them. Do I need any kind of EnvironmentPermission attribute or
something that I saw in the MS doc's? When it comes to this stuff I'm a
complete newbie.
Thanks again.
John
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> wrote in message news:On**************@TK2MSFTNGP12.phx.gbl... "John Bowman" <jm******@charter.net> wrote in message news:Ou**************@TK2MSFTNGP15.phx.gbl... Richard,
Thanks again for continuing to try and help me out. Basically, it's an installer launcher. It figures out what installers are on the media and then launches them in succession. Nothing really fancy. The Environment.ExpandVariables method is used whenever a folder spec is retrieved from various places (such as the registry or ini file) to make certain that any environment strings embedded in the retrieved value are properly expanded. This same routine worked fine in another one of my apps. Then I just lifted the code (such as it is <g>) and put it in here and now it refuses to cooperate.
John
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co dot uk> wrote in message news:ek*************@TK2MSFTNGP10.phx.gbl... "John Bowman" <jm******@charter.net> wrote in message news:ez****************@TK2MSFTNGP12.phx.gbl... Richard,
Thanks again for the additional assistance. The test app works perfectly, even in the same location as the real app. When I copy your line:
Console.WriteLine(Environment.ExpandEnvironmentVar iables("%windir%"));
into my code to replace my existing function. It crashes just like my code.
Any other ideas?
John
How is your code being loaded - are you a plug-in or something like that? There is obviously something fundementally different about the .exe I sent and how your code executes - can you give us some more detail about what your application does?
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
So John, I'm struggling a bit here as the way your code is getting executed does not appear to be the same as you double clicking on a normal .exe.
Do you have something like
[assembly: PermissionSet( SecurityAction.RequestMinimum, Name = "Internet")] [assembly: PermissionSet( SecurityAction.RequestOptional, Name = "Intranet")]
on the assembly?
What causes your code to run - the user starting the program explicitly or something else?
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
Richard,
I copied your PermissionSet lines into my AssemblyInfo.cs and now at compile
time it complains:
Assembly generation failed -- Unexpected exception processing attribute --
System.ArgumentException: Unable to generate permission set; input XML may
be malformed.
What on Earth is it saying? What XML? Aside from the framework itself this
is a completely stand alone .EXE. Also, what are the allowed values for the
Name value string?
John
"John Bowman" <jo*********@thermo.com> wrote in message
news:eG****************@TK2MSFTNGP12.phx.gbl... Richard,
The program is started by someone double clicking on the .EXE like any other. It will reside on the local hard drive, or a CD or a DVD. Since it's an installer launcher and is used for launching both MSI isntallers and MSI patches, it's possible that it might be downloaded as part of a software update/patch, then executed. But it will not be run over the internet. Someone might place it onto a shared network location where multiple users can double click on it.
Also, I do not have any PermissionSet's on the assembly. Didn't know I needed them. Do I need any kind of EnvironmentPermission attribute or something that I saw in the MS doc's? When it comes to this stuff I'm a complete newbie.
Thanks again.
John
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co dot uk> wrote in message news:On**************@TK2MSFTNGP12.phx.gbl... "John Bowman" <jm******@charter.net> wrote in message news:Ou**************@TK2MSFTNGP15.phx.gbl... Richard,
Thanks again for continuing to try and help me out. Basically, it's an installer launcher. It figures out what installers are on the media and then launches them in succession. Nothing really fancy. The Environment.ExpandVariables method is used whenever a folder spec is retrieved from various places (such as the registry or ini file) to make certain that any environment strings embedded in the retrieved value are properly expanded. This same routine worked fine in another one of my apps. Then I just lifted the code (such as it is <g>) and put it in here and now it refuses to cooperate.
John
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co dot uk> wrote in message news:ek*************@TK2MSFTNGP10.phx.gbl... "John Bowman" <jm******@charter.net> wrote in message news:ez****************@TK2MSFTNGP12.phx.gbl... > Richard, > > Thanks again for the additional assistance. The test app works > perfectly, even in the same location as the real app. When I copy your > line: > > > Console.WriteLine(Environment.ExpandEnvironmentVar iables("%windir%")); > > into my code to replace my existing function. It crashes just like my > code. > > Any other ideas? > > John >
How is your code being loaded - are you a plug-in or something like that? There is obviously something fundementally different about the .exe I sent and how your code executes - can you give us some more detail about what your application does?
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
So John, I'm struggling a bit here as the way your code is getting executed does not appear to be the same as you double clicking on a normal .exe.
Do you have something like
[assembly: PermissionSet( SecurityAction.RequestMinimum, Name = "Internet")] [assembly: PermissionSet( SecurityAction.RequestOptional, Name = "Intranet")]
on the assembly?
What causes your code to run - the user starting the program explicitly or something else?
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
"John Bowman" <jm******@charter.net> wrote in message
news:OO**************@TK2MSFTNGP12.phx.gbl... Richard,
I copied your PermissionSet lines into my AssemblyInfo.cs and now at compile time it complains:
Assembly generation failed -- Unexpected exception processing attribute -- System.ArgumentException: Unable to generate permission set; input XML may be malformed.
What on Earth is it saying? What XML? Aside from the framework itself this is a completely stand alone .EXE. Also, what are the allowed values for the Name value string?
John
"John Bowman" <jo*********@thermo.com> wrote in message news:eG****************@TK2MSFTNGP12.phx.gbl... Richard,
The program is started by someone double clicking on the .EXE like any other. It will reside on the local hard drive, or a CD or a DVD. Since it's an installer launcher and is used for launching both MSI isntallers and MSI patches, it's possible that it might be downloaded as part of a software update/patch, then executed. But it will not be run over the internet. Someone might place it onto a shared network location where multiple users can double click on it.
Also, I do not have any PermissionSet's on the assembly. Didn't know I needed them. Do I need any kind of EnvironmentPermission attribute or something that I saw in the MS doc's? When it comes to this stuff I'm a complete newbie.
Thanks again.
John
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co dot uk> wrote in message news:On**************@TK2MSFTNGP12.phx.gbl... "John Bowman" <jm******@charter.net> wrote in message news:Ou**************@TK2MSFTNGP15.phx.gbl... Richard,
Thanks again for continuing to try and help me out. Basically, it's an installer launcher. It figures out what installers are on the media and then launches them in succession. Nothing really fancy. The Environment.ExpandVariables method is used whenever a folder spec is retrieved from various places (such as the registry or ini file) to make certain that any environment strings embedded in the retrieved value are properly expanded. This same routine worked fine in another one of my apps. Then I just lifted the code (such as it is <g>) and put it in here and now it refuses to cooperate.
John
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co dot uk> wrote in message news:ek*************@TK2MSFTNGP10.phx.gbl... > "John Bowman" <jm******@charter.net> wrote in message > news:ez****************@TK2MSFTNGP12.phx.gbl... >> Richard, >> >> Thanks again for the additional assistance. The test app works >> perfectly, even in the same location as the real app. When I copy >> your line: >> >> >> Console.WriteLine(Environment.ExpandEnvironmentVar iables("%windir%")); >> >> into my code to replace my existing function. It crashes just like my >> code. >> >> Any other ideas? >> >> John >> > > How is your code being loaded - are you a plug-in or something like > that? There is obviously something fundementally different about the > .exe I sent and how your code executes - can you give us some more > detail about what your application does? > > Regards > > Richard Blewett - DevelopMentor > http://www.dotnetconsult.co.uk/weblog > http://www.dotnetconsult.co.uk > So John, I'm struggling a bit here as the way your code is getting executed does not appear to be the same as you double clicking on a normal .exe.
Do you have something like
[assembly: PermissionSet( SecurityAction.RequestMinimum, Name = "Internet")] [assembly: PermissionSet( SecurityAction.RequestOptional, Name = "Intranet")]
on the assembly?
What causes your code to run - the user starting the program explicitly or something else?
John,
I wasn't saying you *should* have them, it was a possibility as to why youor
code was failing. When you add a RequestMinimum and RequestOptional then
anyting outside of that union is implcitly refused. If you had this type
thing in your assembly it would explain why the "evaluate assembly" said
fulltrust and yet the code wasn't running with it
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jwpioneer |
last post by:
I have a need within an application to modify the path environment variable,
as I need to find specific directories and remove them. I use the following
code to do this:
RegistryKey rkey = ...
|
by: John Dalberg |
last post by:
I am trying to lock down file access of some sites in a shared hosting
environment so that different users can only access their own site's
directory with their asp.net code. However there's a...
|
by: Bill Baker |
last post by:
I have a class that requires the Machine Name as a parameter in the
construtor. It is a Windows Form app. When I run the executable, I get the
"Send Error Report..." dialog. When I debug in VS.NET,...
|
by: tmoffett |
last post by:
I am very new to the language so please pardon my ignorance.
I am writing a small console application to gather hardware inventory
information. When I run the application locally all works well....
|
by: Richard Levasseur |
last post by:
(Forewarning, most of these problems and solutions come from being the
only developer in a 1 server department with no budget, few resources,
unresponsive IT, and non-technical managers, so thats...
|
by: Will Asrari |
last post by:
In my code I have created a Process for opening up a command line
executable using System.Diagnostics.Process that imports a csv full of
Generic Authorization account information to numerous tables...
|
by: mohins |
last post by:
I am getting the error while I am trying to connect to Oracle with my code in ASP.NET, this code is working in another machine, but it fails in my laptop, giving the below error.
Could not create...
|
by: ram.rachum |
last post by:
Hey, I'm looking for a good Python environment. That is, at least an
editor and a debugger, and it should run on Windows. Does anyone have
any idea?
|
by: =?Utf-8?B?SGVsZW4gVHJpbQ==?= |
last post by:
I am developing a web application in Visual Studio 2003, .NET 1.1 to run on
our intranet. I want to identify users to save them logging in.
The line:
UserName = Environment.UserName
is...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |